|
2019-03-06
| ||
| 13:11 | • Closed ticket [da2cb25ca2]: New command "timerate": measurement of exe... artifact: 7992485aa6 user: sebres | |
|
2017-01-09
| ||
| 19:24 | • New ticket [da2cb25ca2]. artifact: f6ceaa5c4f user: sebres | |
New command "timerate": measurement of execution time
Closed / Acceptedda2cb25ca2e6d5e6a2703f377960ce8731ecffb6Created 10 years agoUpdated 8 years ago
Descriptionhtml2017-01-09 19:24:08
This is a interim PR, back-porting command timerate from my tclSE engine (previous PR on github).
See branch sebres-trunk-timerate.
Currently used as merge-point for clock-speed-up branch to compare performance between original tcl-clock and new tcl-clock engines.
Contains:
- new command
timerate, that allows to do the measurement of code executing more precise and in opposition to commandtimeis time-related (not count-related); - small fix to test tcl-clock under Windows (registry in development env);
Additionally pros of command "timerate"
timeratecan be calibrated to minimize influence of measurement overhead (and byte code execution overhead) -timerate -calibrate {}.
Following example diff shows influence of measurement and execution overheads (the times retrieved for execution of empty scope-block resp. of eachset i ...is more precise after calibration), e. g. in reality the execution time ofset i ...amounts to ca. 0.057 µs/#:
+ % # calibrate to minimize influence of overhead:
+ % timerate -calibrate {}
+ 0.04763798110968011 µs/#-overhead, 0.048467 µs/#, 40275119 #, 20632745 #/sec
% timerate {}
- 0.049425 µs/#, 20232613 #, 20232613 #/sec
+ 0.003276 µs/#, 19640807 #, 305208960 #/sec
% timerate {set i 0} 5000
- 0.155394 µs/#, 32176202 #, 6435240 #/sec
+ 0.057090 µs/#, 47953979 #, 17516238 #/sec
% timerate {set i 0; set i 1} 5000
- 0.221634 µs/#, 22559694 #, 4511938 #/sec
+ 0.113668 µs/#, 31042572 #, 8797543 #/sec
% timerate {set i 0; set i 1; set i 2} 5000
- 0.293191 µs/#, 17053736 #, 3410747 #/sec
+ 0.190558 µs/#, 21012023 #, 5247746 #/sec- to reset previously calibrated overhead
timerate -calibrate {} 0can be used; - it can measure compiled and not compiled code pieces (use option
-directto disable "compilation" outside of measure cycle, and will be executed byTclEvalObjExinsteadTclNRExecuteByteCode);
Normally it uses compiled version to measure (as it would be a part of compiled script or procedure body):
- # measure not-compiled version:
- % timerate -direct {}
- 0.089162 µs/#, 11215515 #, 11215515 #/sec
+ # measure compiled version:
+ % timerate {}
+ 0.049425 µs/#, 20232613 #, 20232613 #/sec- with option
-overheadan external calculated overhead can be specified for thetimeratecommand to measure execution of the part of script. Following example shows possibility to ignore overhead of execution of_initprocedure resp. more precise the speed of partstring tolower ...only:
% proc _init {} { string trim " test " }
% timerate { set obj [_init]; string tolower $obj }
0.758217 µs/#, 1318883 #, 1318883 #/sec
% timerate \
-overhead [lindex [timerate { set obj [_init] }] 0] \
{ set obj [_init]; string tolower $obj }
0.097757 µs/#, 1393420 #, 10229413 #/sec
sebreswiki2019-03-06 13:11:51
Integrated as part of TIP#527.
Log in (anonymous is fine) to add a comment.