Fix progressive report slowdown
This commit is contained in:
parent
1b9a892607
commit
d49cee7d5c
10 changed files with 109 additions and 28 deletions
|
@ -1,6 +1,7 @@
|
|||
# v0.7.2 2014-12-06
|
||||
# v0.7.2 2014-12-08
|
||||
|
||||
* Fix synthetic race conditon in actor implementation
|
||||
* Fix progressive reporter slowdown
|
||||
|
||||
# v0.7.1 2014-12-04
|
||||
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
---
|
||||
threshold: 18
|
||||
total_score: 1164
|
||||
total_score: 1200
|
||||
|
|
|
@ -141,6 +141,7 @@ UtilityFunction:
|
|||
- Mutant::AST::Sexp#s
|
||||
- Mutant::CLI#reporter
|
||||
- Mutant::Integration::Rspec#parse_example
|
||||
- Mutant::Meta::Example::Verification#format_mutation # False positive, its a utility
|
||||
- Mutant::Meta::Example::Verification#format_mutation
|
||||
- Mutant::Reporter::CLI::Format::Progressive#new_buffer
|
||||
- Mutant::Reporter::CLI::Printer::StatusProgressive#object # False positive calls super
|
||||
max_helper_calls: 0
|
||||
|
|
|
@ -51,6 +51,23 @@ module Mutant
|
|||
self
|
||||
end
|
||||
|
||||
# Return report delay in seconds
|
||||
#
|
||||
# TODO: Move this to a callback registration
|
||||
#
|
||||
# Reporters other than CLI that might exist in futures
|
||||
# may only the final report. So providing a noop callback
|
||||
# registration makes more sense than. As only CLI reporters
|
||||
# exist currently I do not really care right now.
|
||||
#
|
||||
# @return [Float]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def delay
|
||||
format.delay
|
||||
end
|
||||
|
||||
# Report warning
|
||||
#
|
||||
# @param [String] message
|
||||
|
|
|
@ -25,6 +25,16 @@ module Mutant
|
|||
#
|
||||
abstract_method :progress
|
||||
|
||||
# Return report delay in seconds
|
||||
#
|
||||
# @return [Float]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def delay
|
||||
self.class::REPORT_DELAY
|
||||
end
|
||||
|
||||
# Output abstraction to decouple tty? from buffer
|
||||
class Output
|
||||
include Concord.new(:tty, :buffer)
|
||||
|
@ -67,17 +77,8 @@ module Mutant
|
|||
# Format for progressive non rewindable output
|
||||
class Progressive < self
|
||||
|
||||
# Initialize object
|
||||
#
|
||||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def initialize(*)
|
||||
@seen = Set.new
|
||||
|
||||
super
|
||||
end
|
||||
REPORT_FREQUENCY = 1.0
|
||||
REPORT_DELAY = 1 / REPORT_FREQUENCY
|
||||
|
||||
# Return start representation
|
||||
#
|
||||
|
@ -96,12 +97,7 @@ module Mutant
|
|||
# @api private
|
||||
#
|
||||
def progress(status)
|
||||
current = status.env_result.subject_results.flat_map(&:mutation_results)
|
||||
new = current.reject(&@seen.method(:include?))
|
||||
@seen = current.to_set
|
||||
new.map do |mutation_result|
|
||||
format(Printer::MutationProgressResult, mutation_result)
|
||||
end.join(EMPTY_STRING)
|
||||
format(Printer::StatusProgressive, status)
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -124,6 +120,9 @@ module Mutant
|
|||
|
||||
BUFFER_FLAGS = 'a+'.freeze
|
||||
|
||||
REPORT_FREQUENCY = 20.0
|
||||
REPORT_DELAY = 1 / REPORT_FREQUENCY
|
||||
|
||||
# Format start
|
||||
#
|
||||
# @param [Env] env
|
||||
|
|
|
@ -341,6 +341,54 @@ module Mutant
|
|||
|
||||
end # MutationProgressResult
|
||||
|
||||
# Reporter for progressive output format on scheduler Status objects
|
||||
class StatusProgressive < self
|
||||
|
||||
FORMAT = '(%02d/%02d) %3d%% - killtime: %0.02fs runtime: %0.02fs overhead: %0.02fs'.freeze
|
||||
|
||||
delegate(
|
||||
:coverage,
|
||||
:runtime,
|
||||
:amount_mutations_killed,
|
||||
:amount_mutations,
|
||||
:amount_mutation_results,
|
||||
:killtime,
|
||||
:overhead
|
||||
)
|
||||
|
||||
# Run printer
|
||||
#
|
||||
# @return [self]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def run
|
||||
status(
|
||||
FORMAT,
|
||||
amount_mutations_killed,
|
||||
amount_mutations,
|
||||
coverage * 100,
|
||||
killtime,
|
||||
runtime,
|
||||
overhead
|
||||
)
|
||||
|
||||
self
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Return object being printed
|
||||
#
|
||||
# @return [Result::Env]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def object
|
||||
super().env_result
|
||||
end
|
||||
end
|
||||
|
||||
# Reporter for subject progress
|
||||
class SubjectProgress < self
|
||||
|
||||
|
|
|
@ -21,6 +21,18 @@ module Mutant
|
|||
end
|
||||
end
|
||||
|
||||
REPORT_DELAY = 0.0
|
||||
|
||||
# Return report delay
|
||||
#
|
||||
# @return [Float]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def delay
|
||||
REPORT_DELAY
|
||||
end
|
||||
|
||||
end # Tracker
|
||||
end # reporter
|
||||
end # Mutant
|
||||
|
|
|
@ -22,9 +22,6 @@ module Mutant
|
|||
include Adamantium::Flat, Anima.new(:job, :result)
|
||||
end
|
||||
|
||||
REPORT_FREQUENCY = 20.0
|
||||
REPORT_DELAY = 1 / REPORT_FREQUENCY
|
||||
|
||||
# Initialize object
|
||||
#
|
||||
# @return [undefined]
|
||||
|
@ -45,7 +42,7 @@ module Mutant
|
|||
status = current_status
|
||||
break if status.done
|
||||
reporter.progress(status)
|
||||
Kernel.sleep(REPORT_DELAY)
|
||||
Kernel.sleep(reporter.delay)
|
||||
end
|
||||
|
||||
reporter.progress(status)
|
||||
|
|
|
@ -85,6 +85,12 @@ RSpec.describe Mutant::Reporter::CLI do
|
|||
it_reports("message\n")
|
||||
end
|
||||
|
||||
describe '#delay' do
|
||||
subject { object.delay }
|
||||
|
||||
it { should eql(0.05) }
|
||||
end
|
||||
|
||||
describe '#start' do
|
||||
subject { object.start(env) }
|
||||
|
||||
|
@ -116,19 +122,19 @@ RSpec.describe Mutant::Reporter::CLI do
|
|||
context 'with empty scheduler' do
|
||||
update(:env_result) { { subject_results: [] } }
|
||||
|
||||
it_reports ''
|
||||
it_reports "(00/02) 0% - killtime: 0.00s runtime: 4.00s overhead: 4.00s\n"
|
||||
end
|
||||
|
||||
context 'with last mutation present' do
|
||||
update(:env_result) { { subject_results: [subject_a_result] } }
|
||||
|
||||
context 'when mutation is successful' do
|
||||
it_reports '..'
|
||||
it_reports "(02/02) 100% - killtime: 2.00s runtime: 4.00s overhead: 2.00s\n"
|
||||
end
|
||||
|
||||
context 'when mutation is NOT successful' do
|
||||
update(:mutation_a_test_result) { { passed: true } }
|
||||
it_reports 'F.'
|
||||
it_reports "(01/02) 50% - killtime: 2.00s runtime: 4.00s overhead: 2.00s\n"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -49,7 +49,7 @@ RSpec.describe Mutant::Runner do
|
|||
let(:incomplete_status) { status.update(done: false) }
|
||||
|
||||
before do
|
||||
expect(Kernel).to receive(:sleep).with(1 / 20.0).exactly(2).times.ordered
|
||||
expect(Kernel).to receive(:sleep).with(0.0).exactly(2).times.ordered
|
||||
|
||||
current_sender = actor_env.mailbox(:current).sender
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue