Skip to content

Commit 0fee19a

Browse files
authored
Promote the rubybench_runner gem (#266)
1 parent 69034c1 commit 0fee19a

File tree

6 files changed

+51
-0
lines changed

6 files changed

+51
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.instructions-list {
2+
li {
3+
margin: 15px 0;
4+
}
5+
}

app/helpers/repos_helper.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module ReposHelper
2+
def show_gem_tip
3+
@repo &&
4+
@repo.name == 'rails' &&
5+
@benchmark &&
6+
@benchmark.category !~ /^discourse_/
7+
end
8+
end

app/views/repos/_script.html.haml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
- if script_url = benchmark.script_url
2+
- if show_gem_tip
3+
%h4.l-align-center
4+
!= t('repos.run_locally_tip', path: run_locally_path)
25
%h2.l-align-center
36
= t('repos.script_title', graph_name: benchmark.category.humanize)
47

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.container
2+
.row
3+
.col-md-10.col-md-offset-1
4+
%h1= t('static_pages.run_locally.title')
5+
!= t('static_pages.run_locally.instructions')

config/locales/en.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ en:
3030
"%{category}" does not have any results. Please select another
3131
Benchmark Type.
3232
view_github: View on Github
33+
run_locally_tip: You can run this benchmark locally using the <code>rubybench_runner</code> gem. More details <a href="%{path}">here</a>.
3334

3435
index:
3536
commits_benchmark: Commits Benchmarks
@@ -78,6 +79,34 @@ en:
7879
desc: 'Script to set up new bare metal servers.'
7980
sponsors:
8081
title: Sponsors
82+
run_locally:
83+
title: Run locally
84+
instructions: |
85+
The <a href="https://rubygems.org/gems/rubybench_runner">rubybench_runner</a> gem allows you to run the benchmarks locally. Note the gem is still under development and it's currently limited to the Rails benchmarks. Here is how you can use it:
86+
<ul class="instructions-list">
87+
<li>Install the gem:
88+
<pre>gem install rubybench_runner</pre>
89+
</li>
90+
<li>Clone the Rails repository:
91+
<pre>git clone https://github.com/rails/rails.git</pre>
92+
</li>
93+
<li>Pick one of the <a href="https://rubybench.org/rails/rails/commits">available rails benchmarks</a> and copy the GitHub link of the script (it's the "View on Github" button).</li>
94+
<li>Run:
95+
<pre>rubybench_runner run rails &lt;script_url&gt; &lt;path_to_rails_clone&gt;</pre>
96+
</li>
97+
<li>If the benchmark requires a database server, then you need to specify the <code>--db</code> option. Run <code>rubybench_runner --help</code> for details.</li>
98+
</ul>
99+
<h3>Database server requirement</h3>
100+
Scripts that contain <code>activerecord</code> or <code>scaffold</code> in their names are the scripts that require a database server. Supported database servers are PostgreSQL and MySQL.
101+
<br>
102+
<br>
103+
If the benchmark you want to run requires a database server, then depending on the <code>--db</code> option that you specified, the gem will install either the <code>pg</code> or <code>mysql2</code> gems which require some packages to be installed on your system. For the <code>mysql2</code> gem, you can see the required packages <a href="https://github.com/brianmario/mysql2#configuration-options">in their README</a>. For the <code>pg</code> gem, you'll need to install the <code>postgresql</code> and <code>libpq-dev</code> packages using your system package manager. On Ubuntu that would be <code>sudo apt-get install postgresql libpq-dev</code>.
104+
<br>
105+
<h3>Configurations</h3>
106+
On the first run the gem will create a file called <code>.rubybench_runner_config</code> in your home directory. This file allows you to configure the name of the database that the gem will create to run the benchmarks, as well as the database user, host and port. If you have the database server running locally and it's configured to allow peer authentication, then you shouldn't need to change anything in this file (unless you want to change the database name which defaults to <code>rubybench</code>). Note that the database user must have sufficient privileges to create a database on the server.
107+
<br>
108+
<h3>Feedback</h3>
109+
If you want to report an issue in the gem, propose a feature or suggest an improvment to this guide, feel free to post at <a href="https://community.rubybench.org/">community.rubybench.org</a>.
81110
82111
top_nav:
83112
logo: RubyBench

config/routes.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
get 'hardware' => 'static_pages#hardware'
1717
get 'contributing' => 'static_pages#contribute', as: :contribute
1818
get 'sponsors' => 'static_pages#sponsors', as: :sponsors
19+
get 'run-locally' => 'static_pages#run_locally', as: :run_locally
1920
get 'benchmarks' => 'organizations#index'
2021
get ':organization_name/:repo_name/commits/overview' => 'repos#index', as: :overview
2122
get ':organization_name/:repo_name/commits' => 'repos#commits', as: :commits

0 commit comments

Comments
 (0)