To answer your edited question, you can use timers. You start a timer before executing your code and stop it right after. Then subtract Stop-Start to find out the ellapsed time..
Already answered here
1
solved Load time, traversal time, memory usage for different data segments C/C++ [closed]