Skip to content

Commit 62d491b

Browse files
committed
[GR-21232] Add ecosystem benchmark for rails routes
PullRequest: truffleruby/2075
2 parents c622cf9 + b3c847b commit 62d491b

File tree

5 files changed

+72
-1
lines changed

5 files changed

+72
-1
lines changed

bench/rails/blog6-bundle-install.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# This is a long running benchmark and should
2+
# be run using fixed iterations. E.g.
3+
# jt benchmark bench/rails/blog6-bundle-install.rb --elapsed --iterations --ips --fixed-iterations 1
4+
# RUBY_BENCHMARKS=true jt mx benchmark ecosystem
5+
#
6+
7+
require_relative './blog6-setup.rb'
8+
9+
Blog6Setup.setup_bundler
10+
11+
benchmark 'blog6-bundle-install' do
12+
Blog6Setup.bundle_install
13+
end

bench/rails/blog6-rails-routes.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# This is a long running benchmark and should
2+
# be run using fixed iterations. E.g.
3+
# jt benchmark bench/rails/blog6-rails-routes.rb --elapsed --iterations --ips --fixed-iterations 1
4+
# RUBY_BENCHMARKS=true jt mx benchmark ecosystem
5+
#
6+
7+
require_relative './blog6-setup.rb'
8+
require_relative '../../tool/jt.rb'
9+
10+
Blog6Setup.setup_bundler
11+
Blog6Setup.bundle_install
12+
13+
benchmark 'blog6-rails-routes' do
14+
Dir.chdir(Blog6Setup::BLOG6_DIR) do
15+
JT.ruby(*%w[-S bin/rails routes])
16+
end
17+
end

bench/rails/blog6-setup.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
require_relative '../../tool/jt.rb'
2+
require 'fileutils'
3+
4+
module Blog6Setup
5+
BLOG6_DIR = File.expand_path('../../../test/truffle/ecosystem/blog6', __FILE__)
6+
7+
def self.setup_bundler
8+
Dir.chdir(BLOG6_DIR) do
9+
FileUtils.cp 'Gemfile.lock.renamed', 'Gemfile.lock'
10+
gem_test_pack = JT.gem_test_pack
11+
JT.ruby(*%w[-S bundle config --local cache_path], "#{gem_test_pack}/gem-cache")
12+
JT.ruby(*%w[-S bundle config --local without postgresql mysql])
13+
JT.ruby(*%w[-S bundle config --local path vendor/bundle])
14+
end
15+
end
16+
17+
def self.bundle_install
18+
Dir.chdir(BLOG6_DIR) do
19+
JT.ruby(*%w[-S bundle install --local --no-cache])
20+
end
21+
end
22+
end

mx.truffleruby/mx_truffleruby_benchmark.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,13 +692,20 @@ def time(self):
692692
'rubykon/rubykon',
693693
]
694694

695+
blog6_benchmarks = [
696+
'rails/blog6-bundle-install',
697+
'rails/blog6-rails-routes',
698+
]
699+
695700
class WarmupBenchmarkSuite(AllBenchmarksBenchmarkSuite):
696701
def config(self):
697702
iterations = {
698703
'asciidoctor-convert': {10:'startup', 100:'early-warmup', 500:'late-warmup'},
699704
'asciidoctor-load-file': {10:'startup', 100:'early-warmup', 500:'late-warmup'},
700705
'asciidoctor-load-string': {10:'startup', 100:'early-warmup', 500:'late-warmup'},
701706
'rubykon': {1:'startup', 10:'early-warmup', 30:'late-warmup'},
707+
'blog6-bundle-install': {1:'single-shot'},
708+
'blog6-rails-routes': {1:'single-shot'},
702709
}
703710
return {'kind': 'fixed-iterations', 'iterations': iterations}
704711

@@ -709,7 +716,10 @@ def directory(self):
709716
return None
710717

711718
def benchmarkList(self, bmSuiteArgs):
712-
return warmup_benchmarks
719+
benchmarks = warmup_benchmarks[:]
720+
if os.environ.get('GUEST_VM') != "jruby":
721+
benchmarks.extend(blog6_benchmarks)
722+
return benchmarks
713723

714724
mx_benchmark.add_bm_suite(BuildStatsBenchmarkSuite())
715725
mx_benchmark.add_bm_suite(AllocationBenchmarkSuite())

tool/jt.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2596,6 +2596,15 @@ def visualvm
25962596
class JT
25972597
include Commands
25982598

2599+
def self.ruby(*args)
2600+
jt = JT.new
2601+
jt.send(:run_ruby, *args)
2602+
end
2603+
2604+
def self.gem_test_pack
2605+
JT.new.gem_test_pack
2606+
end
2607+
25992608
def main(args)
26002609
args = args.dup
26012610

0 commit comments

Comments
 (0)