Skip to content

Instantly share code, notes, and snippets.

@apainintheneck
Created December 28, 2023 02:49
Show Gist options
  • Save apainintheneck/c048d1abf346a322964e02c6b9875428 to your computer and use it in GitHub Desktop.
Save apainintheneck/c048d1abf346a322964e02c6b9875428 to your computer and use it in GitHub Desktop.
# Benchmarking things to explore `brew desc` without a cache.
# See: https://github.com/Homebrew/brew/issues/16237
Benchmark.bm do |x|
x.report("JSON") do
Homebrew::API::Formula.all_formulae
end
x.report("Ruby") do
CoreTap.instance.formula_files.map do |file|
Formulary.factory(file)
end
end
x.report("Cache") do
CacheStoreDatabase.use(:descriptions) do |db|
db.empty?
end
end
end
# On Old iMac
# -----------
# user system total real
# JSON 0.633890 0.073619 0.707509 ( 0.709061)
# Ruby 16.119298 2.291271 18.433785 ( 19.035318)
# Cache 0.005555 0.000541 0.006096 ( 0.006521)
@apainintheneck
Copy link
Author

The JSON parser was around twice as fast on my new MacBook.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment