Created
December 17, 2025 21:50
-
-
Save faheemmughal/a4e6cedb555e2a3ae082993fbddccfa8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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" | |
| @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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
n = 25 gave these results: