/shrine-carrierwave-load-time.rb Secret
Last active
September 16, 2016 06:24
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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