newTimer {xegaSelectGene} | R Documentation |
Timer for R code chunks.
Description
newTimer
sets up a timer object with two
internal state variables, namely count
to count the number of timer calls and
tUsed
to calculate the total time spent in a code block
between two timer calls.
Usage
newTimer()
Details
-
Generate a timer:
a<-newTimer()
sets up the timera
. The timera
supports three methods:-
a()
ora("Measure")
ora(method="Measure")
starts the timer when called 1st, 3rd, 5th, ... time and stops the timer when called the 2nd, 4th, 6th, ... time. The calls can be manually inserted before and after a block of R-code for profiling. -
a("TimeUsed")
ora(method="TimeUsed")
returns the time used in seconds. -
a("Count")
ora(method="Count")
returns the number of times the function/block or R-code has been executed.
-
-
The second way of usage is with the
Timed
function:Generate a timer:
a<-newTimer()
sets up the timera
.You convert a function
b
into a timed functionbTimed
bybTimed<-Timed(a, b)
.You use
bTimed
instead ofb
.At the end, you can query the aggregated time and the aggregated number of executions by
a("TimeUsed")
anda("Count")
, respectively.
Value
newTimer()
returns a timer function.
a_timer_function()
returns the used time in seconds
(invisible).
a_timer_function("TimeUsed")
returns the used time in seconds.
a_timer_function("Count")
returns the number of executions
of a timed function and/or a timed block of R-Code in seconds.
See Also
Other Performance Measurement:
Counted()
,
Timed()
,
newCounter()
Examples
a<-newTimer()
a(); Sys.sleep(2); a()
a("TimeUsed")
a("Count")