????3.perfstat——????????????????

??????????????????ò?????????μ??????????忴???ó?????????????????????????????Щ????????????????????????????????????????????

??????Щ????????????????????????????????????CPU???м????????CPUbound?????Щ????????????????IO???????????CPU????????ò?????????IObound???????CPUbound?????????IObound????????????

??????????????Щ????????Perfstat???????????????????????????????????????????????????е??????????????????

????????У?????????????????????test1.c??

??????????????test1

<SPAN style="FONT-SIZE: 14px"> //test.c
 void longa()
 {
   int i??j;
   for(i = 0; i < 1000000; i++)
   j=i; //am I silly or crazy? I feel boring and desperate.
 }

 void foo2()
 {
   int i;
   for(i=0 ; i < 10; i++)
        longa();
 }

 void foo1()
 {
   int i;
   for(i = 0; i< 100; i++)
      longa();
 }

 int main(void)
 {
   foo1();
   foo2();
 } </SPAN>

????????????????????? test1

????gcc – o test1 – g test.c

????????????????-g????????????????????

????????????? perf stat ?????? test1 ???????

?????????????

?????? test1???е????????????? ( ????????????? )???????????????????????Ч???

??????????£????? task-clock-msecs ???perf stat ?????????????????????????????

????Task-clock-msecs??CPU ??????????????????????????仨???? CPU ????????? IO??

????Context-switches???????л??????????????????й????з????????ν????л????????????л???????????

????Cache-misses?????????й?????????? cache ???????????????????????????? cache ???ò???

????CPU-migrations????????? t1 ???й????з????????? CPU ??????????????????? CPU ??????????? CPU ?????С?

????Cycles??????????????????????????????? cycles??

????Instructions: ????????????

????IPC???? Instructions/Cycles ???????????????????????????????????????????

????Cache-references: cache ???е????

????Cache-misses: cache ?Ч???????