Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Stopping a Timer / Running a timer simultaneously on Excel | Excel Discussion (Misc queries) | |||
Counting cells with intervals | Excel Worksheet Functions | |||
Counting in ranged intervals | Excel Programming | |||
I need smaller code. | Excel Programming | |||
Time smaller than a second | Excel Programming |