Skip to content

Instantly share code, notes, and snippets.

@janko
Last active September 16, 2016 06:24
Show Gist options
  • Save janko/0d4269b9c7195b5e65cc947acf1cc028 to your computer and use it in GitHub Desktop.
Save janko/0d4269b9c7195b5e65cc947acf1cc028 to your computer and use it in GitHub Desktop.
require "benchmark"
gem = Gem::Specification.find_by_name("shrine")
plugins_dir = "#{gem.full_gem_path}/lib/shrine/plugins"
plugin_names = Dir["#{plugins_dir}/*.rb"].map { |plugin_path| File.basename(plugin_path, ".*").to_sym }
puts Benchmark.realtime {
require "shrine"
plugin_names.each do |plugin_name|
case plugin_name
when :download_endpoint
Shrine.plugin plugin_name, storages: [:cache]
when :remote_url
Shrine.plugin plugin_name, max_size: nil
when :backup
Shrine.plugin plugin_name, storage: :backup_store
when :background_helpers, :migration_helpers
# deprecated
when :activerecord, :sequel
# loading ORMs skews the results
else
Shrine.plugin plugin_name
end
end
}
puts Benchmark.realtime {
require "carrierwave"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment