|
|
用的是创龙的OMAP-L138的板子和XDS100v3仿真器,用的方法是TSCL = 0;3 p/ c. x0 J( f B& N
TSCH = 0;
% q6 I6 E6 {$ W( i& o* j! V$ Z unsigned long long start,stop,overhead;# U3 y4 n! ]* }5 @9 i
start = _itoll(TSCH,TSCL);
3 I* F0 ]+ l" I! s6 K9 ^2 A: H stop = _itoll(TSCH,TSCL); # S3 d) l8 d9 Q" e! f; n
3 h( a K! z* x0 \; d2 Q( {
overhead = stop - start;% r* z" A, m9 V. q% m
printf("overhead run-time is %d\n",overhead);
4 R% c/ `8 |4 ~4 X9 M& d3 p( ^; e2 D8 }# h3 Q
start = _itoll(TSCH,TSCL);2 K* z8 w T( q9 v8 I$ w
//here is function5 Y) I, ^1 a! ?) k% h9 B
function();
) Y9 [% _; h& g$ Astop = _itoll(TSCH,TSCL);
" E0 C9 d' ~* a, N. q/ B1 B. y7 \7 uprintf("The function run-time time is %lu\n",(stop - start - overhead));2 P5 y8 B" G5 H1 J6 u0 ?2 L
3 q7 Z7 p$ K4 A/ L4 {2 Z$ \5 z9 p& T
为什么每次测量出来的时间都不一致?测量出来的不是一个固定的值。
8 K* S& y5 I& x9 A6 [1 Z' F& ~
: N$ g6 m+ b' |; a5 u- c8 V$ Q/ ^ |
|