Benchmark: each_key vs each vs each_pair
来源:互联网 发布:2017年病退工资的算法 编辑:程序博客网 时间:2024/06/02 01:16
each_keyeacheach_pair
require "benchmark"
h = Hash.new;
n = 100000;
for i in 1..n;
h[i] = i.to_s;
end;
Benchmark.bm do |x|;
x.report {
s = "";
h.each_key do |key|;
s << key.to_s << h[key];
end;
}
end;
# user system total real
# 0.621000 0.040000 0.661000 ( 0.691000)
require "benchmark"
h = Hash.new;
n = 100000;
for i in 1..n;
h[i] = i.to_s;
end;
Benchmark.bm do |x|;
x.report {
s = "";
h.each do |key, value|;
s << key.to_s << value;
end;
}
end;
# user system total real
# 0.821000 0.030000 0.851000 ( 0.871000)
require "benchmark"
h = Hash.new;
n = 100000;
for i in 1..n;
h[i] = i.to_s;
end;
Benchmark.bm do |x|;
x.report {
s = "";
h.each_pair do |key, value|;
s << key.to_s << value;
end;
}
end;
# user system total real
# 0.841000 0.030000 0.871000 ( 0.891000)
- Benchmark: each_key vs each vs each_pair
- Async vs sync benchmark
- JAVA VS CPP Benchmark
- kudu vs parquet, impala vs spark Benchmark
- Benchmark - W3C DOM vs. innerHTML
- Benchmark: PHP vs. Python vs. Perl vs. Ruby
- Quick Benchmark: Gzip vs Bzip2 vs LZMA vs XZ vs LZ4 vs LZ
- Quick Benchmark: Gzip vs Bzip2 vs LZMA vs XZ vs LZ4 vs LZO
- each_pair
- Java String vs StringBuilder vs StringBuffer Concatenation Performance Micro Benchmark
- MySQL 5.5 m2 VS MS Sql Server 2000 SE BenchMark
- > VS >
- VS
- vs
- vs
- &&VS&
- VS
- vs
- collect!
- 将jsp动态页面静态化
- lcm
- .bash_profile和.bashrc的什么区别
- concat
- Benchmark: each_key vs each vs each_pair
- NetAdvantage控件的汉化办法
- 如何批量新建文件
- Linux核心调试环境的搭建
- <<
- benchmark
- W1
- chomp
- html