opt-diff: Support splitting to multiple output files

When reading the resulting files back with opt-viewer, they will be parsed in
parallel.

llvm-svn: 326126
This commit is contained in:
Adam Nemet 2018-02-26 21:15:51 +00:00
parent f7778892d2
commit 9dea9b4918
1 changed files with 11 additions and 4 deletions

View File

@ -36,13 +36,19 @@ if __name__ == '__main__':
default=None,
type=int,
help='Max job count (defaults to %(default)s, the current CPU count)')
parser.add_argument(
'--max-size',
'-m',
default=100000,
type=int,
help='Maximum number of remarks stored in an output file')
parser.add_argument(
'--no-progress-indicator',
'-n',
action='store_true',
default=False,
help='Do not display any indicator of how many YAML files were read.')
parser.add_argument('--output', '-o', default='diff.opt.yaml')
parser.add_argument('--output', '-o', default='diff{}.opt.yaml')
args = parser.parse_args()
files1 = optrecord.find_opt_files(args.yaml_dir_or_file_1)
@ -60,9 +66,10 @@ if __name__ == '__main__':
for r in removed:
r.Added = False
result = added | removed
result = list(added | removed)
for r in result:
r.recover_yaml_structure()
with open(args.output, 'w') as stream:
yaml.dump_all(result, stream)
for i in range(0, len(result), args.max_size):
with open(args.output.format(i / args.max_size), 'w') as stream:
yaml.dump_all(result[i:i + args.max_size], stream)