[Python-Dev] Python Benchmarks

"Martin v. Löwis" martin at v.loewis.de
Sat Jun 3 12:33:16 CEST 2006

Fredrik Lundh wrote:
>> it is updated whenever the scheduler schedules a different thread.
> updated with what?  afaik, the scheduler doesn't have to wait for a 
> timer interrupt to reschedule things (think blocking, or interrupts that 
> request rescheduling, or new processes, or...) -- but it's always the 
> thread that runs when the timer interrupt arrives that gets the entire 
> jiffy time.

Sure: when a thread doesn't consume its entire quantum, accounting
becomes difficult. Still, if the scheduler reads the current time
when scheduling, it measures the time consumed.

> if the scheduler used the TSC to keep track of times, it would be 
> *measuring* process time.  but unless something changed very recently, 
> it doesn't.

You mean, "unless something changed very recently" *on Linux*, right?
Or when did you last read the sources of Windows XP?

It would still be measuring if the scheduler reads the latest value
of some system clock, although that would be much less accurate than
reading the TSC.

> times(2) reports time in 1/CLOCKS_PER_SEC second units, while jiffies 
> are counted in 1/HZ second units.  on my machine, CLOCKS_PER_SEC is a 
> thousand times larger than HZ.  what does this code print on your machine?

You are right; clock_t allows for higher precision than jiffies.


More information about the Python-Dev mailing list