Deeper Profiling / Function Emulation

Hello everyone, Merry Christmas. I need some advice, I have the following code:

int main() { int k=5000000; int p; int sum=0; for (p=0;p<k;p++) { sum+=p; } return 0; } 

When I collect it, I get

 main: pushl %ebp movl %esp, %ebp subl $16, %esp movl $5000000, -4(%ebp) movl $0, -12(%ebp) movl $0, -8(%ebp) jmp .L2 .L3: movl -8(%ebp), %eax addl %eax, -12(%ebp) addl $1, -8(%ebp) .L2: movl -8(%ebp), %eax cmpl -4(%ebp), %eax jl .L3 movl $0, %eax leave ret 

If I run it through gprof, I get that the main execution is complete, which is quite obvious! However, I want to take another step and find out if there is more L2 or L3. here it is obvious that L3 performed the most. is there still some kind of profiler, emulator, which can give me this data for all the code?

+4
source share
1 answer

Well, if you are not against low-tech, you can answer any such question either with a single tap or in this way . For the latter method, it doesn't matter how big or complex your program is.

+1
source

Source: https://habr.com/ru/post/1333394/


All Articles