tor 2011-04-14 klockan 03:23 -0700 skrev Jack:
> Hi all,
> The Timer() function in basic returns the (system?) time in seconds.  Is
> there another function that has a better resolution?  I want to time how
> long it takes to execute a certain function in LibreOffice Basic and I would
> like to have smaller increments than 1 second.  I'm talking about something
> like this:
> 
>  -= Start of code =-
> 
> dim startTime as single
> dim stopTime as single
> 
> startTime = Timer()
> someTimeConsumingSub()
> stopTime = Timer()
> MsgBox "It took " & stopTime - startTime & " second(s) to execute the code"
> 
>  -= End of code =-
> 
> Typically, this would result in something like:
> It took 2 second(s) to execute the code
> 
> I would like something like:
> It took 1.957 second(s) to execute the code
> 
> The reason I'm using the Timer() function is because I know in VBA it works
> like the second example.  Does anyone know of a function or workaround that
> I can use?
> 
> Regards
> Jack


GetSystemTicks()

Here's an example from the LibreOffice Help:
Sub ExampleWait
        Dim lTick As Double
        lTick = GetSystemTicks()
        wait 2000
        lTick = (GetSystemTicks() - lTick)
        MsgBox "" & lTick & " Ticks" ,0,"Pausen varade i"
End Sub

Seems like one tick is one millisecond, at least on my system. The rest
is simple math.

-- 
Best regards

Johnny Rosenberg


-- 
Unsubscribe instructions: E-mail to [email protected]
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/www/users/
All messages sent to this list will be publicly archived and cannot be deleted

Reply via email to