- 注册时间
- 2007-12-28
- 最后登录
- 1970-1-1
- 威望
- 星
- 金币
- 枚
- 贡献
- 分
- 经验
- 点
- 鲜花
- 朵
- 魅力
- 点
- 上传
- 次
- 下载
- 次
- 积分
- 12787
- 在线时间
- 小时
|
楼主 |
发表于 2018-1-2 11:43:34
|
显示全部楼层
在我这里,用Timing得到时间值确实是离散的,它总是15.6ms的总倍数。AbsoluteTiming不是
下面是我的代码,你可测试下。
- Print["Mathematica:",$VersionNumber];
- digArr={20,30,40,50,60,70,80,90,100,125,158,199,251,316,398,501,630,794,
- 1000};
- For [i=1,i <= Length[digArr],i++,
- prec=digArr[[i]];
- n=IntegerPart[N[2^24/(prec^1.5),10]];
- n=Max[n,3];
- (*Print["n=",n];*);
- x=N[Sqrt[3]-1,prec];
- y=N[Sqrt[5],prec];
-
- While [True,
- (*t=(AbsoluteTiming[Do[Log[x],{n}]][[1]]-AbsoluteTiming[Do[Null,{n}]][[1]]);*)
- t=Timing[Do[Log[x],{n}]][[1]];
- (* convert to ms *)
- t *= 1000;
- (*Print["t=",t]; *)
- If [t>=10.0, Break[]];
- n*=2;
- ];
- Print[prec,":took ",t/n, " ms (", n, " eval in ", t, "ms)" ];
- ]
复制代码
下面是测试结果
- Mathematica:10.3
- 20:took 0.0025782 ms (187574 eval in 483.603ms)
- 30:took 0.00275021 ms (102102 eval in 280.802ms)
- 40:took 0.00305806 ms (66317 eval in 202.801ms)
- 50:took 0.00328748 ms (47453 eval in 156.001ms)
- 60:took 0.00388944 ms (36098 eval in 140.401ms)
- 70:took 0.00435666 ms (28646 eval in 124.801ms)
- 80:took 0.0053229 ms (23446 eval in 124.801ms)
- 90:took 0.00555757 ms (19649 eval in 109.201ms)
- 100:took 0.0055791 ms (16777 eval in 93.6006ms)
- 125:took 0.00779745 ms (12004 eval in 93.6006ms)
- 158:took 0.00923411 ms (8447 eval in 78.0005ms)
- 199:took 0.0130523 ms (5976 eval in 78.0005ms)
- 251:took 0.0147938 ms (4218 eval in 62.4004ms)
- 316:took 0.0208977 ms (2986 eval in 62.4004ms)
- 398:took 0.0295456 ms (2112 eval in 62.4004ms)
- 501:took 0.0521394 ms (1496 eval in 78.0005ms)
- 630:took 0.0735854 ms (1060 eval in 78.0005ms)
- 794:took 0.0833116 ms (749 eval in 62.4004ms)
- 1000:took 0.117737 ms (530 eval in 62.4004ms)
复制代码 各次运行时间除以15.6, 在6位精度范围内,他确实是15.6的正倍数。
- 总时间 总时间/15.6
- 483.603 31.00019231
- 280.802 18.00012821
- 202.801 13.0000641
- 156.001 10.0000641
- 140.401 9.000064103
- 124.801 8.000064103
- 124.801 8.000064103
- 109.201 7.000064103
- 93.6006 6.000038462
- 93.6006 6.000038462
- 78.0005 5.000032051
- 78.0005 5.000032051
- 62.4004 4.000025641
- 62.4004 4.000025641
- 78.0005 5.000032051
- 78.0005 5.000032051
- 62.4004 4.000025641
- 62.4004 4.000025641
复制代码
如果时间的分辨率是毫秒,该如何解释 124.801,109.201,93.6006这样的数值呢? 如果正好碰到一个15.6的倍数不奇怪,但100%的15.6的倍数就难以解释了。 |
|