I have two identical purpose programs made in C++ and i need to compare the total execution time, total CPU usage, total memory usage, execution time at instruction level, etc. The main difference between the two programs are that the first is made using threads and the second using processes. The proposal is simply run N threads or processes and wait them to stop.
I already used -pg option in the g++ compiler but the program that uses processes created many gmon.out files, one per process. I think the correct way to do this is by adding some instructions to my code to measure time, etc.
you should run both through a good profiler. There are tools to do what you want already. I don't know the go-to for unix, visual studio has one built in.
you can do it yourself, but its going to be a big pain.