How can I read operations in C ++?

How can I read operations in C ++? I would like to analyze the code better than just synchronizing it, because time is often rounded to 0 milliseconds.

+5
source share
11 answers

You can make accurate measurements by reading the time counter ( tsc ) of the CPU, which increases by one with each clock.

Unfortunately, reading is done using some assembler instructions in the code. Depending on the underlying architecture, the cost of reading varies from ~ 11 (AMD) to ~ 33 (Intel) tsc . With a 1 GHz processor, you can actually get nano-second accuracy.

, :

  • , cpu, AMD cool'n Intel SpeedStep.
  • , .
  • , SHED_RR SHED_FIFO. / , .
  • mlockall().

- ++, Linux, Linux, tsc i386, x86_64 ia64.

+3

, , . , , 10,000 , , . , , .

+7

" " - , . / , , , () ..

, , , .

, , ...

, - , O (1), O (log n), O (n) .. , ++, , . ( )

+5

- . Windows , Visual Studio, xperf tools Windows. xperf . xperf . .

+4

. /, . , , .

, n . .

+3

valgrind Linux. , .

+3

, , , PAPI - API - . , , Total Ops, FLOPS, -/ .. .

, .

+2

.

0

? , , .

, , , , , .

, , - .

0

( ) , , ++.

0

If you are concerned that your program is running as fast as possible, and it is single-threaded, and you are using an IDE, check this out: How to optimize the performance of your program

0
source

All Articles