Posts tagged Tips

How to skip a class or library from being profiled?

0

Icon Description
We used to run profiler for performance tuning. By using profiler, you can check – function timing, function coverage etc. By default profiler profiles the entire modules. But how can we skip a particular user library or class from profiling?

Icon How Can I Do It?
There is a setting file named profile.ini, where profiler keep its settings.
For skipping a user library just add a line like this.
exclude:myuser.lib

Assume you have a class named CHighPerfomance and want it to be skipped from profiling, then add the following line.
exclude:CHighPerfomance.obj

Icon - Where is it?
The profiler setting file is located at
<VisualStudioDir>\VC98\bin\PROFILER.INI

Log path informations to eventlog, Even better.

1

Icon Description
In most of our projects, when some error occurs, it’s being logged to the evenlog with line number and filename. Its done by using __FILE__ and __LINE__ macro.

But the file macros expands to the fullpath. for e.g. If i am building the delivery in my personal folder – “C:\Jijo\Build\MyProduct”, the __FILE__ macro will include this full path and finally in eventlog will contain funny paths which the end-user might see. You can see some 3ed party eventlogs in event viewer which contains authors name in path. :)

Icon How Can I Do It?
You can use #line directive to modify __LINE__ and __FILENAME__. The syntax is as follows,
#line lineno “FileName”

Please see an example below.

#line __LINE__ "MyProduct\Sources\JobDll\Job.cpp"

Icon Note
While experimenting I’ve found that – Its safe to use #line after all #includes. If its used at the top of file, It can be reinitialized by the include files. At first it was not working for me. Latter works. Anyway take care.

Go to Top