QProfile toolkit - a class to profile your code | CodeGuru

QProfile toolkit – a class to profile your code

Environment: VC6.0 Main features of QProfile toolkit: 1. Application runs at the same speed as usual 2. You can get per-thread information 3. Profiling is independent from development enviroment 4. Report can be directed/appended to file or/and consol or/and VC++ debug window 5. Results can be sorted by total time, pure time, hit number or […]

Written By
CodeGuru Staff
CodeGuru Staff
Feb 21, 1999
1 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

Environment: VC6.0

Main features of QProfile toolkit:

1. Application runs at the same speed as usual
2. You can get per-thread information
3. Profiling is independent from development enviroment
4. Report can be directed/appended to file or/and consol
or/and VC++ debug window
5. Results can be sorted by total time, pure time,
hit number or time per hit

How to use QProfile class

1. Download the QProfile source code.
2. Include QProfile.cpp file to your project
3. Add line "include "QProfile.h"" to the common header or to specific C++ file
4. Add QProfile macro to the target functions
5. Compile and run
6. Look at  "QProfile.txt" or/and consol or/and VC++ debug window for results.

QProfile macros

All you have to do is to add a line to a function you want to profile.

YourClass::YourFunction(){
    QPROFILE_FUN("YourClass::YourFunction");
    …
    if (…) return false;
    …
    return true;
}

If you want to get results for this function  per thread:

YourClass::YourFunction(){
    QPROFILE_MT_FUN1("YourFunction,thread:%lx", GetCurrentThread());
    …
    if (…) return false;
    …
    return true;
}

After program exits you’ll get profile report like this
(points are used to align HTML text)

—————– Profiling .results —————–
Date: 07.02.1999, Time: 13:08.32
——————————————————
|-Child|Total | .Hits .|Time/call | . MIN . | . MAX . | Function . .
——————————————————
| . . .|100.00| . . . 1| .7032.837| . .0.000| . .0.000|Total time
| 57.43| 83.59| . . . 1| .5878.893| 5878.893| 5878.893|Sorting int array[100], thread:ffc481ff
| .0.30| 26.16| . .1000| . . 1.840| . .0.299| .150.408| .Sort_Int_Array, thread:ffc481ff(31.3%)
| 47.03| 77.31| . . . 1| .5437.054| 5437.054| 5437.054|Sorting int array[1000],thread: ffc48bbb
| .0.14| 30.28| . . 386| . . 5.517| . .4.243| . 25.024| .Sort_Int_Array, thread:ffc48bbb(39.2%)
| . . .| 55.99| . .1386| . . 2.841| . .0.278| .150.383|::qsort – all threads

——————————————————

You can find more detail at http://members.tripod.com/~DanKozub

Download source – 7.5KB

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.