|
|
用的是创龙的OMAP-L138的板子和XDS100v3仿真器,用的方法是TSCL = 0;! U% V3 Q, i7 \- L8 m- F
TSCH = 0;4 `$ ~/ L; r% a+ l% ^
unsigned long long start,stop,overhead;
% b! X: i. J' L' n, W- u start = _itoll(TSCH,TSCL);8 \: H$ p c1 `7 a! `3 m
stop = _itoll(TSCH,TSCL); : p: L( G# `- b! w
8 }' |( \" b) t$ J# E" ?- T9 Joverhead = stop - start;" Q. B4 H2 [$ c2 d7 | U, b
printf("overhead run-time is %d\n",overhead);( [- T0 X0 |( _$ E8 j/ u/ R/ E" T
?( Q) C" H2 _* ~4 Z, n/ x
start = _itoll(TSCH,TSCL);; V6 @/ f9 h& @8 a9 K
//here is function
4 q' H; M. g& J2 i( J5 R& O" a3 H" ?function();% b. x5 s- _7 z* A
stop = _itoll(TSCH,TSCL);. A( p# e o+ s- I, {+ G! b6 I! D
printf("The function run-time time is %lu\n",(stop - start - overhead));* G1 m( u! m% d+ U" r" H' {& t
: d. ~, o: A" B2 l7 V) a8 x- E- l! B; ~7 v6 S7 q
为什么每次测量出来的时间都不一致?测量出来的不是一个固定的值。
- Z) f+ M$ O0 E% g
. b! r; l. z- q7 Y$ z) F |
|