fivemack: (Default)
At work, I've the good fortune of having a two-CPU workstation on my desk.

Unfortunately, whilst the two CPUs are within a centimetre of one another on the same piece of silicon, they appear to maintain independent clocks running with a noticeable offset; I can't tell if the speeds are also different.

In any case,

a = clock()
multi_threaded_operation()
b = clock()


can leave b reading out as several seconds before a, if the main thread was initially on the core with the later clock and got rescheduled onto the other one after the operation. This is not helpful for seeing which things are actually faster than which others.

Is there a standard C library routine, or at least something in <sys/*.h>, guaranteed to read a clock of a kind such that I can be reasonably confident that the computer's got only one?

March 2024

S M T W T F S
     12
3456789
10111213141516
17181920212223
24 252627282930
31      

Syndicate

RSS Atom

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Aug. 3rd, 2025 06:47 am
Powered by Dreamwidth Studios