Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index

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()
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?



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
Posting guidelines + more:
List archive:
All messages sent to this list will be publicly archived and cannot be deleted


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.