Skip to main content
gamedev.net
🔒 Locked

C++ code profiler

Started by nickwinters 5 replies 1.7k views
Original Post
nickwinters
nickwinters
Are there any free C++ profilers that someone would recommend? Thanks. -Nick
Drew_Benton
Drew_Benton
Quote:
Original post by nickwinters
Are there any free C++ profilers that someone would recommend?

Thanks.

-Nick


I made my own profiler so I knew exactly how it was working. I think it is very fast not to mention accurate up to 20 decimal places (the resolution of the timer I use). There are a few free commercial profilers that are good. [edit]VTune is not free [tears][/edit]. I'm sure there are a few more avaliable if you search google. If you wanted something simple take a look at my profiler [smile].

I have made a test project that shows you how to use it as well as provide the source code. If you do use it, let me know what you think! It is a project that I have not abadoned - I just haven't had time to make it releaseable and let people test it out, but since you asked about a profiler. The data's end result will look like this if you are intrested in trying it out.

- <Profile>- <Entry>  <Name>Program</Name>   <Hits>1</Hits>   <Time>0.14889693455053377000</Time>   </Entry>- <Entry>  <Name>Test For Loop 1000 Iterations Math</Name>   <Hits>1000</Hits>   <Time>0.00066504539559014263</Time>   </Entry>- <Entry>  <Name>Test For Loop 1000 Iterations No Math</Name>   <Hits>1000</Hits>   <Time>0.00073357527686321463</Time>   </Entry>- <Entry>  <Name>Test For Loop 32767 Iterations Math</Name>   <Hits>32767</Hits>   <Time>0.02826456649705676900</Time>   </Entry>- <Entry>  <Name>Test For Loop 32767 Iterations No Math</Name>   <Hits>32767</Hits>   <Time>0.03429002294722138800</Time>   </Entry>  </Profile>


Here is the included main.cpp file that shows its use:
#include "CProfiler.h"// Profiler variableCProfiler profiler;int main( int argc, char* argv[] ){	// Start the total program time	profiler.Start( "Program" );	for ( int x=0; x < 1000; x++ )	{		profiler.Start( "Test For Loop 1000 Iterations Math" );		int val = 100 / 2 * 5 / 5 * 6 / 4 * 7 / 4;		profiler.Stop( "Test For Loop 1000 Iterations Math" );	}	for ( x=0; x < 1000; x++ )	{		profiler.Start( "Test For Loop 1000 Iterations No Math" );		; // Do nothing		profiler.Stop( "Test For Loop 1000 Iterations No Math" );	}	for ( x=0; x < 32767; x++ )	{		profiler.Start( "Test For Loop 32767 Iterations Math" );		int val = 100 / 2 * 5 / 5 * 6 / 4 * 7 / 4;		profiler.Stop( "Test For Loop 32767 Iterations Math" );	}	for ( x=0; x < 32767; x++ )	{		profiler.Start( "Test For Loop 32767 Iterations No Math" );		; // Do nothing		profiler.Stop( "Test For Loop 32767 Iterations No Math" );	}	// Stop the total program time	profiler.Stop( "Program" );	// It is important to remember to save the results ;) but call this last!	profiler.Write_Data( "Profile.xml" );		// Standard return	return 0;}


It is XML so the end file looks nicer in a browser [wink]. I hope this helps some!

- Drew

[Edited by - Drew_Benton on January 21, 2005 5:01:55 PM]
b2b3
b2b3
And there's of course AMD CodeAnalyst. It has version for Windows and for Linux too. And it's free.
wyrzy
wyrzy
Quote:
There are a few free commercial profilers that are good. One example is VTune for intel processors

VTune is Not free for Windows. There is a free evalution (believe its good for 30 days - don't quote me). If you are running Windows then VTune is free for Non-Commercial development.

I personally use CompuWare's DevPartner Community Edition.
Drew_Benton
Drew_Benton
Quote:
Original post by wyrzy
Quote:
There are a few free commercial profilers that are good. One example is VTune for intel processors

VTune is Not free for Windows. There is a free evalution (believe its good for 30 days - don't quote me). If you are running Windows then VTune is free for Non-Commercial development.

I personally use CompuWare's DevPartner Community Edition.


You are absolutly correct! My mistake.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.