P
P
pixik2015-09-09 09:19:32
linux
pixik, 2015-09-09 09:19:32

How to measure the number of operations performed by the processor during the execution of a certain program with a given algorithm under linux?

Good afternoon, dear ones!
The essence of the problem is this, I developed a program on a powerful desktop computer, everything flies and is generally good. You need to run the same on the microcomputer. To do this, you need to understand what computing power I need on board this microcomputer.
Surely there is some solution that does something like this:

cpu_prof ./mySuperProgram
total cpu operation: 100500
total time: 100ms

I decided that I needed to measure the number of processor operations performed during the execution of the program and the time interval. And based on this, think how many MIPS you need on a microcomputer processor (OrangePI mip, etc.).
Are there any special utilities that tell you how many resources were used for a particular application?
It would also be interesting to know what performance measurement tools are available under Linux for c ++ applications, so that in case of a strong difference between existing processors and the required one, it would be possible to work more finely somewhere in the code.
Thanks everyone!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
J
jcmvbkbc, 2015-09-09
@pixik

How to measure the number of operations performed by the processor during the execution of a certain program with a given algorithm under linux?

perf stat <program with its arguments>
For example:
$ perf stat ls
...
 Performance counter stats for 'ls':

          2.287765 task-clock                #    0.666 CPUs utilized          
                36 context-switches          #    0.016 M/sec                  
                 0 cpu-migrations            #    0.000 K/sec                  
               283 page-faults               #    0.124 M/sec                  
         3,555,075 cycles                    #    1.554 GHz                     [67.11%]
         2,620,681 stalled-cycles-frontend   #   73.72% frontend cycles idle    [78.12%]
         2,041,963 stalled-cycles-backend    #   57.44% backend  cycles idle   
         1,807,743 instructions              #    0.51  insns per cycle        
                                             #    1.45  stalled cycles per insn
           356,700 branches                  #  155.916 M/sec                  
            14,920 branch-misses             #    4.18% of all branches         [58.70%]

       0.003432740 seconds time elapsed

S
Saboteur, 2015-09-09
@saboteur_kiev

What is a microcomputer?
You need to understand that if the architecture is the same there, and the binary is the same but just less powerful, then there is generally no difference in MIPS, with the exception of the cost of the operating system.
If the architecture is different, then the binary will be different.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question