Skip to content

Instantly share code, notes, and snippets.

@motchang
Last active June 20, 2019 12:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save motchang/ac3ab76c3e7060e969356d8374cac22a to your computer and use it in GitHub Desktop.
Save motchang/ac3ab76c3e7060e969356d8374cac22a to your computer and use it in GitHub Desktop.
big set
require 'set'
require 'benchmark'
Benchmark.bm 10 do |r|
limit = 65535*1000
r.report "to_a" do
(1..limit).to_a
end
r.report "to_set" do
(1..limit).to_set
end
end
@motchang
Copy link
Author

motchang commented Jun 20, 2019

*                user     system      total        real
to_a         1.520000   0.150000   1.670000 (  1.821450)
to_set      28.270000   1.780000  30.050000 ( 30.259813)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment