From: Jeff R. <dv...@di...> - 2014-10-06 04:47:01
|
Gustaf Neumann wrote: > What i did was to extend "configure" to look, if there is gettimeofday() > available > on the system. If it is, it bypasses the call to Tcl_GetTime() to get > the timestamp > via system call. On busy systems, Ns_GetTime() is one of the most > frequent calls, used e.g. for mutex timings, so this makes a difference. > > The advantage of using Tcl_GetTime() is to delegate system dependencies > to Tcl. This struck me as an interesting optimization question, so I wrote a quick program to test it (attached). The only test environment at the moment I have is a linux VPS, so there's bound to be random influences from virtualization and whatever else happens to be running on the host at the time, so the noise is high. Still, I was not able to see any clear difference between gettimeofday(), Ns_GetTime, and Tcl_GetTime - on any given run any of the three was equally likely to be fastest. time-int the program reports typically 2:1 system time:user time. What this suggests to me is that - at least in my environment - the probable few hundred cycles difference in the implementations is completely lost to syscall and timeslice overhead or possibly cache line flushes, and it's not worth spending too much time worrying about it. I'd be interested to hear anyone else's results and interpretations, or suggestions about how to better measure the differences in these. -J |