Skip to content
Tcl Source Code History Of Ticket 1821187
Login

History Of Ticket 1821187

Artifacts Associated With Ticket 1821187

  1. Ticket change [e6a43b3d97] (rid 104328) by msofer on 2007-10-27 12:08:24:

    1. assignee initialized to: "kennykb"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      When working on performance measurements of tiny bites of code (eg, individual instructions in TEBC) the resolution of TclpGetClicks() is sometimes insufficient. But the platform may have click sources of higher resolution.
      
      * OSX has TclpGetWideClicks which (I am assuming) has higher resolution
      
      * Windows has the QueryPerformanceCounter function, which is used elsewhere in tclWinTime.c but not for this purpose
      
      * on Pentium and later x86 cpus the rdtsc opcode is available. On linux, the rdtscll function may or may not be available depending on kernel config, but we can define it as
      
      #define GetClicks(foo) do {\
         uint32_t __a,__d; \
         asm volatile("rdtsc" : "=a" (__a), "=d" (__d)); \
         (foo) = ((unint64_t)__a) | (((uint64_t)__d)<<32); \
      } while(0)
      
      * other platforms?
      
      The last two solutions (OSX too?) would require that the process be confined to a single cpu to insure accuracy, but we can leave that to the user.
      
    4. foundin initialized to: "None"
    5. is_private initialized to: "0"
    6. priority initialized to: "5 Medium"
    7. resolution initialized to: "None"
    8. status initialized to: "Open"
    9. submitter initialized to: "msofer"
    10. subsystem initialized to: "06. Time Measurement"
    11. title initialized to: "extend TclpGetWideClicks to other platforms"
    12. type initialized to: "RFE"
  2. Ticket change [7df48e2701] (rid 97320) by das on 2007-11-06 12:26:59:

    1. icomment:
      Logged In: YES 
      user_id=90580
      Originator: NO
      
      On OSX, TclpGetWideClicks() is based on mach_absolute_time() which is the highest resolution timer available on OSX in a processor-independent fashion. It runs at the CPU bus frequency and is incremented independently of multiple cores/CPUs or speedstep and the like. The frequency can be determined via mach_timebase_info(), allowing conversion of wide clicks to nanonseconds in TclpWideClicksToNanoseconds()  - which is used by [time] on OSX (for docs c.f. http://developer.apple.com/qa/qa2004/qa1398.html).
      There are higher resolution processor-specific timers available, e.g. on the intel pentium m family there are the PMCs CPU_CLK_UNHALTED and CPU_CLK_UNHALTED.BUS (the latter independent of speedstep), my tclCHUDtime.tcl extension uses these to do higher-resolution timing, also c.f. there for the code to convert ticks of these timers to nanoseconds: http://rutherglen.ics.mq.edu.au/~steffen/tcltk/carboncritlib/tclCHUDtime.tcl
      
      
    2. login: "das"
    3. mimetype: "text/plain"
    4. username: "das"