zombocom / derailed_benchmarks

Go faster, off the Rails - Benchmarks for your whole Rails app
2.97k stars 144 forks source link

Introduce DERAILED_REQUIRE_APPLICATION #254

Closed kbrock closed 1 month ago

kbrock commented 1 month ago

Problem

This came about because when I run rake bundle:mem, it loads rails/all, and then it looks like we are loading action_mailbox and other rails gems that we void.

There are a bunch of options in this gem. If there is another way of determining this information, please point the way.

Description

For rails, config/application initializes the application.

DERAILED_REQUIRE_APPLICATION gives the developer the option to use the application.rb file to load all requires.

Do note, the existing Bundler.require(*env) will be a no-op.

DERAILED_REQUIRE_APPLICATION=true bundle exec derailed bundle:mem

(included above text for those following along - you know all this)

Alt Solution

-        if ENV["DERAILED_REQUIRE_APPLICATION"]
-          require "./config/application"
+        if ENV["DERAILED_REQUIRE"]
+          require ENV["DERAILED_REQUIRE"]

This provides non-rails use, but it does look a little bit of a brakeman nightmare. Let me know which way you want to go.

Thanks for all the good ruby stuff

schneems commented 1 month ago

I'm hesitant to add a ton of purpose-built env var flags. I think you can get the functionality you want already using a combination of DERAILED_SKIP_RAILS_REQUIRES and the perf.rake files https://github.com/zombocom/derailed_benchmarks?tab=readme-ov-file#perfrake

kbrock commented 1 month ago

@schneems thanks so much. I agree with wanting to avoid including a hundred environment variables here.

And thanks for all the great stuff in general