Jump to content
  • Advertisement
Sign in to follow this  
renqilin

My open source C++ performance profiler

This topic is 3561 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi everyone, I wrote a simple C++ performance profiler these days. Any suggestion is welcome. You can download it at: https://sourceforge.net/project/showfiles.php?group_id=249996 Homepage: http://freeprofiler.sourceforge.net/ ==============================================================================

Introduction

1. Basic Information

FreeProfiler is a light weighted C++ code performance profiler. It provides utility macros for users to insert into their code. After recompiling and running their application, user can watch the performance result. Unix name: freeprofiler CVS anonymous access: :pserver:anonymous@freeprofiler.cvs.sourceforge.net:/cvsroot/freeprofiler

2. Why Use FreeProfiler?

2.1 Compared to other performance profilers, FreeProfiler has smaller granularity. It focuses on code block times and message processing times, not functions. So user can know exactly how much time is consumed by a specific part of a function, or how much time is consumed by a specific windows message. Here is a typical case where FreeProfiler is useful: You have a window callback procedure function, and you want to know which message consumes much time. So you simply add FreeProfiler macros at the beginning of your windows callback procedure, like this:
LRESULT CALLBACK AppWndProc(HWND hwnd, int message, WPARAM wParam, LPARAM lParam) 
{ 
        FreeProfilerRecordMessageBlock(message); 
        switch (message) 
        { 
        case WM_CREATE: 
                ...... 
        ...... 
        } 
        ...... 
}

And you can view the xml-format result after you exit your application. 2.2 It is light-weighted. FreeProfiler has minimal impact on the performance of the application. 2.3 It is thread-safe. So you don’t need to worry if your function will be called by multiple-threads simultaneously. 2.4 It is open source and free. You can use it for any purposes. [Edited by - renqilin on January 19, 2009 4:15:53 AM]

Share this post


Link to post
Share on other sites
Advertisement
I made some modifications to the package. Now there are two zip files: One is binary zip, the other is source zip.

If you don't want to compile FreeProfiler by yourself, you can just download binary zip.

Share this post


Link to post
Share on other sites

I just realized that there are the following bugs in my package:

1. __declspec(thread) does not work well with LoadLibrary. (This is fixed now).
2. rdtsc does not work well on a multi-core CPU.




Share this post


Link to post
Share on other sites
Hi Rattenhirn, Thanks for your comment. I'm sorry that FreeProfiler won't work if you don't insert the macros into your code. I have logged this as a future feature. Ideally FreeProfiler should analyze your source code and insert those detecting macros into your code automatically.

For now, you need to insert macros by yourself. However, one benefit of this is that you can detecting the performance of a small part of an algorithm.

Share this post


Link to post
Share on other sites
Nice tool. Thanks for making this open source.

I browsed the source and noticed that you use construction and destruction to start and stop the high performance timer. I've been using this technique at work to do ad-hoc profiling and found it extremely useful in hunting down bottlenecks without pulling out the the big guns (like BoundsChecker). This is much more mature, cheers for putting it together. It may find it's way into my hobby projects.

Share this post


Link to post
Share on other sites
To Valere:
Thanks, and yes, high resolution timer is fast. However it does not work well on a multi-core CPU. This is something I need to improve.

Share this post


Link to post
Share on other sites
You should add the ability to output to a real time debug render, like iprof. Writing to a text file(xml or otherwise) is pretty useless imo. It's hugely more useful to see real time timer stats on screen so performance issues can be examined in real time. I don't mean add rendering code, something much simpler, like a lightweight render interface the application user can implement that will let the profiler optionally draw to the screen.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!