1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* benchmark/: add vnmakarov's benchmarks around hash [ruby-core:75265]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56161 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2016-09-14 16:00:55 +00:00
parent 2bbd6f18cd
commit 2abf156304
6 changed files with 12 additions and 0 deletions

View file

@ -1,3 +1,7 @@
Thu Sep 15 00:59:30 2016 NARUSE, Yui <naruse@ruby-lang.org>
* benchmark/: add vnmakarov's benchmarks around hash [ruby-core:75265]
Wed Sep 14 07:02:31 2016 NARUSE, Yui <naruse@ruby-lang.org>
* hash.c (each_pair_i_fast): use rb_yield_values2 to avoid var args.

1
benchmark/bm_bighash.rb Normal file
View file

@ -0,0 +1 @@
h = {}; 5000000.times {|n| h[n] = n }

View file

@ -0,0 +1,4 @@
k1 = "Ping Pong Ping Pong Ping Pong Ping Pong Ping Pong Ping Pong Ping Pong Ping Pong Ping Pong Ping Pong";
k2 = "Pong Ping Pong Ping Pong Ping Pong Ping Pong Ping Pong Ping Pong Ping Pong Ping Pong Ping Pong Ping";
h = {k1 => 0, k2 => 0};
3000000.times{|i| k = i % 2 ? k2 : k1; h [k] = h[k] + 1}

View file

@ -0,0 +1 @@
1000000.times.map{|i| a={}; 2.times{|j| a[j]=j}; a}

View file

@ -0,0 +1 @@
1000000.times.map{|i| a={}; 4.times{|j| a[j]=j}; a}

View file

@ -0,0 +1 @@
1000000.times.map{|i| a={}; 8.times{|j| a[j]=j}; a}