|
|
用的是创龙的OMAP-L138的板子和XDS100v3仿真器,用的方法是TSCL = 0;
3 `0 J/ z0 n6 u0 W TSCH = 0;' V, d. k4 A+ _4 A: m4 D c4 n [/ k
unsigned long long start,stop,overhead;9 x% H. }+ p W e
start = _itoll(TSCH,TSCL);
; K; J: E2 T6 p' d stop = _itoll(TSCH,TSCL);
% G0 @* J: e( p0 q6 y* i( ^( e4 D3 X1 s0 u+ i: w$ k+ ~
overhead = stop - start;
9 `! ]. l) Q1 a' kprintf("overhead run-time is %d\n",overhead);# [: ]' C% }- ~( H& n" j9 S. y
. H1 o+ n3 j" `) x
start = _itoll(TSCH,TSCL);2 |3 x6 U5 V9 l6 V& O6 x& J
//here is function% A- ?. H% a4 M2 a, f2 H1 ^4 |
function();
, n \" e1 D+ b* P! W( A5 ]& Rstop = _itoll(TSCH,TSCL);
, f$ N% Z7 J0 A+ iprintf("The function run-time time is %lu\n",(stop - start - overhead));- g& H: F# [6 D' m A
; p7 \+ R6 V3 Z2 I9 [3 a. V
* r9 m5 I1 A6 n! K, g- ?- w
为什么每次测量出来的时间都不一致?测量出来的不是一个固定的值。 _+ x' m7 R9 A% T2 B% J
* ~# U6 Z4 E3 @& i |
|