|
2026-11-13
| ||
| 11:18 | • Closed ticket [625454ffff]: new arg to 'time' - iterations in secs p... artifact: 4c102d0c6c user: serhiy.storchaka | |
|
2009-07-14
| ||
| 17:53 | • Ticket [625454ffff]: 5 changes artifact: 4eb05dd196 user: dkf | |
| 17:50 | • Ticket [625454ffff]: 4 changes artifact: 99c97d511f user: dkf | |
| 17:50 | • Add attachment cps.tcl to ticket [625454ffff] artifact: dd702fbad3 user: dkf | |
|
2003-03-10
| ||
| 18:12 | • Ticket [625454ffff] new arg to 'time' - iterations in secs status st... artifact: 623e72216a user: dkf | |
| 04:53 | • Ticket [625454ffff]: 4 changes artifact: 48019fa82e user: dkf | |
|
2002-10-18
| ||
| 23:13 | • New ticket [625454ffff]. artifact: d31c97e6a0 user: davidw | |
new arg to 'time' - iterations in secs
Closed / Fixed625454ffffffffffffffffffffffffffffffffffCreated 24 years agoUpdated 20 days ago
Descriptionplain2002-10-18 23:13:25
[ I hate the brevity of the summary field ] Hi, While running some testing code that I wanted to time, it came up as a requirement that users want to run it not by number of iterations, but by a certain length of time. The idea occurred to me that [time] could take an additional argument - a qualifier stating that iterations is a number of seconds (I suppose you could also use 'minutes' or 'hours' for the additional arg if you wanted). The loop would then run for at least, but not precisely, that amount of time, and return the amount of microseconds per iteration. It would also be possible to script the whole thing, of course. Maybe that's a better course of action? The nice thing about time is that the loop overhead is minimal. Having it coded in C would mean that the results would be comparable to regular [time] results.
dkfplain2003-03-10 04:53:17
Logged In: YES user_id=79902 One problem with this. How to go about calibrating so that the time-reading code is not called very often, as reading the time is a fairly expensive operation (i.e. at least one syscall.) Techniques that would work well for slow chunks of code will be poor for fast chunks, and vice versa...
dkfplain2003-03-10 18:12:48
Logged In: YES user_id=79902 One possible technique is to use exponential growth of numbers of iterations per clock measurement until such time as the uncertainty in the measurement drops low enough for a reasonable estimate in the number of times to run the code to be made (or the total allotted time is exceeded.) The problem with this is that to estimate the uncertainty you need to know the accuracy of the platform's clock... :^/
dkfplain2009-07-14 17:50:31
File Added - 334999: cps.tcl
dkfplain2009-07-14 17:53:19
I've attached a file that comes from some the TclOO benchmarking suite. It tries *very* hard to get a stable set of performance figures, since it is aimed at timing very fast code (method calls originally). If this (or simple adaptations of it) is suitable for the purposes requested, it's perhaps worth putting in tcllib.
serhiy.storchakawiki2026-11-13 11:18:45
Implemented as the timerate command (TIP 527): timerate script ?time? runs the script for the given number of milliseconds and calibrates out the measurement overhead. It is available in Tcl 9.0, and as tcl::unsupported::timerate since Tcl 8.6.10.
Log in (anonymous is fine) to add a comment.
Attachments:
- cps.tcl [download] added by dkf on 2009-07-14 17:50:30. [details]