Home > Domino Tips > Developer > LotusScript > Accurate LotusScript timing technique
Domino Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

LOTUSSCRIPT

Accurate LotusScript timing technique


Bruce Perry
04.21.2003
Rating: -4.52- (out of 5) Hall of fame tip of the month winner


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


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).



Code

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 tip has been tested with. I'd like to thank Andrew Pollack of Northern Collaborative Technologies and Penumbra Group for their assistance with this testing. Note that AIX and Solaris systems will permit much finer measurements. One thousand ticks per second has been enough for all the testing I've done so far.

  • 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.
  

Rate this Tip
To rate tips, you must be a member of SearchDomino.com.
Register now to start rating these tips. Log in if you are already a member.




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


RELATED CONTENT
LotusScript
Create a non-specified date picker with LotusScript code
LotusScript accesses clipboard to view copied Notes documents
LotusScript action button manages Lotus Notes mail files
LotusScript sorts a Lotus Notes document collection
Display Lotus Notes user group membership details in a tree view
Alternate version of @Command forwards subform via LotusScript
Process large arrays in Notes forms without undue coding or testing
How to use LotusScript to modify a Lotus Notes view selection
Display a custom message box using a LotusScript-generated button
Debug Lotus Notes documents using extracted data

LotusScript
Customize the principal field of outgoing email messages
Create a non-specified date picker with LotusScript code
Resolve Notes 8 migration error: 'Database has not been opened yet'
LotusScript accesses clipboard to view copied Notes documents
LotusScript action button manages Lotus Notes mail files
LotusScript sorts a Lotus Notes document collection
Display Lotus Notes user group membership details in a tree view
Alternate version of @Command forwards subform via LotusScript
Process large arrays in Notes forms without undue coding or testing
How to use LotusScript to modify a Lotus Notes view selection

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



Domino & Lotus Notes Security Solutions: Authentication, Antispam, Encryption and Antivirus
HomeTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersDomino IT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 1999 - 2008, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts