473,378 Members | 1,469 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Timing Code line by line

Hi all, i was wondering if its possible to 'time' every single line of code
then output the the results as in a profiler i.e.

Time Line of code
22ms If... etc;
32ms i++;
..... ....

i know you can time a loop or whatever through the Start -> do loop -> stop
proceedure i.e

Start timer
Do....
.....
....
Stop timer

etc

But im looking for a method to time each and every line of code in a
program, either at compile time or at run time.

hope someone has an idea on how to do this, i am perticularly looking for a
code example so i could get the general gist of doing it.

I dont mind if the results are in C# or VB.net

thanks all for your help

Nick
Nov 16 '05 #1
4 2401
The CLR has all sorts of profiling API's to allow for just this. However,
you'd be far better off looking for a profiling tool. There is one called
NProf which is open source, and I use DevPartners free Community Edition
Profiler.

"Nicholas Mayne" <Nicholas Ma***@discussions.microsoft.com> wrote in message
news:E1**********************************@microsof t.com...
Hi all, i was wondering if its possible to 'time' every single line of
code
then output the the results as in a profiler i.e.

Time Line of code
22ms If... etc;
32ms i++;
.... ....

i know you can time a loop or whatever through the Start -> do loop ->
stop
proceedure i.e

Start timer
Do....
....
...
Stop timer

etc

But im looking for a method to time each and every line of code in a
program, either at compile time or at run time.

hope someone has an idea on how to do this, i am perticularly looking for
a
code example so i could get the general gist of doing it.

I dont mind if the results are in C# or VB.net

thanks all for your help

Nick

Nov 16 '05 #2
Can you suggest any APIs please?... i jsut downloaded NProf so gunna start
scrolling through that, thanks for the suggestion. but if u could suggest
some APIs that would be great.

Thanks alot, Nick

"Sean Hederman" wrote:
The CLR has all sorts of profiling API's to allow for just this. However,
you'd be far better off looking for a profiling tool. There is one called
NProf which is open source, and I use DevPartners free Community Edition
Profiler.

"Nicholas Mayne" <Nicholas Ma***@discussions.microsoft.com> wrote in message
news:E1**********************************@microsof t.com...
Hi all, i was wondering if its possible to 'time' every single line of
code
then output the the results as in a profiler i.e.

Time Line of code
22ms If... etc;
32ms i++;
.... ....

i know you can time a loop or whatever through the Start -> do loop ->
stop
proceedure i.e

Start timer
Do....
....
...
Stop timer

etc

But im looking for a method to time each and every line of code in a
program, either at compile time or at run time.

hope someone has an idea on how to do this, i am perticularly looking for
a
code example so i could get the general gist of doing it.

I dont mind if the results are in C# or VB.net

thanks all for your help

Nick


Nov 16 '05 #3
The APIs are quite nasty. they're COM interfaces, and you'll have to use
unmanaged code to access them. On my computer the documentation is located
at:
C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Tool Developers
Guide\docs\Profiling.doc. There's a samples at:
C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Tool Developers
Guide\Samples\profiler

"Nicholas Mayne" <Ni***********@discussions.microsoft.com> wrote in message
news:79**********************************@microsof t.com...
Can you suggest any APIs please?... i jsut downloaded NProf so gunna start
scrolling through that, thanks for the suggestion. but if u could suggest
some APIs that would be great.

Thanks alot, Nick

"Sean Hederman" wrote:
The CLR has all sorts of profiling API's to allow for just this. However,
you'd be far better off looking for a profiling tool. There is one called
NProf which is open source, and I use DevPartners free Community Edition
Profiler.

"Nicholas Mayne" <Nicholas Ma***@discussions.microsoft.com> wrote in
message
news:E1**********************************@microsof t.com...
> Hi all, i was wondering if its possible to 'time' every single line of
> code
> then output the the results as in a profiler i.e.
>
> Time Line of code
> 22ms If... etc;
> 32ms i++;
> .... ....
>
> i know you can time a loop or whatever through the Start -> do loop ->
> stop
> proceedure i.e
>
> Start timer
> Do....
> ....
> ...
> Stop timer
>
> etc
>
> But im looking for a method to time each and every line of code in a
> program, either at compile time or at run time.
>
> hope someone has an idea on how to do this, i am perticularly looking
> for
> a
> code example so i could get the general gist of doing it.
>
> I dont mind if the results are in C# or VB.net
>
> thanks all for your help
>
> Nick


Nov 16 '05 #4
Dam, im not a strong C++.net programmer, is there none that are specific to
the c# language, or will i have to convert them over?

thanks nick

"Sean Hederman" wrote:
The APIs are quite nasty. they're COM interfaces, and you'll have to use
unmanaged code to access them. On my computer the documentation is located
at:
C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Tool Developers
Guide\docs\Profiling.doc. There's a samples at:
C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Tool Developers
Guide\Samples\profiler

"Nicholas Mayne" <Ni***********@discussions.microsoft.com> wrote in message
news:79**********************************@microsof t.com...
Can you suggest any APIs please?... i jsut downloaded NProf so gunna start
scrolling through that, thanks for the suggestion. but if u could suggest
some APIs that would be great.

Thanks alot, Nick

"Sean Hederman" wrote:
The CLR has all sorts of profiling API's to allow for just this. However,
you'd be far better off looking for a profiling tool. There is one called
NProf which is open source, and I use DevPartners free Community Edition
Profiler.

"Nicholas Mayne" <Nicholas Ma***@discussions.microsoft.com> wrote in
message
news:E1**********************************@microsof t.com...
> Hi all, i was wondering if its possible to 'time' every single line of
> code
> then output the the results as in a profiler i.e.
>
> Time Line of code
> 22ms If... etc;
> 32ms i++;
> .... ....
>
> i know you can time a loop or whatever through the Start -> do loop ->
> stop
> proceedure i.e
>
> Start timer
> Do....
> ....
> ...
> Stop timer
>
> etc
>
> But im looking for a method to time each and every line of code in a
> program, either at compile time or at run time.
>
> hope someone has an idea on how to do this, i am perticularly looking
> for
> a
> code example so i could get the general gist of doing it.
>
> I dont mind if the results are in C# or VB.net
>
> thanks all for your help
>
> Nick


Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Shabam | last post by:
Ok I'm trying to run a php script written by someone else, not me, and it's getting stuck in a particular step. Actually it isn't getting stuck per se, but the browser is, because it's taking...
1
by: Andreas Lobinger | last post by:
Aloha, hotshot.Profile has flags for recording timing per line and line events. Even if i had both set to 1 i still get only the standard data (time per call). Is there any document available...
2
by: Steven D'Aprano | last post by:
The timeit module is ideal for measuring small code snippets; I want to measure large function objects. Because the timeit module takes the code snippet argument as a string, it is quite handy...
15
by: Jay | last post by:
I have a multi threaded VB.NET application (4 threads) that I use to send text messages to many, many employees via system.timer at a 5 second interval. Basically, I look in a SQL table (queue) to...
2
by: julie.siebel | last post by:
Google apparently ate my original post to this (grr) so this'll be a bit more vague than the initial post, but...*sigh*. Javascript is not my forte, and I apologize for the acky-ness of the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.