I saw a lot of messages about using the clock () function to determine the amount of elapsed time in a program with code that looks something like this:
start_time = clock(); //code to be timed . . . end_time = clock(); elapsed_time = (end_time - start_time) / CLOCKS_PER_SEC;
The value of CLOCKS_PER_SEC is almost certainly not the actual number of measures per second, so I'm a little afraid of the result. Without worrying about streaming and I / O, is the output of the clock () function scalable in some way so that this divison gives the correct wall clock time?
The answer to your question is yes.
clock() , CPU, . , , , , CLOCKS_PER_SEC 1000. , clock() , .
clock()
CLOCKS_PER_SEC
, . rdtsc "" - . (, Intel Core 2) . .
rdtsc
, clock(), , . "rdtsc" .
Source: https://habr.com/ru/post/1691370/More articles:Выбор случайных окон из многомерных рядов массивов Numpy - pythonC ++ How to make a timer accurate on Linux - c ++Проблема с безопасной зоной - отлично на iPhone X, а не на других - iosWhy does this function variable have initial values? - javascriptSlow operation using p5 in reaction - performanceImplicit casting operator not compiling outside the original assembly - c #std :: chrono doesn't seem to give exact resolution / frequency - c ++Optimization of the SIMD curve calculated from the second derivative - c ++query in cfc returns [n] elements on the local, but repeats the first element [n] times on a live site - coldfusionPython: should initializing variables inside blocks be avoided? - variablesAll Articles