Class: RubybenchRunner::RailsRunner
Constant Summary
Constants inherited
from BaseRunner
BaseRunner::COPY_FOLDERS, BaseRunner::DEFAULT_OPTS, BaseRunner::HELPERS_VERSION_FILE
Instance Attribute Summary
Attributes inherited from BaseRunner
#opts, #repo_path, #script_url
Instance Method Summary
collapse
Methods inherited from BaseRunner
#bundle_install, #check_dependencies, #copy_helpers, #create_tmpdir, #dest_dir, #download_script, #initialize, #possible_repo_path, #print_results, #process_results, #run, #run_benchmarks, #script_full_path, #script_name, #script_path, #set_repo_path, #setup_db, #write_gemfile
Instance Method Details
#benchmark_name ⇒ Object
29
30
31
|
# File 'lib/rubybench_runner/rails_runner.rb', line 29
def benchmark_name
@benchmark_name ||= "Rails"
end
|
#command ⇒ Object
3
4
5
6
7
8
9
|
# File 'lib/rubybench_runner/rails_runner.rb', line 3
def command
command = "RAILS_ENV=production #{super}"
if require_db?
command = "DATABASE_URL=#{database_url} #{command}"
end
command
end
|
#database_url ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/rubybench_runner/rails_runner.rb', line 15
def database_url
return @db_url if @db_url
raw_config = RubybenchRunner::Configurations.new
config = OpenStruct.new(raw_config[opts.db.to_sym])
url = "#{opts.db}://#{config.user}"
url += ":#{config.password}" if config.password
url += "@#{config.host}" if config.host
url += ":#{config.port}" if config.port
url += "/#{config.dbname}"
with_prep_statement = opts.wps == true
url += "?prepared_statements=#{with_prep_statement}"
@db_url = url
end
|
#gemfile_content ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/rubybench_runner/rails_runner.rb', line 33
def gemfile_content
@gemfile_content ||= " source 'https://rubygems.org'\n\n gem 'rails', path: '\#{@repo_path}'\n\n group :mysql do\n gem 'mysql2', '0.5.2'\n end\n group :postgres do\n gem 'pg', '1.1.4'\n end\n gem 'benchmark-ips', '~> 2.7.2'\n gem 'redis', '~> 4.1.2'\n gem 'puma', '~> 3.12.1'\n GEMFILE\nend\n"
|
#is_repo_path_valid? ⇒ Boolean
11
12
13
|
# File 'lib/rubybench_runner/rails_runner.rb', line 11
def is_repo_path_valid?
File.exists?(File.join(repo_path, "rails.gemspec"))
end
|
#require_db? ⇒ Boolean
55
56
57
58
59
60
61
62
63
|
# File 'lib/rubybench_runner/rails_runner.rb', line 55
def require_db?
filename = @script_url.split("/")[-1]
res = filename.match?(/activerecord|scaffold/)
if res && !opts.db
puts "This benchmark requires database to run. Please specify the `--db` option (see --help for details)"
exit 1
end
res
end
|
#save_dir ⇒ Object
51
52
53
|
# File 'lib/rubybench_runner/rails_runner.rb', line 51
def save_dir
@save_dir ||= File.join(dest_dir, "rails")
end
|