From: Albert G. <Dr....@t-...> - 2008-07-06 11:34:48
|
Libor Spacek wrote: > With these new facilities, I would like to implement in pure a finer-grained timing than the global stats currently provides. You can already do that: > using system; > foo n = #(1..n); // for testing purposes > (clock-t0)/CLOCKS_PER_SEC,res when t0 = clock; res = foo 1000000 end; 1.85,1000000 It's a bit inconvenient, but it works. The clock function uses the same C routine measuring CPU (rather than wallclock) time which is also used by the stats command. > The natural name for it would be "time", aka the unix command line "time", which would excecute and time its argument: > (time somethingtorun), and return (msecs, somethingreturned). That function would have to be a special form. Either it needs to be implemented in the compiler, or we need some facility to define macro functions to be executed at compile time (pretty much like 'def', but for defining macros which can take arguments), then it could be defined in terms of 'clock' above. I'm leaning towards the latter solution, because it's much more general, and would be useful in lots of other situations. > This will allow timing comparisons scripts to be defined, > instead of typing them manually to the interpreter. You can do that with stats, too, you'll just have to pipe it into the interpreter via stdin redirection (rather than passing the script name as a parameter), so that the interactive commands work. > 1) Do you think this could be useful (in addition to the existing global "stats") Yes. That's why the clock function is there, incidentally. :) > 2) if so, can you suggest suitable names for it, or rename "time" in system? I won't rename time in system, it should be named like the C function. But feel free to suggest other names for the timing function. Cheers, Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikinformatik.uni-mainz.de/ag |