Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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