Skip to content

Instantly share code, notes, and snippets.

@enebo

enebo/bench.rb Secret

Created February 28, 2023 21:26
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 enebo/c9a188a0599ec7087ae1d68d6a4f9a8e to your computer and use it in GitHub Desktop.
Save enebo/c9a188a0599ec7087ae1d68d6a4f9a8e to your computer and use it in GitHub Desktop.
require 'benchmark'
20.times do
p("%0.6f" % Benchmark.realtime {
File.open('A.txt').readlines do |line|
10.times do
line[5]
line[10]
line[20]
line[40]
line[60]
end
end
})
end
jruby -Xcompile.invokedynamic gets_bench.rb
"0.757427"
"0.706870"
"0.775262"
"0.752200"
"0.638191"
"0.697848"
"0.840295"
"0.718880"
"0.775943"
"0.751087"
"0.861543"
"0.793738"
"0.731502"
"0.467162"
"0.724081"
"0.701253"
"0.768865"
"0.769979"
"0.662032"
"0.466345"
AFTER:
jruby -Xcompile.invokedynamic gets_bench.rb
"0.708550"
"0.586651"
"0.624988"
"0.587505"
"0.503620"
"0.515223"
"0.510485"
"0.765675"
"0.599085"
"0.606644"
"0.573161"
"0.413883"
"0.561218"
"0.597783"
"0.581685"
"0.576364"
"0.595542"
"0.340622"
"0.658417"
"0.704782"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment