2012-12-07 09:59:37 -05:00
|
|
|
module Mutant
|
|
|
|
class Reporter
|
|
|
|
|
|
|
|
# Stats gathered while reporter is running
|
|
|
|
class Stats
|
|
|
|
|
|
|
|
# Return subject count
|
|
|
|
#
|
|
|
|
# @return [Fixnum]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
2012-12-10 18:17:19 -05:00
|
|
|
attr_reader :subjects
|
2012-12-07 09:59:37 -05:00
|
|
|
|
|
|
|
# Return mutation count
|
|
|
|
#
|
|
|
|
# @return [Fixnum]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
2012-12-10 18:17:19 -05:00
|
|
|
attr_reader :mutations
|
|
|
|
|
|
|
|
# Return skip count
|
|
|
|
#
|
|
|
|
# @return [Fixnum]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
attr_reader :noop_fails
|
2012-12-07 09:59:37 -05:00
|
|
|
|
|
|
|
# Return kill count
|
|
|
|
#
|
|
|
|
# @return [Fixnum]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
2012-12-10 18:17:19 -05:00
|
|
|
attr_reader :kills
|
2012-12-07 09:59:37 -05:00
|
|
|
|
|
|
|
# Return mutation runtime
|
|
|
|
#
|
|
|
|
# @return [Float]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
attr_reader :time
|
|
|
|
|
|
|
|
def initialize
|
|
|
|
@start = Time.now
|
2012-12-10 18:17:19 -05:00
|
|
|
@noop_fails = @subjects = @mutations = @kills = @time = 0
|
2012-12-07 09:59:37 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def runtime
|
|
|
|
Time.now - @start
|
|
|
|
end
|
|
|
|
|
|
|
|
def subject
|
2012-12-10 18:17:19 -05:00
|
|
|
@subjects +=1
|
|
|
|
self
|
2012-12-07 09:59:37 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def alive
|
2012-12-10 18:17:19 -05:00
|
|
|
@mutations - @kills
|
|
|
|
end
|
|
|
|
|
|
|
|
def noop_fail(killer)
|
|
|
|
@noop_fails += 1
|
|
|
|
@time += killer.runtime
|
|
|
|
self
|
2012-12-07 09:59:37 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def killer(killer)
|
2012-12-10 18:17:19 -05:00
|
|
|
@mutations +=1
|
|
|
|
@kills +=1 unless killer.fail?
|
2012-12-07 09:59:37 -05:00
|
|
|
@time += killer.runtime
|
2012-12-10 18:17:19 -05:00
|
|
|
self
|
2012-12-07 09:59:37 -05:00
|
|
|
end
|
|
|
|
|
2012-12-10 18:17:19 -05:00
|
|
|
end
|
2012-12-07 09:59:37 -05:00
|
|
|
end
|
|
|
|
end
|