Have you ever wanted to do timing tests on your LotusScript code but found that NotesDateTime variables don't measure a small enough time interval? With NotesDateTime, you can only time to 100ths of a second. It's possible to get more accuracy by making system-dependant calls, but that ties the timing code to a particular OS. That could be a problem for you if your server is Unix, Linux, or AIX-based and your clients are all Wintel systems. Wouldn't it be nice if there was a system-independent way to time your code more accurately? Well, now there is.
There's a LotusScript function called GetThreadInfo that can get a variety of useful information for you. There's a trick to using this function, though. The key insight that made this code work is that I used numbers rather than the literal definitions (LSI_THREAD_TICKS etc.) listed in the help file. For some reason, if you use the literals, the code compiles, but fails when it runs (true for both R5 and ND6).
Here's the code: ********************************************************** stc = Getthreadinfo(6) ' get the starting tick count <the code you want to time> ftc = Getthreadinfo(6) 'get the final tick count tps = Getthreadinfo(7) 'get the ticks per second t = (ftc - stc) / tps 'final tick count minus starting tick count divided by ticks per second yields duration. **********************************************************
Here's a list of the OSes and Notes versions that this
Requires Free Membership to View
Register today to access targeted resources from our editorial writers and independent industry experts focused on Lotus Domino, Notes, Workplace and other related technologies.
- Win2000 Domino 6.0 (ticks per second 1000)
- Win2000 Domino 5.0.9a (ticks per second 1000)
- AIX 4.3.3 ML 9 with Domino 5.0.11 (ticks per second = 1,000,000)
- Solaris 8 with Domino 5.0.11 (ticks per second = 1,000,000)
- SuSE Linux 8.1 with Domino 6.0.1 (ticks per second 1000)
- Server.Version.Notes = Release 6.0.1; Server.Version.OS = SunOS 5.8 Generic_108528-18 (ticks per second 1000)
stc = Getthreadinfo(6) 'get the starting tick count <the code you want to time> ftc = Getthreadinfo(6) 'get the final tick count tps = Getthreadinfo(7) 'get the ticks per second t = (ftc - stc) / tps 'final tick count minus starting tick count divided by ticks per second yields time.
This was first published in April 2003