-
Notifications
You must be signed in to change notification settings - Fork 422
/
partial_benchmark.rb
33 lines (24 loc) · 1.03 KB
/
partial_benchmark.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# frozen_string_literal: true
# Run `bundle exec rake benchmark` to execute benchmark.
# This is very much a work-in-progress. Please feel free to make/suggest improvements!
require "benchmark/ips"
# Configure Rails Environment
ENV["RAILS_ENV"] = "production"
require File.expand_path("../test/sandbox/config/environment.rb", __dir__)
module Performance
require_relative "components/name_component"
require_relative "components/nested_name_component"
require_relative "components/inline_component"
end
class BenchmarksController < ActionController::Base
end
BenchmarksController.view_paths = [File.expand_path("./views", __dir__)]
controller_view = BenchmarksController.new.view_context
Benchmark.ips do |x|
x.time = 10
x.warmup = 2
x.report("component") { controller_view.render(Performance::NameComponent.new(name: "Fox Mulder")) }
x.report("inline") { controller_view.render(Performance::InlineComponent.new(name: "Fox Mulder")) }
x.report("partial") { controller_view.render("partial", name: "Fox Mulder") }
x.compare!
end