[Clip] Benchmarking NoteTab Functions
- View SourceHi All,
A few days ago, on occasion of a commentary regarding the use of ^!IfTrue
and ^!If, I posted a Clip to test the performance of those instructions.
Those who read it will remember they were actually two Clips, one for each
At the time, I didn't consider going through the trouble of displaying the
elapsed time, and was content with just showing the Starting and Ending
time. Displaying the time isn't as simple as subtracting both time values,
because they are in Hours, Minutes and Seconds, and there is no function to
do that in NoteTab. Though I had an old routine I wrote some time ago, that
routine was in Visual Basic and required to be converted to NoteTab, an
always difficult operation. Worst of all, I had misplaced the function and
wasn't able to find it.
Since there was a discussion going on these days on the List about
converting Degrees to Decimal, my interest was revived and decided, this
time with more luck, to look for the lost routine. Should I have been
wiser, I wouldn't have! It took me quite a few hours, plus a mild headache,
to have it adapted and working on NoteTab. If you've programmed for a
while, you must be familiar with those things that look sooo easy you can
have them running in a few minutes, but turn out taking far more time and
effort than initially planned.
Well, the routine is done, it works, and you and I can now use it in other
Clips. It hopefully will help other NoteTabers that may need it. It can
also be "easily" converted to other environments.
Furthermore, it allows me now, to add "that little improvement that means
everything" to the benchmark Clip I mentioned above, which is the reason of
The Clip will allow you to test one or more NoteTab instructions at a time
to measure their performance.
It might be of interest to other NoteTab programmers in that it shows how
you can implement subroutines inside the same Clip, without the need to use
external support Clips. The DMS and InvDMS external Clips I posted
elsewhere appear here integrated within the main Clip (under the "subDMS"
and "subInvDMS" labels), and the code demonstrates the use of a simple, but
effective, technique to access those subroutines. (NoteTab does not support
user functions nor subroutines at this time, but it allows us to do some
tricks impossible on other environments!)
;======== Start ========
; RS - 08/26/99 6:44:12 PM, based on:
; RS - 08/19/99 7:07:51 PM
; Edited with ClipWriter 1.0
;Change the Seed value to increase
;or decrease the number of loop
;iterations and time for the test.
;Notice that the total number of
;iterations is always equal (Seed + 1).
;So, if you want to have 1000 iterations
;exactly, Seed should be 999.
;This example is meant just to test
;the ^!IfTrue statement. To test other
;instructions, just place them before
;the ^!IfTrue line after the ":loop" label.
^!IfTrue ^%Seed% Msg
;Calculate elapsed time:
^!Set t2= ^%DMS%
;@ Bookmark 1
^!Set t1= ^%DMS%
;calculate & convert to HH:MM:SS:
^!Set InvDMS=^$Calc(^%t2% - ^%t1%;4)$
^!Info BENCHMARK RESULTS ^p^p for ^%iters% loop iterations ^p^p Start =
^%StartTime% ^p End = ^%EndTime% ^p^p Elapsed Time = ^%InvDMS%
; DMS function
;Converts value in DMS (Degrees-Minutes-Seconds)
;to Decimal value.
^!If ^%i% = 0 convert
^!If ^%i% = 0 convert
^!Dec i 2
^!Set DMS=^$Calc((^%h% * 3600 + ^%m% * 60 + ^%s%)/3600;4)$
; InvDMS function
;Converts decimal value to DMS
^!Set x=^$Calc(^%x% * 60;4)$
^!If ^%i% = 0 Next1
^!Set s=^$Calc((^%x% * 60) + .5;2)$
;just 2 digits:
^!If ^%m% > 9 skip
^!If ^%s% > 9 Next2
;========= End =========