I need to measure how long a code run, in seconds
Author Message
I need to measure how long a code run, in seconds

I ned to know how long some code need to execute... can you give me some hints on how to measure this in seconds..?

Thanks
Crirus

Sun, 14 Aug 2005 21:48:27 GMT
I need to measure how long a code run, in seconds

Quote:
> I ned to know how long some code need to execute... can you give
> me some hints on how to measure  this in seconds..?

dim s as integer
s = environment.tickcount
'code
s = environment.tickcount - s
msgbox (s/1000)

Armin

Sun, 14 Aug 2005 22:05:53 GMT
I need to measure how long a code run, in seconds
environment.tickcount return nanoseconds?
How to compute in microseconds(us)?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Mon, 15 Aug 2005 14:52:45 GMT
I need to measure how long a code run, in seconds
Hello Cris,

Quote:
> environment.tickcount return nanoseconds?
> How to compute in microseconds(us)?

No, it returns milliseconds.

microsec = millisec * 1000

Remember that TickCount has millisecond resolution and that it doesn't make
sense to convert the value to mucroseconds (no higher precision).

Regards,
Herfried K. Wagner

Mon, 15 Aug 2005 21:43:46 GMT
I need to measure how long a code run, in seconds

Quote:
> environment.tickcount return nanoseconds?

Where did you read that? :-)

Quote:
> How to compute in microseconds(us)?

Armin

Tue, 16 Aug 2005 00:27:20 GMT
I need to measure how long a code run, in seconds

Quote:

>> environment.tickcount return nanoseconds?

> Where did you read that? :-)

>> How to compute in microseconds(us)?

> Armin

You can use the Ticks property to get 100 nanosecond intervals.  For
example:

Dim s As Long

s = DateTime.Now.Ticks
'code
s = DateTime.Now.Ticks - s
MsgBox("Elapsed time: " & (s/10) & " microseconds)

--
If you don't like lunchmeat, please remove it from my e-mail address to
send me an e-mail

Tue, 16 Aug 2005 01:16:20 GMT
I need to measure how long a code run, in seconds

Quote:

> >> environment.tickcount return nanoseconds?

> > Where did you read that? :-)

> >> How to compute in microseconds(us)?

> > Armin

> You

why me? ;)

Quote:
>  can use the Ticks property to get 100 nanosecond intervals.
> For  example:

> Dim s As Long

> s = DateTime.Now.Ticks
> 'code
> s = DateTime.Now.Ticks - s
> MsgBox("Elapsed time: " & (s/10) & " microseconds)

The unit of ticks is 100 nanoseconds, that's right, but the resultion might
differ. Here it's only 1/100s.

Dim j, l, s As Long
Dim i As Integer
s = Date.Now.Ticks
Do
j = Date.Now.Ticks
If l <> j Then
i += 1
l = j
End If
Loop Until j - s >= 10000000    'loop 1 second
MsgBox(i)

Msgbox shows 100 or 101, i.e. 100 differnt values per second.

(QueryPerformanceCounter/QueryPerformanceFrequency)

Armin

Tue, 16 Aug 2005 03:20:04 GMT
I need to measure how long a code run, in seconds
I tryed to use API for a bette resolution but I got a runtime error with
that LARGE_Integer

Have a running code on this issue, please?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Tue, 16 Aug 2005 14:42:05 GMT
I need to measure how long a code run, in seconds
DevParterner Code Profiler from Compuware is great at measuring code
execution and finding performance problems. see
www.compuware.com/products/numega/dps/profiler. there was an card in the
I have done so, it's really great.

--
Daniel Okely
dbokely at yahoo.com.au

Quote:

> > >> environment.tickcount return nanoseconds?

> > > Where did you read that? :-)

> > >> How to compute in microseconds(us)?

> > > see Herfried's answer

> > > Armin

> > You

> why me? ;)

> >  can use the Ticks property to get 100 nanosecond intervals.
> > For  example:

> > Dim s As Long

> > s = DateTime.Now.Ticks
> > 'code
> > s = DateTime.Now.Ticks - s
> > MsgBox("Elapsed time: " & (s/10) & " microseconds)

> The unit of ticks is 100 nanoseconds, that's right, but the resultion
might
> differ. Here it's only 1/100s.

>       Dim j, l, s As Long
>       Dim i As Integer
>       s = Date.Now.Ticks
>       Do
>          j = Date.Now.Ticks
>          If l <> j Then
>             i += 1
>             l = j
>          End If
>       Loop Until j - s >= 10000000    'loop 1 second
>       MsgBox(i)

> Msgbox shows 100 or 101, i.e. 100 differnt values per second.

> (QueryPerformanceCounter/QueryPerformanceFrequency)

> Armin

Tue, 16 Aug 2005 18:08:06 GMT
I need to measure how long a code run, in seconds
I dont need that kind of banchmarks
I need to measure the time for internal purpose.. read posts above

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Tue, 16 Aug 2005 18:42:31 GMT
I need to measure how long a code run, in seconds

Quote:
> I tryed to use API for a bette resolution but I got a runtime
> error with that LARGE_Integer

> Have a running code on this issue, please?

Public Declare Auto Function QueryPerformanceCounter _
Lib "kernel32.dll" (ByRef Counter As Long) As Integer
Public Declare Auto Function QueryPerformanceFrequency _
Lib "kernel32.dll" (ByRef counter As Long) As Integer

This is my class for encapsulation:

Public NotInheritable Class HPCounter

Private Shared m_Frequency As Long

Shared Sub New()
Win32.QueryPerformanceFrequency(m_Frequency)
End Sub

Private Sub New()
End Sub

Public Shared ReadOnly Property Counter() As Long
Get
Dim Result As Long
Win32.QueryPerformanceCounter(Result)
Return Result
End Get
End Property

Public Shared ReadOnly Property Frequency() As Long
Get
Return m_Frequency
End Get
End Property

Public Shared ReadOnly Property Seconds() As Double
Get
Return Counter / m_Frequency
End Get
End Property

End Class

Put the two API declarations into a class called Win32.

Armin

Tue, 16 Aug 2005 19:28:47 GMT

 Page 1 of 1 [ 11 post ]

Relevant Pages