1-2 ?別?數???方法?程?計???

e@`ҤЪpɤkuO@ӪĪkAu@q{XipɡC`N MATLAB u{pɾv]ProfilerA²٭pɾ^AiHOpC@ӫOҦΪɶAæCXԲӪέpCרA禡SIsFL禡Abp@h]@hpUAߦϥ MATLAB pɾ~঳ĦapXC@Ө禡Ҫ᪺ɶAöiӶiiAi઺iVOG

pGA@~tΨϥΤF Intel h֤ߴAFϭpɾFíwGAAw MATLAB uϥΤ@Ӯ֤ߡAkpUG
  1. U Ctrl-Alt-Delete HҰʤu@޲zC
  2. IuBz{ǡvC
  3. HkI MATLAB.exeAÿܡu]w˩M(A)...vC
  4. uIuCPU 0vA MATLAB.exe ub֤ߤWC
pGAOϥ Linux/Unix @~tΡAiHϥΩROCӫw MATLAB uϥΤ@Ӯ֤ߡAkpUG
  1. ϥΤUCOX MATLAB ҹ{ǽs]Process ID, or PID^G
    ps -C MATLAB
  2. ] PID O 8674Ahڭ̥iHϥΤUCOӬd MATLAB iHϥΪ֤ߡG
    taskset -pc 8674
  3. ̫Aڭ̥iH]w MATLAB uΤ@Ӯ֤ߡG
    taskset -pc 0 8674
]AϥΧ MATLAB pɾAOoNodz]w^]wC^

MATLAB pɾOO profileAbi[WPﶵAHNP\CҦpAYn for jΩҥΨ쪺OOpɡAiHѦҤUCdҡG

Example 1: 01-{p/profile01.mprofile on % Ұʭpɾ for i = 1:1000 a = inv(rand(100)); % p 100x100 üƯx}ϯx} b = mean(rand(100)); % p 100x100 üƯx}C@業 end profile viewer % e{pɵG

槹Wz{XAMATLAB |NҪOɶέpܥXӡApUϡG

ѤWϥioAmean O@QIsF 1000 AΪ Total Time O 0.038 ]]tb mean ҦIsL禡ɶ^A Self Time u 0.022 Aɶä]t mean 禡]b M ɮס^IsL禡Ҫ᪺ɶC~Ainv M rand UQIs 1000 M 2000 A]oӫOOOثOA]L̪ Total Time | Self TimeAҪ᪺ɶiHѤW@AMC

Hint
@OOثOάO M ɮסA which O˵ӷYiCŪ̥iJ which mean which invAݬݶǦ^TPBC

YnD mean 禡pɱpAiHIWz mean sAGpUG

ѤWϥiHo mean 禡pɵGAڭ̬ƦܥiHݨ̪ɶԭzX{b 28 CAھڳoǰTAڭ̴NiHϥΡuvhӹ惡CįΤơAHDptת@CbWϦCA]tFҦثOpɸơCɭYAI@Ө禡sANiHMaݥXC@ӫO parent O]YIsOWhO^M children O]YQOҩIsUhO^AHΥL̦U۩ҦΪɶC

bWzdҤAMATLAB pɾbw]pUAOҦ禡ipɡAoǨ禡]t M ɮסBMEX ɮסAHΤثOCq`ثOwgǪΤƪAAq`ӥih[tAڭ̥iHܭpɾAuw M ɮפ MEX ɮ׶ipɡA]oɮפ~ﵽŶC profile Ou M ɮפ MEX ɮ׶ipɡAib profile on ᱵWu-detail mmexvAҦpG

Example 2: 01-{p/profile02.mprofile on -detail mmex % ҰʭpɾA M/MEX ɮ׭p for i = 1:1000 a = inv(rand(100)); % p 100x100 üƯx}ϯx} b = mean(rand(100)); % p 100x100 üƯx}C@業 end profile viewer % e{pɵG

ɭpɵGNu]t M ɮפ MEX ɮסApUϡG

ѩڭ̥ubN M ɮס]o̥u mean O^M MEX ɮס]bǫåX{^ɶAҥHӳܱo۷²Cڭ̤MiHIWz mean sANiHݨ즹禡Ҫ᪺ɶC

Hint
  • profile -detail builtin: Ҧ禡]t M/MEX ɮסBثO^pɡAw]
  • profile -detail mmex: u M/MEX ɮ׭p


MATLAB{]pGig