Skip to content

Commit a937aac

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 a937aac

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# frozen_string_literal: true
22

33
require 'benchmark/ips'
4-
require 'benchmark'
54

65
if defined?(Faker)
7-
raise 'faker is defined before bench'
6+
puts 'faker is defined before running benchmark, undefining it'
7+
Object.send(:remove_const, :Faker)
88
end
99

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

benchmark/load_faker.rb

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

3-
if defined?(Faker)
4-
raise 'faker is already defined...'
5-
end
6-
73
load(File.expand_path("#{File.dirname(__FILE__)}/../lib/faker.rb"))

0 commit comments

Comments
 (0)