I wrote 2 versions of my program, wich is an evolutionary algorithm in c++. The first version is procedural and works fine and very fast. The second version is completely OOP, and the program finds results, but is very very slow (like 10 times slower than the 1st version). Is there a way to maybe measure time of segments of code inside loops or something like that? Any advice or idea would help. Thanks in advance.
Use a profiler. Which one is best depends on the platform/operating environment; e.g. with g++ you can use gprof, or if you don't want to recompile you can use oprofile, assuming Linux. On Solaris you could use dtrace. On other platforms, such as Windows or Mac, add the tag for your platform to the question...
You need a profiler to find performance related issues in your program.
Depending on the Visual Studio edition, you have various levels of profiling support in your Visual Studio. If you're lucky enough to be at the Visual Studio Ultimate or Premium edition, you have very good profiling support built right in.
If you're on Visual Studio Express or Visual Studio Professional, there is sadly no profiling support built into Visual Studio, but you can use for example info at this link how to do it manually for free with those editions anyway.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With