Timer example + Array

Started by Frank Brübach, December 23, 2023, 09:25:24 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Frank Brübach

Hi all how to Set a Timer function in oxygen?  Found this example Last days with redim and Arrays and IT must be fixed  AS poosible



Update See next post

Thanks  regards Frank
  •  

Frank Brübach

#1
Hi all Made this little redim Array example with Timer feature if its running
Didnt know that ubound command exists already  thats new for me
Never used redim Array before

A little Thing is Missing cause the Timer result doesn't appears correctly
'timer example simple with array redim

Type SYSTEMTIME
     word wYear
     word wMonth
     word wDayOfWeek
     word wDay   
     word wHour   
     word wMinute
     word wSecond
     word wMilliseconds
End Type

Declare GetSystemTime LIB "KERNEL32.DLL" ( SYSTEMTIME *lpSystemTime )
Declare GetLocalTime  Lib "kernel32.dll" ( ByRef lpSystemTime As SYSTEMTIME )

SYSTEMTIME   myTime

'---Variables declaration
dim MaxCount  as long
maxCount = 1000000
dim integer MyArray(1000000)
dim integer Count


'---Start time
dim T0 as double = myTime 'TIMER

'---Dimension the array
redim int MyArray(1000000)

'---Fill the array
' problem -------------------------- //
for Count = 1 to MaxCount
  'MyArray(Count) = Count*Count '^2
  'redim int MyArray(ubound(1,1000000)) = Count*Count
   redim int MyArray(ubound(count,MaxCount)) = Count*Count
next

'---End time
dim T1        as double = myTime 'TIMER

'MsgBox(0, "Total time to fill an EXT array of " & MaxCount & " elements: " & Format$(T1 - T0, "#0.0000") & " secs")

print "total time to fill an EXT array of " + MaxCount + " elements: " + str(T1 - T0, "#0.0000") + " secs"

'end

' this example works good --
'redim int x[10,20,30]
'redim integer x(3)
'print ubound(x)
'print ubound(x,1)
'print ubound(x,2)
'print ubound(x,3)
' this example works good --
  •  

Charles Pegge

format comes from inc\parseutil.inc

The time functions come from inc\TimeUtil.inc

To get a reasonable measurement I bumped the iterations up to 10 million :)

'timer example simple with array redim

uses sysutil

/*
Type SYSTEMTIME
     word wYear
     word wMonth
     word wDayOfWeek
     word wDay   
     word wHour   
     word wMinute
     word wSecond
     word wMilliseconds
End Type

Declare GetSystemTime LIB "KERNEL32.DLL" ( SYSTEMTIME *lpSystemTime )
Declare GetLocalTime  Lib "kernel32.dll" ( ByRef lpSystemTime As SYSTEMTIME )
*/


'---Variables declaration
dim MaxCount  as long
maxCount = 1e7 '10 million
SYSTEMTIME   myTime0
SYSTEMTIME   myTime1

'---Start time
GetSystemTime myTime0

'---Dimension the array
redim int MyArray(maxcount)

dim count as long
'---Fill the array
for Count = lbound(MyArray) to ubound(MyArray)
  MyArray(Count) = Count*Count '^2
next
'---End time
GetSystemTime myTime1


print "total time to fill an EXT array of " + MaxCount + " elements: " + format(TimeLapseMs(myTime0,myTime1), "###") + " msecs"