[REBOL] help with function utilising "extended life-time" words ..
From: petr:krenzelok:trz:cz at: 1-Oct-2003 18:44
I am currently working with some databases and I do some steps in my
script, which I measure currently for its duration time. I use something
start: now/time/precise .... do something ... print now/time/precise -
start start: now/time/precise
I wanted to write myself short logger function, which will save me from
repeating above sequences, as the script becomes a bit messy then. So I
wanted to have following interface:
>> how-long? "Some task ..."
Total: 0:1:32 This: 0:0:1 Some task ....
- Simply put - requested function should not require sending any time
information, only a text message ...
- it should start counter when first called
- it should be possible to reset counter with /reset refinement ...
I looked at some past threads and tried Joel's solution:
foo: func [arg [string!] /reset /report /local ncalls][
if reset [return ncalls/1: 0]
if report [return ncalls/1]
ncalls/1: ncalls/1 + 1
rejoin ["call # " ncalls/1 " with " arg]
... but when I define something like "timer: reduce [now/time/precise
0]", it seems to me, that 'reduce causes reinitialisation of block
values with each function call, while I would like to store "first run"
time value somewhere to be able to count total task run time ...
Thank you very much,