Benchmark for require vs. Kernel.send :require

# encoding: utf-8 require 'benchmark' benchmark_count = 1_000_000 Benchmark.bm do |benchmark| # test require 'gem' benchmark.report(:require) { benchmark_count.times { require 'unirest' } } # test Kernel.send :require, 'gem' benchmark.report(:kernel_send) { benchmark_count.times { Kernel.send :require, 'unirest' } } end # results # user system total real # require 3.950000 0.090000 4.040000 (4.942678) # kernel_send 0.790000 0.010000 0.800000 (0.912427)

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.