Class: Evilution::Runner::Diagnostics Private
- Inherits:
-
Object
- Object
- Evilution::Runner::Diagnostics
- Defined in:
- lib/evilution/runner/diagnostics.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
- #aggregate_worker_stats(stats) ⇒ Object private
- #format_memory_delta(delta_kb) ⇒ Object private
-
#initialize(config, stderr: $stderr) ⇒ Diagnostics
constructor
private
A new instance of Diagnostics.
- #log_memory(phase, context = nil) ⇒ Object private
- #log_mutation_diagnostics(result) ⇒ Object private
- #log_progress(current, status) ⇒ Object private
- #log_worker_stats(stats) ⇒ Object private
- #mutation_metric_parts(result) ⇒ Object private
Constructor Details
#initialize(config, stderr: $stderr) ⇒ Diagnostics
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Diagnostics.
8 9 10 11 |
# File 'lib/evilution/runner/diagnostics.rb', line 8 def initialize(config, stderr: $stderr) @config = config @stderr = stderr end |
Instance Method Details
#aggregate_worker_stats(stats) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/evilution/runner/diagnostics.rb', line 63 def aggregate_worker_stats(stats) return stats if stats.empty? stats.group_by(&:pid).map do |pid, entries| Evilution::Parallel::WorkQueue::WorkerStat.new( pid, entries.sum(&:items_completed), entries.sum(&:busy_time), entries.sum(&:wall_time) ) end end |
#format_memory_delta(delta_kb) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
49 50 51 52 |
# File 'lib/evilution/runner/diagnostics.rb', line 49 def format_memory_delta(delta_kb) sign = delta_kb.negative? ? "" : "+" format("delta: %<sign>s%<mb>.1f MB", sign: sign, mb: delta_kb / 1024.0) end |
#log_memory(phase, context = nil) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/evilution/runner/diagnostics.rb', line 13 def log_memory(phase, context = nil) return unless verbose? rss = Evilution::Memory.rss_mb return unless rss gc = gc_stats_string msg = format("[memory] %<phase>s: %<rss>.1f MB", phase: phase, rss: rss) ctx = [context, gc].compact.join(", ") msg += " (#{ctx})" unless ctx.empty? stderr.write("#{msg}\n") end |
#log_mutation_diagnostics(result) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
32 33 34 35 36 37 38 39 |
# File 'lib/evilution/runner/diagnostics.rb', line 32 def log_mutation_diagnostics(result) return unless verbose? parts = mutation_metric_parts(result) stderr.write("[verbose] #{result.mutation}: #{parts.join(", ")}\n") unless parts.empty? log_mutation_error(result) if result.error? end |
#log_progress(current, status) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
26 27 28 29 30 |
# File 'lib/evilution/runner/diagnostics.rb', line 26 def log_progress(current, status) return unless text_tty? stderr.write("mutation #{current} #{status}\n") end |
#log_worker_stats(stats) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
54 55 56 57 58 59 60 61 |
# File 'lib/evilution/runner/diagnostics.rb', line 54 def log_worker_stats(stats) return unless verbose? && stats.any? stats.each do |stat| pct = format("%.1f", stat.utilization * 100) stderr.write("[verbose] worker #{stat.pid}: #{stat.items_completed} items, utilization #{pct}%\n") end end |
#mutation_metric_parts(result) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
41 42 43 44 45 46 47 |
# File 'lib/evilution/runner/diagnostics.rb', line 41 def mutation_metric_parts(result) parts = [] parts << format("child_rss: %<mb>.1f MB", mb: result.child_rss_kb / 1024.0) if result.child_rss_kb parts << format_memory_delta(result.memory_delta_kb) if result.memory_delta_kb parts << gc_stats_string parts end |