Gustaf Neumann wrote: > Am 06.10.14 06:46, schrieb Jeff Rogers: >> >> This struck me as an interesting optimization question, so I wrote a >> quick program to test it (attached).
> This is not an interesting optimization question, since Tcl itself uses > gettimeofday() > (plus jumping around which might have a bad cache and locality > influence, and some > more copying). I think my underlying point was missed in the measurements. If there is not significant performance advantage to the platform-specific optimized version of Ns_GetTime over the platform-independent Tcl_GetTime, is it worth it to keep the optimized version? The penalty to be paid is in problems like the current one, where the windows build is for some reason having problems. On windows the function is delegating to Tcl_GetTime, but the system-specific bits confuse the issue. Your measurements are consistent and show the relative results I expected. Such is the benefit of real hardware :) They show a small advantage to Ns_GetTime over Tcl_GetTime, about 1.2%. This *is* a very frequently called function, but it is also pretty fast in any case. That's 1.2% of perhaps 5% (?? totally random guess) of overall request processing time. To me, that adds up to not a lot. A different takeaway from this benchmark is that if you are trying to wring every last bit of performance out of this call, it might be advantageous to define it as a macro (or use gcc/c99 inline declarations so it can be inlined and avoid the function call overhead and get to within a few instructions of the raw gettimeofday call (presumably you'll still need to copy the elements to the Ns_Time struct). -J > > One cannot expect a big difference. For better reliability, > i've increased the count. Below are 4 runs on openacs.org. > The native call is from 8% to 20% faster (the latter one most > probably due to external influences). The machine is a bare metal. > Numbers will vary depending on the OS. The faster the > system function gettimeofday() is, the bigger is the percentage > difference. > > -g > > gustafn@openacs:~$ ./tt > count: 100000000 > Tcl_GetTime: 3858686 usec 0.04 per > Ns_GetTime: 3811593 usec 0.04 per > gettimeofday: 3561367 usec 0.04 per > gustafn@openacs:~$ ./tt > count: 100000000 > Tcl_GetTime: 3858657 usec 0.04 per > Ns_GetTime: 3824398 usec 0.04 per > gettimeofday: 3563398 usec 0.04 per > gustafn@openacs:~$ ./tt > count: 100000000 > Tcl_GetTime: 4351765 usec 0.04 per > Ns_GetTime: 4024717 usec 0.04 per > gettimeofday: 3594736 usec 0.04 per > gustafn@openacs:~$ ./tt > count: 100000000 > Tcl_GetTime: 3864511 usec 0.04 per > Ns_GetTime: 3831866 usec 0.04 per > gettimeofday: 3541932 usec 0.04 per > > > > ------------------------------------------------------------------------------ > Slashdot TV. Videos for Nerds. Stuff that Matters. > http://pubads.g.doubleclick.net/gampad/clk?id=160591471&iu=/4140/ostg.clktrk > _______________________________________________ > naviserver-devel mailing list > naviserver-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/naviserver-devel > ------------------------------------------------------------------------------ Slashdot TV. Videos for Nerds. Stuff that Matters. http://pubads.g.doubleclick.net/gampad/clk?id=160591471&iu=/4140/ostg.clktrk _______________________________________________ naviserver-devel mailing list naviserver-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/naviserver-devel