"timed"
which includes information about the time taken to compute the result.
The computation time is printed when the object is printed.
timed(x, ..., starttime = NULL, timetaken = NULL)
timetaken
is given.
x
.
"timed"
.
x
is an expression to be evaluated, timed(x)
evaluates the expression and measures the
time taken to evaluate it.
The result is saved as an object of the class
"timed"
. Printing this object displays the computation time. If x
is an object which has already been computed,
then the time taken to compute the object can be specified either directly
by the argument timetaken
, or indirectly by the argument
starttime
.
timetaken
is the duration of time taken to perform
the computation. It should be the difference of two clock times
returned by proc.time
. Typically the user
sets begin <- proc.time()
before commencing the calculations,
then end <- proc.time()
after completing the calculations,
and then sets timetaken <- end - begin
.
starttime
is the clock time at which the computation started.
It should be a value that was returned by proc.time
at some earlier time when the calculations commenced.
When timed
is called, the computation time will be taken
as the difference between the current clock time and
starttime
. Typically the user
sets begin <- proc.time()
before commencing the calculations,
and when the calculations are completed, the user calls
result <- timed(result, starttime=begin)
.
If the result of evaluating x
belongs to other S3 classes,
then the result of timed(x, ...)
also inherits these classes,
and printing the object will display the appropriate information for these
classes as well.
timeTaken
to extract the time taken.
timed(clarkevans(cells))
timed(Kest(cells))
answer <- timed(42, timetaken=4.1e17)
answer
Run the code above in your browser using DataLab