> -----Original Message-----
> From: Petr Krenzelok []
>
> start: now/time/precise .... do something ... print
> now/time/precise -
> start start: now/time/precise
try this:
it expects a block of code and even returns the value from it (and returns none for no
value functions like print)... but it can easily be tweaked to work differently?
;-----------------------------------------------------
rebol []
how-long?: function [codeblk [block! none!] /reset /quiet /log log-message log-string
][rval timestart timeend timelen][
if ((reset = true) OR (not value? 'how-long-accumulator)) [
how-long-accumulator: 0:00
]
if codeblk [
timestart: now/time/precise
if (error? try [rval: do codeblk ]) [rval: none]
timeend: now/time/precise
timelen: (timeend - timestart)
how-long-accumulator: how-long-accumulator + timelen
if not quiet [
print ["performed in: " timelen ]
print ["accumulated: " how-long-accumulator ]
]
if log [
append log-string log-message
append log-string rejoin [" > time: " timelen "
accumulated: " how-long-accumulator "^/"]
]
]
return rval
]
log-string: copy ""
how-long?/log [loop 1000000 [34.0 / 2.556] ] "test-block-A() " log-string
how-long?/log [loop 1000000 [34.0 / 2.556] ] "test-block-B() " log-string
how-long?/log [loop 1000000 [34.0 / 2.556] ] "test-block-C() " log-string
how-long?/log [loop 1000000 [34.0 / 2.556] ] "test-block-D() " log-string
print log-string
--
To unsubscribe from this list, just send an email to
[EMAIL PROTECTED] with unsubscribe as the subject.