| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright 2015 The Chromium Authors. All rights reserved. | 2 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 '''Generate stats of CQ usage.''' | 5 '''Generate stats of CQ usage.''' |
| 6 | 6 |
| 7 import argparse | 7 import argparse |
| 8 import calendar | 8 import calendar |
| 9 import collections | 9 import collections |
| 10 import copy | 10 import copy |
| (...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 # Fetch and process each patchset log | 588 # Fetch and process each patchset log |
| 589 def get_patch_stats(patch_id): | 589 def get_patch_stats(patch_id): |
| 590 return derive_patch_stats(args, begin_date, end_date, patch_id) | 590 return derive_patch_stats(args, begin_date, end_date, patch_id) |
| 591 | 591 |
| 592 if args.seq or not args.thread_pool: | 592 if args.seq or not args.thread_pool: |
| 593 iterable = map(get_patch_stats, raw_patches) | 593 iterable = map(get_patch_stats, raw_patches) |
| 594 else: | 594 else: |
| 595 pool = ThreadPool(min(args.thread_pool, len(raw_patches))) | 595 pool = ThreadPool(min(args.thread_pool, len(raw_patches))) |
| 596 iterable = pool.imap_unordered(get_patch_stats, raw_patches) | 596 iterable = pool.imap_unordered(get_patch_stats, raw_patches) |
| 597 pool.close() | 597 pool.close() |
| 598 pool.join() |
| 598 | 599 |
| 599 patches, issues = set(), set() | 600 patches, issues = set(), set() |
| 600 for patch_id, pstats in iterable: | 601 for patch_id, pstats in iterable: |
| 601 # The pragma-no-cover statement below is needed due to some bug in coverage | 602 # The pragma-no-cover statement below is needed due to some bug in coverage |
| 602 # engine. When adding | 603 # engine. When adding |
| 603 # print 'foo' | 604 # print 'foo' |
| 604 # before continue-statement, coverage engine reports full coverage, while | 605 # before continue-statement, coverage engine reports full coverage, while |
| 605 # without it it reports missing branch coverage for if-statement and missing | 606 # without it it reports missing branch coverage for if-statement and missing |
| 606 # line coverage for continue-statement. | 607 # line coverage for continue-statement. |
| 607 # TODO(sergiyb): Fix coverage engine and remove this pragma. | 608 # TODO(sergiyb): Fix coverage engine and remove this pragma. |
| (...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1050 } | 1051 } |
| 1051 | 1052 |
| 1052 return try_job_stats | 1053 return try_job_stats |
| 1053 | 1054 |
| 1054 if args.seq or not args.thread_pool: | 1055 if args.seq or not args.thread_pool: |
| 1055 iterable = map(get_flakiness_stats, stats['patch_stats'].keys()) | 1056 iterable = map(get_flakiness_stats, stats['patch_stats'].keys()) |
| 1056 else: | 1057 else: |
| 1057 pool = ThreadPool(min(args.thread_pool, len(stats['patch_stats'].keys()))) | 1058 pool = ThreadPool(min(args.thread_pool, len(stats['patch_stats'].keys()))) |
| 1058 iterable = pool.imap_unordered( | 1059 iterable = pool.imap_unordered( |
| 1059 get_flakiness_stats, stats['patch_stats'].keys()) | 1060 get_flakiness_stats, stats['patch_stats'].keys()) |
| 1061 pool.close() |
| 1062 pool.join() |
| 1060 | 1063 |
| 1061 try_job_stats = {} | 1064 try_job_stats = {} |
| 1062 for result in iterable: | 1065 for result in iterable: |
| 1063 for master, builder in result.iterkeys(): | 1066 for master, builder in result.iterkeys(): |
| 1064 keys = ( | 1067 keys = ( |
| 1065 'total', | 1068 'total', |
| 1066 'flakes', | 1069 'flakes', |
| 1067 'infra_failures', | 1070 'infra_failures', |
| 1068 'compile_failures', | 1071 'compile_failures', |
| 1069 'test_failures', | 1072 'test_failures', |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1266 | 1269 |
| 1267 return stats | 1270 return stats |
| 1268 | 1271 |
| 1269 def main(): | 1272 def main(): |
| 1270 args = parse_args() | 1273 args = parse_args() |
| 1271 configure_session(args) | 1274 configure_session(args) |
| 1272 logger = logging.getLogger() | 1275 logger = logging.getLogger() |
| 1273 infra_libs.logs.process_argparse_options(args, logger) | 1276 infra_libs.logs.process_argparse_options(args, logger) |
| 1274 stats = acquire_stats(args) | 1277 stats = acquire_stats(args) |
| 1275 print_stats(args, stats) | 1278 print_stats(args, stats) |
| OLD | NEW |