Skip to content

Commit 0d24c5e

Browse files
Create benchmark workflow
Run a benchmark as part of our CI to ensure new code does not degrade performance.
1 parent f7a8e72 commit 0d24c5e

File tree

3 files changed

+27
-6
lines changed

3 files changed

+27
-6
lines changed

.github/workflows/bench.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Bench
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
name: Benchmarks
13+
steps:
14+
- uses: actions/checkout@v6
15+
- uses: ruby/setup-ruby@v1
16+
with:
17+
ruby-version: '3.4'
18+
- name: Install dependencies
19+
run: bundle install
20+
21+
- name: Generators benchmark
22+
run: RUBYOPT="-W0" bundle exec ruby benchmark/generators.rb
23+
- name: Load benchmark
24+
run: RUBYOPT="-W0" bundle exec ruby benchmark/load.rb
25+
- name: YML vs JSON benchmark
26+
run: RUBYOPT="-W0" bundle exec ruby benchmark/load_yml_vs_json.rb

benchmark/load.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
# frozen_string_literal: true
22

33
require 'benchmark/ips'
4-
require 'benchmark'
5-
6-
if defined?(Faker)
7-
raise 'faker is defined before bench'
8-
end
94

105
path = File.expand_path("#{File.dirname(__FILE__)}/load_faker.rb")
116

benchmark/load_faker.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

33
if defined?(Faker)
4-
raise 'faker is already defined...'
4+
raise 'faker is defined before load'
55
end
66

77
load(File.expand_path("#{File.dirname(__FILE__)}/../lib/faker.rb"))

0 commit comments

Comments
 (0)