Nice job, but I'm a contrarian. Sorry. I only care about the overall time and how to reduce it. To find out what to fix, I use stackshots. To get a stackshot, run under gdb, hit ^C, thread 1, and bt. If it doesn't run long enough, wrap a temporary loop around the outside. So what do I get? stack 1. in timewaster, no surprise. Fix: comment out timewaster stack 1. in printf, no surprise. Fix: comment out printf Result: loop 100e6 times, 12 sec. (120 nsec) stack 1. at line a[i] = fib3(i-1) + fib3(i-2); stack 2. at line int fib3(int i){ i.e. Spends all its time in the function call Fix: So get rid of the function call. Do a[j]=a[j-1]+a[j-2]. Now it takes 5 sec (50 nsec - 2 times faster than before). Usually, I take several stackshots, but less than 20. The point is, if something you can do will save X% of time, then it will be on at least X% of stackshots. That's not timing, it's identifying speedups. Added: as I think about it, the above code is going to spend most of its time indexing the a array. Not necessary. The inner loop could look something like this: int x, y=1, z=1; x = y+z; y = x+z; z = x+y; and when you get to the end, grab the right one.
@@antshivrobotics A GUI that gives line-by-line analysis of exactly which lines of code are taking a long time to run, with red highlighting of the problematic lines of code. That together with a function stack view that lets you "expand hot path". Visual Studio performance profiler lets you double-click a function name to see the code of that function with an analysis of each and every line of code. It works great with the Release build of your application! (not only debug) Essentially all AAA game devs use C++ and use Visual Studio for performance profiling. It even has GPU performance profiling.
There are things a CLI do better than a GUI. Profiling and debugging are not part of those things. We have to admit that no tool comes even close to Visual studio when it comes to debugging and especially profiling.
If you liked the video, please subscribe and turn notifications on to not miss any future videos, thank you!
Nice video, thanks! It would be great if you made the same tutorial for memory profiling.
thank you so much man insane video :)
Thank you!
Good video, thank you sir. subscribed!
Thank you
Nice job, but I'm a contrarian. Sorry. I only care about the overall time and how to reduce it. To find out what to fix, I use stackshots. To get a stackshot, run under gdb, hit ^C, thread 1, and bt. If it doesn't run long enough, wrap a temporary loop around the outside.
So what do I get?
stack 1. in timewaster, no surprise.
Fix: comment out timewaster
stack 1. in printf, no surprise.
Fix: comment out printf
Result: loop 100e6 times, 12 sec. (120 nsec)
stack 1. at line a[i] = fib3(i-1) + fib3(i-2);
stack 2. at line int fib3(int i){
i.e. Spends all its time in the function call
Fix: So get rid of the function call. Do a[j]=a[j-1]+a[j-2].
Now it takes 5 sec (50 nsec - 2 times faster than before).
Usually, I take several stackshots, but less than 20. The point is, if something you can do will save X% of time, then it will be on at least X% of stackshots. That's not timing, it's identifying speedups.
Added: as I think about it, the above code is going to spend most of its time indexing the a array. Not necessary. The inner loop could look something like this: int x, y=1, z=1;
x = y+z; y = x+z; z = x+y;
and when you get to the end, grab the right one.
These performance profilers are a disgrace compared to the Microsoft Visual Studio Performance Profiler
Interesting. In what way?
@@antshivrobotics A GUI that gives line-by-line analysis of exactly which lines of code are taking a long time to run, with red highlighting of the problematic lines of code. That together with a function stack view that lets you "expand hot path".
Visual Studio performance profiler lets you double-click a function name to see the code of that function with an analysis of each and every line of code.
It works great with the Release build of your application! (not only debug)
Essentially all AAA game devs use C++ and use Visual Studio for performance profiling. It even has GPU performance profiling.
@@ronensuperexplainer I second it. For large projects, I would recommend Visual studio.
There are things a CLI do better than a GUI. Profiling and debugging are not part of those things. We have to admit that no tool comes even close to Visual studio when it comes to debugging and especially profiling.