Class: GroongaQueryLog::Command::CheckPerformanceRegression::Checker
- Inherits:
-
Object
- Object
- GroongaQueryLog::Command::CheckPerformanceRegression::Checker
- Defined in:
- lib/groonga-query-log/command/check-performance-regression.rb
Instance Method Summary collapse
- #check ⇒ Object
-
#initialize(old_statistics, new_statistics, output, threshold, target_queries) ⇒ Checker
constructor
A new instance of Checker.
Constructor Details
#initialize(old_statistics, new_statistics, output, threshold, target_queries) ⇒ Checker
Returns a new instance of Checker.
319 320 321 322 323 324 325 326 327 328 329 |
# File 'lib/groonga-query-log/command/check-performance-regression.rb', line 319 def initialize(old_statistics, new_statistics, output, threshold, target_queries) @old_statistics = old_statistics @new_statistics = new_statistics @output = output @threshold = threshold @target_queries = target_queries end |
Instance Method Details
#check ⇒ Object
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 |
# File 'lib/groonga-query-log/command/check-performance-regression.rb', line 331 def check old_statistics = filter_statistics(@old_statistics) new_statistics = filter_statistics(@new_statistics) old_queries = old_statistics.group_by(&:raw_command) new_queries = new_statistics.group_by(&:raw_command) query_statistics = [] old_queries.each_key do |query| query_statistic = QueryStatistic.new(query, old_queries[query], new_queries[query], @threshold) next unless query_statistic.slow? query_statistics << query_statistic end n_slow_queries = 0 n_target_operations = 0 n_slow_operations = 0 query_statistics.sort_by(&:ratio).each do |query_statistic| n_slow_queries += 1 @output.puts(<<-REPORT) Query: #{query_statistic.query} Mean (old): #{format_elapsed_time(query_statistic.old_elapsed_time)} Mean (new): #{format_elapsed_time(query_statistic.new_elapsed_time)} Diff: #{format_diff(query_statistic)} Operations: REPORT query_statistic.each_operation_statistic do |operation_statistic| n_target_operations += 1 next unless operation_statistic.slow? n_slow_operations += 1 index = operation_statistic.index name = operation_statistic.name context = operation_statistic.context label = [name, context].compact.join(" ") old_elapsed_time = operation_statistic.old_elapsed_time new_elapsed_time = operation_statistic.new_elapsed_time @output.puts(<<-REPORT) Operation[#{index}]: #{label} Mean (old): #{format_elapsed_time(old_elapsed_time)} Mean (new): #{format_elapsed_time(new_elapsed_time)} Diff: #{format_diff(operation_statistic)} REPORT end end n_all_queries = @old_statistics.size n_target_queries = old_queries.size n_old_cached_queries = count_cached_queries(@old_statistics) n_new_cached_queries = count_cached_queries(@new_statistics) @output.puts(<<-REPORT) Summary: Slow queries: #{format_summary(n_slow_queries, n_target_queries)} Slow operations: #{format_summary(n_slow_operations, n_target_operations)} Caches (old): #{format_summary(n_old_cached_queries, n_all_queries)} Caches (new): #{format_summary(n_new_cached_queries, n_all_queries)} REPORT true end |