Sha256: d3f1701c0b4dd957517c72527eee671d6b995e1938fc8a41b83f40c31778ce2f

Contents?: true

Size: 1.34 KB

Versions: 109

Compression:

Stored size: 1.34 KB

Contents

# frozen_string_literal: true
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

109 entries across 106 versions & 12 rubygems

Version Path
harbr-0.1.83 vendor/bundle/ruby/3.2.0/gems/mini_mime-1.1.5/bench/bench.rb
harbr-0.1.82 vendor/bundle/ruby/3.2.0/gems/mini_mime-1.1.5/bench/bench.rb
harbr-0.1.81 vendor/bundle/ruby/3.2.0/gems/mini_mime-1.1.5/bench/bench.rb
harbr-0.1.80 vendor/bundle/ruby/3.2.0/gems/mini_mime-1.1.5/bench/bench.rb
harbr-0.1.79 vendor/bundle/ruby/3.2.0/gems/mini_mime-1.1.5/bench/bench.rb
harbr-0.1.78 vendor/bundle/ruby/3.2.0/gems/mini_mime-1.1.5/bench/bench.rb
harbr-0.1.77 vendor/bundle/ruby/3.2.0/gems/mini_mime-1.1.5/bench/bench.rb
harbr-0.1.76 vendor/bundle/ruby/3.2.0/gems/mini_mime-1.1.5/bench/bench.rb
harbr-0.1.75 vendor/bundle/ruby/3.2.0/gems/mini_mime-1.1.5/bench/bench.rb
harbr-0.1.74 vendor/bundle/ruby/3.2.0/gems/mini_mime-1.1.5/bench/bench.rb
harbr-0.1.73 vendor/bundle/ruby/3.2.0/gems/mini_mime-1.1.5/bench/bench.rb
harbr-0.1.72 vendor/bundle/ruby/3.2.0/gems/mini_mime-1.1.5/bench/bench.rb
harbr-0.1.71 vendor/bundle/ruby/3.2.0/gems/mini_mime-1.1.5/bench/bench.rb
harbr-0.1.70 vendor/bundle/ruby/3.2.0/gems/mini_mime-1.1.5/bench/bench.rb
harbr-0.1.69 vendor/bundle/ruby/3.2.0/gems/mini_mime-1.1.5/bench/bench.rb
harbr-0.1.68 vendor/bundle/ruby/3.2.0/gems/mini_mime-1.1.5/bench/bench.rb
harbr-0.1.67 vendor/bundle/ruby/3.2.0/gems/mini_mime-1.1.5/bench/bench.rb
harbr-0.1.66 vendor/bundle/ruby/3.2.0/gems/mini_mime-1.1.5/bench/bench.rb
harbr-0.1.65 vendor/bundle/ruby/3.2.0/gems/mini_mime-1.1.5/bench/bench.rb
harbr-0.1.64 vendor/bundle/ruby/3.2.0/gems/mini_mime-1.1.5/bench/bench.rb