Skip to content

Instantly share code, notes, and snippets.

@josevalim
Created December 6, 2011 11:54

Revisions

  1. josevalim revised this gist Dec 6, 2011. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions application.rb
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,8 @@
    # THANKS EVERYONE FOR YOUR BELOVED BENCHMARKS.
    # THIS PATCH IS NOW IN RAILS:
    #
    # https://github.com/rails/rails/commit/885a599303585b796da7a0a1c3ccd0bc5c642134

    # Please add the following lines after Bundler.require
    # and before "class Application < Rails::Application"
    # in your config/application.rb
  2. josevalim revised this gist Dec 6, 2011. 1 changed file with 5 additions and 4 deletions.
    9 changes: 5 additions & 4 deletions application.rb
    Original file line number Diff line number Diff line change
    @@ -4,8 +4,8 @@
    #
    # Notice this is just an experiment, don't leave those
    # lines there after the experiment. Then please benchmark
    # your app boot time before and after adding those lines.
    # A simple benchmark is:
    # your app boot time in development before and after adding
    # those lines. A simple benchmark is:
    #
    # time script/rails runner "MODEL"
    #
    @@ -19,8 +19,9 @@
    # This patch should work on Rails 3.0, 3.1 and master.
    #
    # Extra: if you could run your app in development and
    # production (in your machine!!) with this patch and
    # report any errors you will win extra <3 <3 <3.
    # production (in your machine!!) with this patch on
    # for a couple minutes and report any errors, you will
    # win extra <3 <3 <3.

    require "active_support/dependencies"

  3. josevalim revised this gist Dec 6, 2011. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion application.rb
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,9 @@
    #
    # time script/rails runner "MODEL"
    #
    # Where MODEL is a model available in your app.
    # Where MODEL is a model available in your app. Also,
    # please run the command above at least three times to
    # ensure we don't have fake samples. :)
    #
    # Please post the results in the comments below of the
    # benchmarks before and after adding the code. <3
  4. josevalim created this gist Dec 6, 2011.
    40 changes: 40 additions & 0 deletions application.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,40 @@
    # Please add the following lines after Bundler.require
    # and before "class Application < Rails::Application"
    # in your config/application.rb
    #
    # Notice this is just an experiment, don't leave those
    # lines there after the experiment. Then please benchmark
    # your app boot time before and after adding those lines.
    # A simple benchmark is:
    #
    # time script/rails runner "MODEL"
    #
    # Where MODEL is a model available in your app.
    #
    # Please post the results in the comments below of the
    # benchmarks before and after adding the code. <3
    #
    # This patch should work on Rails 3.0, 3.1 and master.
    #
    # Extra: if you could run your app in development and
    # production (in your machine!!) with this patch and
    # report any errors you will win extra <3 <3 <3.

    require "active_support/dependencies"

    ActiveSupport::Dependencies::WatchStack.class_eval do
    def watching?
    !@watching.empty?
    end
    end

    def load_dependency(file)
    if ActiveSupport::Dependencies.load? && ActiveSupport::Dependencies.constant_watch_stack.watching?
    ActiveSupport::Dependencies.new_constants_in(Object) { yield }
    else
    yield
    end
    rescue Exception => exception # errors from loading file
    exception.blame_file! file
    raise
    end