1

What does clock_t mean in c++? I want the number of clock ticks used by the CPU hardware. Does clock_t represent the crystal clock?

Dharun
  • 11
  • 2
  • "*Clock ticks are units of time of a constant but system-specific length*". What's wrong with that definition? btw.: which crystal clock? – dhke Sep 12 '15 at 10:17
  • 2
    You might want to read more about [the `clock` function](http://en.cppreference.com/w/c/chrono/clock). – Some programmer dude Sep 12 '15 at 10:17

1 Answers1

1

clock_t is just a typedef for some of integer value. Clock_t does not represent a clock, just a number.

You use clock_t type to be sure, that clock() function's return value can be held in a variable of this type

You do not want usually to know crystal clock ticks. There is no need for this. Crystal clock ticks are not the same as processor's internal clock frequency.

Eg. ARM's has inside them a device called PLL, that multiplies crystal clock's frequency.

DawidPi
  • 2,285
  • 2
  • 19
  • 41
  • Thank you for your response!. :) I want to know the crystal clock frequency for bench marking purposes.Is there any code to do that? – Dharun Sep 12 '15 at 10:40
  • 1
    I do not know it myself. And AFAIK it's not that easy task. Take a look at: http://stackoverflow.com/questions/8351944/finding-out-the-cpu-clock-frequency-per-core-per-processor – DawidPi Sep 12 '15 at 10:51