Sha256: 64610492cee8bfa624171ad372a4dec3e7bfb9da8e65233d4375332f9dbe5602

Contents?: true

Size: 1.32 KB

Versions: 25

Compression:

Stored size: 1.32 KB

Contents

require 'memory_profiler'
require 'benchmark/ips'

$: << File.expand_path('../../lib', __FILE__)


puts
puts "Memory stats for requiring mime/types/columnar"
result = MemoryProfiler.report do
  require 'mime/types/columnar'
end

puts "Total allocated: #{result.total_allocated_memsize} bytes (#{result.total_allocated} objects)"
puts "Total retained:  #{result.total_retained_memsize} bytes (#{result.total_retained} objects)"

puts
puts "Memory stats for requiring mini_mime"
result = MemoryProfiler.report do
  require 'mini_mime'
end

puts "Total allocated: #{result.total_allocated_memsize} bytes (#{result.total_allocated} objects)"
puts "Total retained:  #{result.total_retained_memsize} bytes (#{result.total_retained} objects)"


Benchmark.ips do |bm|
  bm.report 'cached content_type lookup MiniMime' do
    MiniMime.lookup_by_filename("a.txt").content_type
  end

  bm.report 'content_type lookup MIME::Types' do
    MIME::Types.type_for("a.txt")[0].content_type
  end
end

module MiniMime
  class Db
    class RandomAccessDb
      alias_method :lookup, :lookup_uncached
    end
  end
end

Benchmark.ips do |bm|
  bm.report 'uncached content_type lookup MiniMime' do
    MiniMime.lookup_by_filename("a.txt").content_type
  end

  bm.report 'content_type lookup MIME::Types' do
    MIME::Types.type_for("a.txt")[0].content_type
  end
end

Version data entries

25 entries across 18 versions & 6 rubygems

Version Path
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/tdiary-5.1.4/vendor/bundle/ruby/2.7.0/gems/mini_mime-1.0.2/bench/bench.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/2.7.0/gems/mini_mime-1.0.2/bench/bench.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/mini_mime-1.0.2/bench/bench.rb
tdiary-5.1.5 vendor/bundle/ruby/2.7.0/gems/mini_mime-1.0.2/bench/bench.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/tdiary-5.1.4/vendor/bundle/ruby/2.7.0/gems/mini_mime-1.0.2/bench/bench.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/mini_mime-1.0.2/bench/bench.rb
tdiary-5.1.4 vendor/bundle/ruby/2.7.0/gems/mini_mime-1.0.2/bench/bench.rb
tdiary-5.1.3 vendor/bundle/ruby/2.6.0/gems/mini_mime-1.0.2/bench/bench.rb
tdiary-5.1.3 vendor/bundle/ruby/2.7.0/gems/mini_mime-1.0.2/bench/bench.rb
tdiary-5.1.2 vendor/bundle/ruby/2.7.0/gems/mini_mime-1.0.2/bench/bench.rb
tdiary-5.1.2 vendor/bundle/ruby/2.6.0/gems/mini_mime-1.0.2/bench/bench.rb
argon-1.3.1 vendor/bundle/ruby/2.7.0/gems/mini_mime-1.0.2/bench/bench.rb
symbolic_enum-1.1.5 vendor/bundle/ruby/2.7.0/gems/mini_mime-1.0.2/bench/bench.rb
tdiary-5.1.1 vendor/bundle/ruby/2.7.0/gems/mini_mime-1.0.2/bench/bench.rb
tdiary-5.1.1 vendor/bundle/ruby/2.6.0/gems/mini_mime-1.0.2/bench/bench.rb
tdiary-5.1.0 vendor/bundle/gems/mini_mime-1.0.2/bench/bench.rb
chatops-rpc-0.0.2 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/mini_mime-1.0.2/bench/bench.rb
chatops-rpc-0.0.1 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/mini_mime-1.0.2/bench/bench.rb
spiral_form-0.1.1 vendor/bundle/gems/mini_mime-1.0.2/bench/bench.rb
spiral_form-0.1.0 vendor/bundle/gems/mini_mime-1.0.2/bench/bench.rb