When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
1 messages ยท Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
gperf not showing run time for half part of the program
gperf not showing run time for half of the program
Idk, I've never used gmon, but maybe you can try to use perf (iirc it should already come pre-installed with some Linux distributions). Also a sampling time of 0.01 seconds is way too grainy. That way you only get 100 samples per second while your CPU does billions of operations per second.
Also if you want someone to make something useful of the gmon report, then post it as text rather than a screenshot
You'll probably want to use perf record and perf report
it seems to me perf has more restrictions about library compatibilities and user privileges, so far I haven't succeeded in making it work...
Iirc you need to sudo it
<@undefined>
Please don't delete forum posts. They can be helpful to refer to later and other members can learn from them. In the future you can use !solved to close a post and mark a post as solved.
Thanks for this. One (probably stupid) question is, is it true that we only do profiling w/o optimizations like -O1/2/2 ? Does it even make sense to profile on code w/ optimizations?
@cobalt wedge Has your question been resolved? If so, type !solved :)
It's not a stupid question, because you've got mixed around.
It doesn't make sense to profile unoptimized code.
It does make sense to profile optimized code.
This is because when you profile your code, then you want to measure where it looses time. You will never ship the product (i.e. actually use the program) without optimizations enabled, because it just makes sense to make your code faster, so measuring time loss of the unoptimized thing is silly.
Typically the minimum optimization setting you want to have is -O2, but for your simple cases you'll most likely want to crank it to -O3
!solved
Thank you and let us know if you have any more questions!
This thread is now set to auto-hide after an hour of inactivity
Thanks. I tried look at the profiling report and it's kinda complicated to newbee like me. Since am still using gprof as of now I'm trying to find some visualization tools to help me get a clearer view ๐
Would you mind an additional question? I barely exported a visualized report from the tool and it mainly gives funciton level time costs. So I wonder if, in common sense, the profiling tools (like gprof and perf) are providing anything more than function level summary? like, which code block is using more time? Or, when it comes to sub function level, we'd better manually add some "system_clock" calls to dig it by ourselves?
How are you using perf right now?
Still on gprof with the profiling report generated with how much time it costs for each major function
also visualized with perf2dot for a call graph. But nothing goes beyond sub function level.
I know for a fact that with perf report you can even go into assembly level
Since the result of perf can also be processed by perf2dot, I guess results from perf would be similar but correct me if wrong.
I have no idea what perf2dot is tbh
huh, while reading the tutorial (it's been a time since I used perf) for assembly level you apparently should use perf annotate... Idk, I would need to read the tutorial again, but honestly I don't want to ๐
Still thanks for the hints, I think I should read the tutorial. I think gprof should be able to go assembly too, but if not then I will go for perf.
Gprof is a sampling profiler
You'll only see information where samples hit