Class: Gravitext::PerfTest::PrintListener
- Inherits:
-
Object
- Object
- Gravitext::PerfTest::PrintListener
show all
- Includes:
- CalcUtil
- Defined in:
- lib/gravitext-util/perftest.rb
Overview
Listen for various events from the Harness and print results to console
Constant Summary
Constants included
from CalcUtil
CalcUtil::NaN
Instance Method Summary
collapse
Methods included from CalcUtil
#latency_change, #throughput_change
Constructor Details
#initialize(out = $stdout) ⇒ PrintListener
Status is written via out << (default $stdout)
270
271
272
|
# File 'lib/gravitext-util/perftest.rb', line 270
def initialize( out = $stdout )
@out = out
end
|
Instance Method Details
#begin(harness, factories) ⇒ Object
274
275
276
277
278
|
# File 'lib/gravitext-util/perftest.rb', line 274
def begin( harness, factories )
@out << "Concurrent testing: #{harness.thread_count} threads."
new_line
@nwidth = ( factories.map { |f| f.name.length } << 4 ).max
end
|
#comparison_complete_run(executor, prior) ⇒ Object
318
319
320
|
# File 'lib/gravitext-util/perftest.rb', line 318
def comparison_complete_run( executor, prior )
print_result( executor, prior )
end
|
#comparison_next_series(harness) ⇒ Object
310
311
312
|
# File 'lib/gravitext-util/perftest.rb', line 310
def comparison_next_series( harness )
print_separator
end
|
#comparison_start_run(executor) ⇒ Object
314
315
316
|
# File 'lib/gravitext-util/perftest.rb', line 314
def comparison_start_run( executor )
print_result_start( executor )
end
|
#comparisons_begin(harness, run_counts) ⇒ Object
303
304
305
306
307
308
|
# File 'lib/gravitext-util/perftest.rb', line 303
def comparisons_begin( harness, run_counts )
@out << ( "Comparison runs (%d iterations):" %
[ harness.final_iterations ] )
new_line
end
|
#comparisons_end(harness, executor_sums) ⇒ Object
322
323
324
325
326
327
328
|
# File 'lib/gravitext-util/perftest.rb', line 322
def comparisons_end( harness, executor_sums )
print_separator( '=' )
executor_sums.each_index do |s|
print_result_start( executor_sums[s] )
print_result( executor_sums[s], ( executor_sums.first unless s.zero? ) )
end
end
|
#new_line ⇒ Object
330
331
332
|
# File 'lib/gravitext-util/perftest.rb', line 330
def new_line
@out << "\n"
end
|
334
335
336
337
338
339
340
341
342
343
344
345
346
347
|
# File 'lib/gravitext-util/perftest.rb', line 334
def
@out << ( "%-#{@nwidth}s %-6s %-7s %-6s %8s %10s(%6s) %-9s (%6s)" %
[ "Test",
"Count",
"Time",
"R Sum",
"~R Value",
"Throughput",
"Change",
"~Latency",
"Change" ] )
new_line
print_separator( '=' )
end
|
#print_result(exec, prior = nil, out = @out) ⇒ Object
360
361
362
363
364
365
366
367
368
369
370
371
|
# File 'lib/gravitext-util/perftest.rb', line 360
def print_result( exec, prior = nil, out = @out )
out << ( "%7s %6s %6s/r %6sr/s (%6s) %7s/r (%6s)" %
[ exec.duration,
Metric::format( exec.result_sum ),
Metric::format( exec.result_sum.to_f /
exec.runs_executed ),
Metric::format( exec.mean_throughput ),
Metric::format_difference( throughput_change(exec,prior) ),
exec.mean_latency,
Metric::format_difference( latency_change(exec,prior) ) ] )
new_line
end
|
#print_result_start(exec, out = @out) ⇒ Object
354
355
356
357
358
|
# File 'lib/gravitext-util/perftest.rb', line 354
def print_result_start( exec, out = @out )
out << ( "%-#{@nwidth}s %6s " %
[ exec.factory.name,
Metric::format( exec.runs_target ) ] )
end
|
#print_separator(char = '-') ⇒ Object
349
350
351
352
|
# File 'lib/gravitext-util/perftest.rb', line 349
def print_separator( char = '-' )
@out << ( char * ( @nwidth + 69 ) )
new_line
end
|
#warmup_complete_run(executor, prior) ⇒ Object
291
292
293
|
# File 'lib/gravitext-util/perftest.rb', line 291
def warmup_complete_run( executor, prior )
print_result( executor, prior )
end
|
#warmup_next_series(harness) ⇒ Object
295
296
297
|
# File 'lib/gravitext-util/perftest.rb', line 295
def warmup_next_series( harness )
print_separator
end
|
#warmup_start_run(executor) ⇒ Object
287
288
289
|
# File 'lib/gravitext-util/perftest.rb', line 287
def warmup_start_run( executor )
print_result_start( executor )
end
|
#warmups_begin(harness) ⇒ Object
280
281
282
283
284
285
|
# File 'lib/gravitext-util/perftest.rb', line 280
def warmups_begin( harness )
@out << ( "Warmup min %gs (change tolerance: %g) per test:" %
[ harness.warmup_total_target, harness.warmup_tolerance ] )
new_line
end
|
#warmups_end(final_executors) ⇒ Object
299
300
301
|
# File 'lib/gravitext-util/perftest.rb', line 299
def warmups_end( final_executors )
new_line
end
|