[R] how to obtain the CPU time of my program

Gabor Csardi csardi at rmki.kfki.hu
Thu Sep 13 17:38:09 CEST 2007


Here's how to use it: 

f <- function() {
  <<here comes your code>>
}

system.time( f() )

It is not required to define a function, but i think it is easier.

Gabor

On Thu, Sep 13, 2007 at 04:16:45PM +0100, gang xu wrote:
> Dear R users and experts,
> 
> I am current running a program (a series of commands) in R. such as:
> 
> A <- as.matrix(read.table("C:/LP.txt"));
> 
> a=which(memb==q); b=a; B=as.matrix(A[a,b])
> 
> LS=sum(B)/2;
> 
> TL=sum(A)/2
> 
> i<-c(1:NN);
> 
> D=sum(A[a,i]);
> 
> how can i obtain the CPU time used for these commands ?
> 
> I have seen the system.time function but i am not sure how to use it. Could anyone help me ?
> 
> ****** If we have a number of commands, how can we know the CPU for these commands *******
> 
> 
> Thanks a lot for your time and help
> 
> Have a nice day!
> 
> Warm Regards
> 
> Marshall
> 
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor <csardi at rmki.kfki.hu>    MTA RMKI, ELTE TTK



More information about the R-help mailing list