Click here to Skip to main content
6,306,412 members and growing! (17,595 online)
Email Password   helpLost your password?
Languages » VB.NET » Utilities     Intermediate

A simple .NET Profiler

By Peter Schlang

A DLL helping to measure process time in your applications.
VB, .NET, Win2K, WinXP, Visual Studio, Dev
Posted:3 Feb 2005
Updated:10 Apr 2006
Views:41,269
Bookmarked:26 times
Announcements
Loading...
 
Search    
Advanced Search
printPrint   Broken Article?Report       add Share
  Discuss Discuss   Recommend Article Email
12 votes for this article.
Popularity: 3.33 Rating: 3.08 out of 5
7 votes, 50.0%
1

2

3
2 votes, 14.3%
4
5 votes, 35.7%
5

Introduction

When optimizing my programs, I usually had the question: 'Which of my functions needs most of the time?'. Searching the web, I did not find any remarkable solution for my issue. So I had to resolve it by myself, I wrote a small DLL to be called from any of my .NET programs.

It measures the time needed inside the actual function and writes the result to a disk file, averaging (maximizing, minimizing etc.) the time used to process the function.

The DLL is rather simple, the source code consists of 160 lines (including comment lines).

Using the code

To use pscProfilEx, you must:

  • Reference 'pscProfilEx'.
  • Define 'Public <myProfile> As New pscProfilEx.CProfilEx'.
  • At the start of your application, insert <myProfile>.profileOpen("<logFileName>").
  • At the start of the function to be profiled, insert <myProfile>.profileStart("<function name>").
  • At the end of this function, insert <myProfile>.profileEnd().
  • When leaving your application, insert <myProfile>.profileClose().

Maybe you want to avoid an 'endless' profiling inside a program running in a loop. Then, e.g., following a timer, counter or other criterion, you may insert:

<myProfile>.profileClose()
    <myProfile>.profileOpen(<newLogFileName>)

wherever you want (and if applicable). This will close the current log file and create a new one.

History

2005-Jan-31 - First release - 2.0.0.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Peter Schlang


Member
Peter Schlang, working with computers since 1974
Developing mainly for newspapers since 1981, first as employee of ATEX
Freelancer since 1987
Preferred language is VB: Starting with VB 1.0 and VBDOS, up to VB.NET

Occupation: Web Developer
Location: Germany Germany

Other popular VB.NET articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 10 of 10 (Total in Forum: 10) (Refresh)FirstPrevNext
Generalplenty of existing products PinmemberKuno Meyer6:02 22 Aug '08  
GeneralVery nice Pinmemberdwaterfield10:26 21 Apr '06  
GeneralDoes not work ... Pinmemberneil young12:08 19 Apr '06  
GeneralRe: Does not work ... PinmemberPeter Schlang7:52 20 Apr '06  
GeneralTwo articles PinmemberVladimir Afanasyev0:32 4 Feb '05  
GeneralRe: Two articles Pinmemberpsc_exec0:41 4 Feb '05  
GeneralRe: Two articles PinmemberVladimir Afanasyev1:01 4 Feb '05  
GeneralReadable data PinmemberKlapouchy23:29 3 Feb '05  
GeneralRe: Readable data Pinmemberpsc_exec23:56 3 Feb '05  
GeneralRe: Readable data PinmemberKlapouchy0:18 4 Feb '05  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 10 Apr 2006
Editor: Smitha Vijayan
Copyright 2005 by Peter Schlang
Everything else Copyright © CodeProject, 1999-2009
Web11 | Advertise on the Code Project