'''Clock and Timing Granularity''' presents ideas for a [Tcl] clock with finer granularity . How precise is the timing clock in Tcl? When using `[after]`, an interesting thing happens when you start using small values, you don't necessarily get the [callback] until later. This can cause problems if you are doing animation, like I am right now. Run on different WinXP SP2 computers: Not so good. ======none % set e [clock micro] ; after 5 {puts [expr [clock micro] - $e]} after#39 16000 ====== Now this is more like it! ====== % set e [clock micro] ; after 5 {puts [expr [clock micro] - $e]} after#5914 5055 ====== Different machines will fail at different small values. I think this is because of the way `[after]` must be implemented on windows. See [http://www.geisswerks.com/ryan/FAQS/timing.html%|%Results of some quick research on timing in Win32], Ryan Geiss, 2002-08-16 (...with updates since then). ** How to fix it? ** I'm thinking to make a separate thread use a better [Win32] timing schedule command and call the main thread. I guess this is reimplementing `[after]`. Anyone have a better idea? ** From the web ** '' As I mentioned earlier the default PIC resolution for the OS when it starts up is around 16 milliseconds. Let’s say that you set a periodic timer to fire every 5 milliseconds, with the PIC set at 16 milliseconds you will only be alerted every 16 milliseconds (at best). This level of accuracy is usually good enough for most applications. However, for time critical applications such as audio and video playback this resolution just is not good enough. '' http://blogs.msdn.com/b/mediasdkstuff/archive/2009/07/02/why-are-the-multimedia-timer-apis-timesetevent-not-as-accurate-as-i-would-expect.aspx ** See Also ** [https://groups.google.com/d/msg/comp.lang.tcl/MTytQJSfo_c/bPoftvFE2FYJ%|%clock click -milliseconds resolution - again...] , [comp.lang.tcl] , 2004-06-02 : in which [KBK] discusses the extent [Tcl] goes to to get finer granularity , and what is problematic about [Microsoft Windows%|%Windows] <> After | Clock | Discussion