Michael,
here is a little bit more precise function duration measurement tool
(FDMT):

\
*******************************************************************
\ Precise measurement of duration of a FUNCTION
\ Pito 17-9-2010
\ based on the idea on FUNCTION separation by Michael Kalus
\ Pito's 4 primitives flib used
\ Pito's stopwatch used
\ atmega 1284p @25MHz


2000000. 2constant Nloop  \ 2mil measurements
fvariable t_fdrop
fvariable t_empty
fvariable t_empty1
fvariable t_function

: m1
\ measure empty loop1
_pi     100 0 timer-start do 20000 0
do sp@ >r r> sp! loop
loop timer-stop Nloop d>f f/ fdup t_empty1 f! 
cr fs. ." secs elapsed - empty1 loop" fdrop ;

: m2
\ measure fdrop
_pi     100 0 timer-start do 20000 0 
do sp@ >r fdrop r> sp! loop
loop timer-stop Nloop d>f f/ fdup t_fdrop f! 
cr fs. ." secs elapsed - fdrop loop" fdrop 

t_fdrop f@ t_empty1 f@ f- t_fdrop f!
cr t_fdrop f@ fs. ." secs duration of fdrop" ;

: m3
\ measure empty measurement loop
_pi _1e3 f* _e
100 0 timer-start do 20000 0
do fdup fdup fdrop fdrop loop
loop timer-stop Nloop d>f f/  fdup t_empty f! 
cr fs. ." secs elapsed - fdrop fdrop loop" fdrop fdrop ;

: fmeasure
\ did you run m1 m2 m3 already?

\ measure FUNCTION in measurement loop
_pi _1e3 f* _e 

100 0 timer-start do 20000 0
\
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
do fdup fdup f/ fdrop loop    \ <<<<< replaced one fdrop with
FUNCTION
\
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
loop timer-stop Nloop d>f f/ fdup t_function f! 

cr fs. ." secs elapsed - function fdrop loop"  fdrop fdrop

\ calculate clean FUNCTION duration
t_function f@ t_empty f@ f- t_fdrop f@ f+ t_function f!  \
t_function-(t_empty-t_fdrop)

cr t_function f@ fs. ." secs duration of f/ FUNCTION" ;


\
****************************************************************************************

Ex: (@25MHz f_cpu)

> m1

8.9653244E-6 secs elapsed - empty1 loop ok

> m2

1.4795408E-5 secs elapsed - fdrop loop
5.830083E-6 secs duration of fdrop ok

> m3

2.6738689E-5 secs elapsed - fdrop fdrop loop ok 

> fmeasure

2.9554117E-5 secs elapsed - function fdrop loop
8.6455116E-6 secs duration of f+ FUNCTION ok 

> fmeasure

2.858418E-5 secs elapsed - function fdrop loop
7.6755762E-6 secs duration of f- FUNCTION ok

> fmeasure

3.3853273E-5 secs elapsed - function fdrop loop
1.2944672E-5 secs duration of f* FUNCTION ok

> fmeasure

5.3068438E-5 secs elapsed - function fdrop loop
3.2159829E-5 secs duration of f/ FUNCTION ok


Thanks and have a nice weekend! Pito 








------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Amforth-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/amforth-devel

Reply via email to