我只是想知道Crystal编程语言的编译速度 . 感觉比较慢:
➜ ~/Code/crystal/crystal_scheduler (master ✘)✹✭ ᐅ time crystal build --release src/crystal_scheduler.cr
34.64s user 1.10s system 93% cpu 38.174 total
➜ ~/Code/crystal/crystal_scheduler (master ✘)✹✭ ᐅ time crystal build --release src/crystal_scheduler.cr
36.11s user 0.83s system 93% cpu 39.465 total
➜ ~/Code/crystal/crystal_scheduler (master ✘)✹✭ ᐅ time crystal build src/crystal_scheduler.cr
8.09s user 0.89s system 181% cpu 4.956 total
代码相对较小,有两个分片,两个类 . 与我从Java中了解的其他编译时间相比,这感觉好像很长一段时间 .
我得到的版本编译速度很慢,但git书中说:
原因是没有完全优化的性能仍然相当不错并且提供了快速的编译时间,因此您可以使用crystal命令,就像它是一个解释器一样 .
但8s声称你可以“使用它几乎就像是翻译一样”,感觉有点慢 .
我只是想知道 - a)我的编译速度特别慢/编译时间是否正常 - b)它与你体验中的其他语言相比如何
编制统计:
Parse: 00:00:00.0007470 ( 0.25MB)
Semantic (top level): 00:00:00.3968920 ( 36.08MB)
Semantic (new): 00:00:00.0019210 ( 44.08MB)
Semantic (type declarations): 00:00:00.0355760 ( 44.08MB)
Semantic (abstract def check): 00:00:00.0012690 ( 44.08MB)
Semantic (ivars initializers): 00:00:00.0094640 ( 44.08MB)
Semantic (cvars initializers): 00:00:00.0394420 ( 44.08MB)
Semantic (main): 00:00:00.6025030 ( 108.14MB)
Semantic (cleanup): 00:00:00.0012750 ( 108.14MB)
Semantic (recursive struct check): 00:00:00.0018930 ( 108.14MB)
Codegen (crystal): 00:00:00.7354530 ( 140.27MB)
Codegen (bc+obj): 00:00:33.2533520 ( 140.27MB)
Codegen (linking): 00:00:00.3647440 ( 140.27MB)
我的系统:
➜ crystal -v
Crystal 0.22.0 (2017-04-20) LLVM 4.0.0
硬件概述:
Model Name: MacBook Pro
Model Identifier: MacBookPro11,1
Processor Name: Intel Core i5
Processor Speed: 2,8 GHz
Number of Processors: 1
Total Number of Cores: 2
L2 Cache (per Core): 256 KB
L3 Cache: 3 MB
Memory: 16 GB
1 回答
使用
crystal build --no-debug my_code.cr
可以提高编译速度 .见:Why Crystal use too much memory?和Crystal for large scale programs
另外,我建议你添加
--progress
标志 .进度标志添加有关编译过程的更多信息,显示在codegen阶段生成的每个文件的统计信息 .
(1)处理的文件数量,可以在Crystal缓存目录中看到这些文件 .
顺便说一句,我在一台旧的Intel Celeron PC上用不到30秒的时间编制了一个完整的Amber项目,其中包含10个分片 . 不要在开发阶段使用
--release
标志,而是在 生产环境 阶段使用 . (LLVM需要花费大量时间进行优化)