Skip to content

Instantly share code, notes, and snippets.

@faheemmughal
Created December 17, 2025 21:50
Show Gist options
  • Select an option

  • Save faheemmughal/a4e6cedb555e2a3ae082993fbddccfa8 to your computer and use it in GitHub Desktop.

Select an option

Save faheemmughal/a4e6cedb555e2a3ae082993fbddccfa8 to your computer and use it in GitHub Desktop.
require "benchmark"
@project_directory = File.expand_path(Coverband.configuration.root)
def old_glob
Dir.glob("#{@project_directory}/app/views/**/*.html.{erb,haml,slim}").map {|filename| filename }
end
def current_glob
Dir.glob("#{@project_directory}/**/app/views/**/*.html.{erb,haml,slim}").map {|filename| filename }
end
def glob_following_symlink
Dir.glob("#{@project_directory}/**/*/**/app/views/**/*.html.{erb,haml,slim}").map {|filename| filename }
end
def glob_with_explicit_directories
Dir.glob("#{@project_directory}/{,components,packs,engines}/*/app/views/**/*.html.{erb,haml,slim}").map {|filename| filename }
end
def find_suggestion
IO.popen("find #{@project_directory}/ -path '*/app/views/*' \\( -iname \*.html.erb -o -iname \*.html.haml -o -iname \*.html.slim \\)").map { |path| path.chomp }
end
def find_with_symlink
IO.popen("find -L #{@project_directory}/ -path '*/app/views/*' \\( -iname \*.html.erb -o -iname \*.html.haml -o -iname \*.html.slim \\)").map { |path| path.chomp }
end
n = 25
Benchmark.bm(30) do |bm|
bm.report("old_glob:") { n.times { old_glob } }
bm.report("current_glob:") { n.times { current_glob } }
bm.report("glob_following_symlink:") { n.times { glob_following_symlink } }
bm.report("glob_with_explicit_directories:") { n.times { glob_with_explicit_directories } }
bm.report("find:") { n.times { find_suggestion } }
bm.report("find_with_symlink:") { n.times { find_with_symlink } }
end
@faheemmughal
Copy link
Author

benchmark to support the issue here: danmayer/coverband#596

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