《高效R语言编程》8–高效硬件

软件配置

benchmarkme包

高效硬件的5个技巧

  • 1、使用benchmarkme包评估下CPU,看是否值得硬件升级
  • 2、如有可能,增加更多RAM(虽然现在芯片慌,说这个有点不合时宜) 粗略经验,RAM应该是所分析数据集的3倍benchmarkme::get_ram() #查看你有多少RAM,当然我的电脑--属性也行Ps.我的windows系统中没有结果NA B
  • 3、确认你用的是64位的R 32位系统至多能用4G RAM,最近的电脑应该都是64位的了。·.Machine$sizeof.pointer #[1] 8·这样的结果就代表64位啦,这个应该是有原理的,感兴趣的可以查下。
  • 4、云计算也是一个成本低的获得强大算力的一个选择
  • 5、固态硬盘通常对代码执行影响不大,但是可以提升整体工作效率

R语言跑个分玩玩

library(benchmarkme)
res=benchmark_std()
# Programming benchmarks (5 tests):
 3,500,000 Fibonacci numbers calculation (vector calc): 0.547 (sec).
 Grand common divisors of 1,000,000 pairs (recursion): 0.66 (sec).
 Creation of a 3,500 x 3,500 Hilbert matrix (matrix calc): 0.353 (sec).
 Creation of a 3,000 x 3,000 Toeplitz matrix (loops): 1.27 (sec).
 Escoufier's method on a 60 x 60 matrix (mixed): 1.32 (sec).
# Matrix calculation benchmarks (5 tests):
 Creation, transp., deformation of a 5,000 x 5,000 matrix: 0.367 (sec).
 2,500 x 2,500 normal distributed random matrix^1,000: 0.323 (sec).
 Sorting of 7,000,000 random values: 0.683 (sec).
 2,500 x 2,500 cross-product matrix (b = a'
 * a): 6.77 (sec).
 Linear regr. over a 5,000 x 500 matrix (c = a  b'): 0.557 (sec).
# Matrix function benchmarks (5 tests):
 Cholesky decomposition of a 3,000 x 3,000 matrix: 3.62 (sec).
 Determinant of a 2,500 x 2,500 random matrix: 2.97 (sec).
 Eigenvalues of a 640 x 640 random matrix: 0.533 (sec).
 FFT over 2,500,000 random values: 0.287 (sec).
 Inverse of a 1,600 x 1,600 random matrix: 2.75 (sec).
plot(res)
# You are ranked 310 out of 749 machines.
# AMD R7 4700 8核心8线程,还凑活
# 上传你的结果
upload_results(res)
Creating temporary file
Getting system specs. This can take a while on Macs
Uploading results
Upload complete
Tracking id: 2021-05-12-63245334
[1] "2021-05-12-63245334"

有三个结果,分别是程序、计算和函数的总时间和相对时间,发现没有用上全部8核心,应该有一定影响。

其他的命令:

 benchmarkme::get_cpu()
$vendor_id
[1] "AuthenticAMD"

$model_name
[1] "AMD Ryzen 7 4700U with Radeon Graphics"

$no_of_cores
[1] 8
memory.limit()
[1] 15741


本篇文章来源于微信公众号: 微因

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注