Skip to content

Instantly share code, notes, and snippets.

@djberg96
Created August 18, 2020 10:58
Show Gist options
  • Select an option

  • Save djberg96/7b33f4eb04b5ba98aa71dd3851a8b825 to your computer and use it in GitHub Desktop.

Select an option

Save djberg96/7b33f4eb04b5ba98aa71dd3851a8b825 to your computer and use it in GitHub Desktop.
require 'benchmark'
MAX = 10000000
Benchmark.bm(30) do |x|
x.report("require") do
MAX.times { require 'ffi' }
end
x.report("require unless") do
MAX.times { require 'ffi' unless defined?(FFI) }
end
end
# RESULTS
user system total real
require 9.909382 0.018558 9.927940 ( 9.943800)
require unless 0.544861 0.000000 0.544861 ( 0.545700)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment