pboling / gem_bench

Benchmark different versions of same or similar gems & Static Gemfile and installed gem library source code analysis
http://railsbling.com/gem_bench
MIT License
84 stars 5 forks source link

Issues when attempting to benchmark `inline_svg` #56

Open tagliala opened 1 week ago

tagliala commented 1 week ago

Hi,

I suspect that there could be an issue in case the library has nested folders which alphabetically precede the library itself, but it is just a guess

re_namespaced_gems = [
  GemBench::Jersey.new(
    gem_name: "inline_svg",
    trades: {
      "InlineSvg" => 'InlineSvgGithubMain'
    },
    verbose: true
  ),
].each(&:doff_and_don) # Copies, re-namespaces, and requires each gem.
$ bundle exec ruby benchmarks.rb
[inline_svg] Doffing ~/.rvm/gems/ruby-3.3.6/bundler/gems/inline_svg-01b5e607814d
[inline_svg] --------------------------------
[inline_svg] Doffing file ~/.rvm/gems/ruby-3.3.6/bundler/gems/inline_svg-01b5e607814d/lib/inline_svg/action_view/helpers.rb
[inline_svg] --------------------------------
[inline_svg][helpers.rb] dirname: ~/.rvm/gems/ruby-3.3.6/bundler/gems/inline_svg-01b5e607814d/lib/inline_svg/action_view
[inline_svg][helpers.rb] is_at_gem_root: false
[inline_svg][helpers.rb] lib_split: inline_svg/action_view
[inline_svg][helpers.rb] relative_path: inline_svg/action_view
~/.rvm/gems/ruby-3.3.6/gems/gem_bench-2.0.5/lib/gem_bench/jersey.rb:95:in `mkdir': No such file or directory @ dir_s_mkdir - /var/folders/tmp/path/to/inline_svg/action_view (Errno::ENOENT)
    from ~/.rvm/gems/ruby-3.3.6/gems/gem_bench-2.0.5/lib/gem_bench/jersey.rb:95:in `block (2 levels) in doff_and_don'
    from ~/.rvm/gems/ruby-3.3.6/gems/gem_bench-2.0.5/lib/gem_bench/jersey.rb:72:in `map'
    from ~/.rvm/gems/ruby-3.3.6/gems/gem_bench-2.0.5/lib/gem_bench/jersey.rb:72:in `block in doff_and_don'
    from ~/.rvm/rubies/ruby-3.3.6/lib/ruby/3.3.0/tmpdir.rb:99:in `mktmpdir'
    from ~/.rvm/gems/ruby-3.3.6/gems/gem_bench-2.0.5/lib/gem_bench/jersey.rb:70:in `doff_and_don'

I've changed this line

https://github.com/pboling/gem_bench/blob/7624082896d30e7ae2ef583d661721770857bf10/lib/gem_bench/jersey.rb#L95

with FileUtils.mkdir_p(dir_path) unless Dir.exist?(dir_path) (plus requiring fileutils) and it worked

PS: The gem does not work yet because of a couple of require relatives that I've missed: (jamesmartin/inline_svg#173)

PS2: Even with the changes at jamesmartin/inline_svg#173, gem_bench does not work with inline_svg

pboling commented 2 days ago

Thanks for trying it out!! I will have a look and see if I can figure out where it fails. It struggles in certain scenarios where load order is important.