Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/algorithm/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R-计算脚本的计算成本_R_Algorithm_Code Complexity - Fatal编程技术网

R-计算脚本的计算成本

R-计算脚本的计算成本,r,algorithm,code-complexity,R,Algorithm,Code Complexity,我有两个在R中使用类似算法的脚本。我想通过计算成本来比较它们。我怎样计算呢 谢谢 劳尔这是一个很好的例子 第一种方式: ptm <- proc.time() #your function here proc.time() - ptm 墙时间,CPU,总内存将是我的猜测。措施;不要计算。你是说system.time不会计算传递给它的表达式吗?因为那完全是错误的。或者您只是不知道您可以打印,例如,system.time(打印(1:5)),或者分配,例如,system.time(x@Rolan

我有两个在R中使用类似算法的脚本。我想通过计算成本来比较它们。我怎样计算呢

谢谢

劳尔

这是一个很好的例子

第一种方式:

ptm <- proc.time()
#your function here
proc.time() - ptm

墙时间,CPU,总内存将是我的猜测。措施;不要计算。你是说
system.time
不会计算传递给它的表达式吗?因为那完全是错误的。或者您只是不知道您可以打印,例如,
system.time(打印(1:5))
,或者分配,例如,
system.time(x@Roland,你说得对,刚刚检查过。我的意思是按照大o符号来衡量计算成本automatically@user3886573我想这是一个实验性的问题,你可以通过测量不同初始参数的不同时间来得到
system.time({ #your function here })