diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c7438b7f2..0636f5035 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,7 @@ jobs: name: Base steps runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Check Whitespace run: git diff --check -- HEAD~1 ruby-spec: @@ -27,7 +27,7 @@ jobs: - os: macos-latest ruby: ruby-3.0 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} @@ -50,7 +50,7 @@ jobs: - os: macos-latest ruby: ruby-3.0 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 - uses: ruby/setup-ruby@v1 @@ -75,7 +75,7 @@ jobs: - os: macos-latest ruby: ruby-3.0 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} @@ -95,7 +95,7 @@ jobs: ruby: [ruby-3.0, ruby-3.1.2, ruby-3.1, ruby-3.2, ruby-3.3] os: [ubuntu-latest] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} @@ -111,7 +111,7 @@ jobs: ruby: [ruby-3.0, ruby-3.1.2, ruby-3.1, ruby-3.2, ruby-3.3] os: [ubuntu-latest] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} @@ -127,7 +127,7 @@ jobs: ruby: [ruby-3.0, ruby-3.1.2, ruby-3.1, ruby-3.2, ruby-3.3] os: [ubuntu-latest] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} @@ -143,7 +143,7 @@ jobs: ruby: [ruby-3.0, ruby-3.1.2, ruby-3.1, ruby-3.2, ruby-3.3] os: [ubuntu-latest] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} diff --git a/Changelog.md b/Changelog.md index bac14f8ed..9499a5fff 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,12 +1,15 @@ # v0.11.28 -* Fix CLI parsing issue where arguments given to `mutant environment` where silently ignored. - [#1416](https://github.com/mbj/mutant/pull/1416) +* [#1416](https://github.com/mbj/mutant/pull/1416) + Fix CLI parsing issue where arguments given to `mutant environment` where silently ignored. -* Change to report efficiency instead of overhead. +* [#1415](https://github.com/mbj/mutant/pull/1415) + Change to report efficiency instead of overhead. Efficiency is defined by `killtime / runtime`. - [#1415](https://github.com/mbj/mutant/pull/1415) +* [#1413](https://github.com/mbj/mutant/pull/1413) + + Add `Process.warmup` optimization for ruby-3.3+ which yields a noticable speed improvement. # v0.11.27 2023-12-01 diff --git a/lib/mutant/mutation/runner.rb b/lib/mutant/mutation/runner.rb index 701274f22..032615798 100644 --- a/lib/mutant/mutation/runner.rb +++ b/lib/mutant/mutation/runner.rb @@ -15,6 +15,8 @@ def self.call(env) def self.run_mutation_analysis(env) reporter = reporter(env) + env.world.process_warmup + env .record(:analysis) { run_driver(reporter, async_driver(env)) } .tap { |result| env.record(:report) { reporter.report(result) } } diff --git a/lib/mutant/world.rb b/lib/mutant/world.rb index 2677735eb..398b9623a 100644 --- a/lib/mutant/world.rb +++ b/lib/mutant/world.rb @@ -82,5 +82,9 @@ def deadline(allowed_time) def record(name, &block) recorder.record(name, &block) end + + def process_warmup + process.warmup if process.respond_to?(:warmup) + end end # World end # Mutant diff --git a/spec/unit/mutant/mutation/runner_spec.rb b/spec/unit/mutant/mutation/runner_spec.rb index 9b1a0c480..972eac2a9 100644 --- a/spec/unit/mutant/mutation/runner_spec.rb +++ b/spec/unit/mutant/mutation/runner_spec.rb @@ -8,7 +8,8 @@ let(:emit_mutation_worker_process_start) { instance_double(Proc) } let(:env_result) { instance_double(Mutant::Result::Env) } let(:reporter) { instance_double(Mutant::Reporter, delay: delay) } - let(:world) { fake_world } + let(:world) { instance_double(Mutant::World) } + let(:timer) { instance_double(Mutant::Timer) } let(:env) do instance_double( @@ -55,6 +56,7 @@ end before do + allow(world).to receive_messages(timer: timer) allow(world.timer).to receive_messages(now: 1.0) end @@ -70,6 +72,11 @@ def apply selector: :start, arguments: [env] }, + { + receiver: world, + selector: :process_warmup, + arguments: [] + }, { receiver: env, selector: :record, @@ -147,6 +154,11 @@ def apply selector: :start, arguments: [env] }, + { + receiver: world, + selector: :process_warmup, + arguments: [] + }, { receiver: env, selector: :record, diff --git a/spec/unit/mutant/world_spec.rb b/spec/unit/mutant/world_spec.rb index a3c308c8b..65eaaec1a 100644 --- a/spec/unit/mutant/world_spec.rb +++ b/spec/unit/mutant/world_spec.rb @@ -140,4 +140,43 @@ def apply end end end + + describe '#process_warmup' do + let(:process) { double(Process) } + + subject { super().with(process: process) } + + def apply + subject.process_warmup + end + + before do + allow(process).to receive_messages( + respond_to?: respond_to?, + warmup: process + ) + end + + context 'when process supports warmup' do + let(:respond_to?) { true } + + it 'performs warmup' do + apply + + expect(process).to have_received(:respond_to?).with(:warmup).ordered + expect(process).to have_received(:warmup).ordered + end + end + + context 'when process supports warmup' do + let(:respond_to?) { false } + + it 'performs warmup' do + apply + + expect(process).to have_received(:respond_to?).with(:warmup) + expect(process).to_not have_received(:warmup) + end + end + end end