Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Timer which counting smaller than 1 second intervals


Hi,

I'm looking for a way to use a counter which can count smalle
intervals than the standard 1 second. I need something like 0.
seconds.

Currently I'm using this as my pause module. Problem is, it uses 100
of my CPU, which is (naturally) unacceptable.

Public Sub Pause(Pausetime As Single)

Dim Starttime As Single

Starttime = Timer

Do Until Timer Starttime + Pausetime
Loop

End Sub

In this sub "Pausetime" is used to determine the pause interval. In m
case 0.1 seconds (pausetime = 0.1)

Any suggestions are welcome.

Regards,

Berend Botj

--
Berend Botj
-----------------------------------------------------------------------
Berend Botje's Profile: http://www.excelforum.com/member.php...fo&userid=1015
View this thread: http://www.excelforum.com/showthread.php?threadid=31868

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Timer which counting smaller than 1 second intervals

Hi Berend,

Visit Karl E. Peterson's site and look at his CStopWatch download:

http://www.mvps.org/vb/index2.html?tips/benchmarks.htm

---
Regards,
Norman



"Berend Botje" wrote in message
...

Hi,

I'm looking for a way to use a counter which can count smaller
intervals than the standard 1 second. I need something like 0.1
seconds.

Currently I'm using this as my pause module. Problem is, it uses 100%
of my CPU, which is (naturally) unacceptable.

Public Sub Pause(Pausetime As Single)

Dim Starttime As Single

Starttime = Timer

Do Until Timer Starttime + Pausetime
Loop

End Sub

In this sub "Pausetime" is used to determine the pause interval. In my
case 0.1 seconds (pausetime = 0.1)

Any suggestions are welcome.

Regards,

Berend Botje


--
Berend Botje
------------------------------------------------------------------------
Berend Botje's Profile:
http://www.excelforum.com/member.php...o&userid=10154
View this thread: http://www.excelforum.com/showthread...hreadid=318682



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default Timer which counting smaller than 1 second intervals

I have an example on my website: Subsecond Delay

--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Berend Botje" wrote in message
...

Hi,

I'm looking for a way to use a counter which can count smaller
intervals than the standard 1 second. I need something like 0.1
seconds.

Currently I'm using this as my pause module. Problem is, it uses 100%
of my CPU, which is (naturally) unacceptable.

Public Sub Pause(Pausetime As Single)

Dim Starttime As Single

Starttime = Timer

Do Until Timer Starttime + Pausetime
Loop

End Sub

In this sub "Pausetime" is used to determine the pause interval. In my
case 0.1 seconds (pausetime = 0.1)

Any suggestions are welcome.

Regards,

Berend Botje


--
Berend Botje
------------------------------------------------------------------------
Berend Botje's Profile:
http://www.excelforum.com/member.php...o&userid=10154
View this thread: http://www.excelforum.com/showthread...hreadid=318682



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Timer which counting smaller than 1 second intervals

Rob,

i see a subsecond wait (a plain api sleep)
but i dont see a subsecond delay

--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Rob van Gelder wrote :

I have an example on my website: Subsecond Delay

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Timer which counting smaller than 1 second intervals


I did find some code with a timer in
SpeedTestRangeRead.

I disagree with your test method...

I've changed the 3rd test...

With .Range("A1")
For i = 0 To 10000 - 1
lngTemp = .Offset(i, 0).Value
Next
End With


Test 1: 85
Test 2: 178
Test 3: 74 (original test 3: 151)

Offset wins handsdown if used properly..
your original lngTemp = rng.Offset(i, 0).Value
has to reevaluate the range object in every iteration.

<VBG



--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Rob van Gelder wrote :

I have an example on my website: Subsecond Delay



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default Timer which counting smaller than 1 second intervals

Sorry - you're right. I'm starting to forget the labels.

--
Rob van Gelder - http://www.vangelder.co.nz/excel


"keepITcool" wrote in message
ft.com...
Rob,

i see a subsecond wait (a plain api sleep)
but i dont see a subsecond delay

--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Rob van Gelder wrote :

I have an example on my website: Subsecond Delay



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default Timer which counting smaller than 1 second intervals

Thanks for the comment and feedback.
Perhaps you're right. I hardly understand the inner workings of how VB/Excel
evaluates ranges.

The code purpose was more to demonstrate speed test possibilities than prove
or disprove certain methods of reading - even though that is exactly what
it's doing.

I had planned to develop it into a rough profiler application but soon
realised what was involved - especially handling exit do, exit sub, exit,
exit function, etc...


Back to the 3rd test...
I get no significant difference between the two tests.


Declare Function timeGetTime Lib "winmm.dll" () As Long

Dim lngStart As Long

Sub Start()
lngStart = timeGetTime()
End Sub

Function Finish()
Finish = timeGetTime() - lngStart
End Function

Sub test()
Const cQuant = 65536
Dim i As Long, lngTemp As Long, rng As Range

With ActiveSheet
'set up test data
For i = 1 To cQuant: .Cells(i, 1).Value = i: Next

Start
Set rng = .Range("A1")
For i = 0 To cQuant - 1
lngTemp = rng.Offset(i, 0).Value
Next
Debug.Print "Test 3: " & Finish

Start
With .Range("A1")
For i = 0 To cQuant - 1
lngTemp = .Offset(i, 0).Value
Next
End With
Debug.Print "Test 4: " & Finish
End With
End Sub


Test 3: 500
Test 4: 485


Cheers


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"keepITcool" wrote in message
ft.com...

I did find some code with a timer in
SpeedTestRangeRead.

I disagree with your test method...

I've changed the 3rd test...

With .Range("A1")
For i = 0 To 10000 - 1
lngTemp = .Offset(i, 0).Value
Next
End With


Test 1: 85
Test 2: 178
Test 3: 74 (original test 3: 151)

Offset wins handsdown if used properly..
your original lngTemp = rng.Offset(i, 0).Value
has to reevaluate the range object in every iteration.

<VBG



--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Rob van Gelder wrote :

I have an example on my website: Subsecond Delay



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Stopping a Timer / Running a timer simultaneously on Excel Paul23 Excel Discussion (Misc queries) 1 March 10th 06 12:08 PM
Counting cells with intervals Paulo Araújo Excel Worksheet Functions 4 June 24th 05 01:46 AM
Counting in ranged intervals No Name Excel Programming 2 April 12th 04 07:39 PM
I need smaller code. Jennifer Glass Excel Programming 3 January 15th 04 08:36 PM
Time smaller than a second PK[_6_] Excel Programming 3 October 11th 03 05:06 AM


All times are GMT +1. The time now is 07:15 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"