Commit feac83ce authored by Petr Špaček's avatar Petr Špaček

msgdiff: create main function to make msgdiff importable

parent 30b9ec83
...@@ -277,30 +277,30 @@ def process_results(diff_generator): ...@@ -277,30 +277,30 @@ def process_results(diff_generator):
uniq[field] = collections.OrderedDict(uniq[field].most_common(20)) uniq[field] = collections.OrderedDict(uniq[field].most_common(20))
pprint(uniq) pprint(uniq)
target = 'kresd' def main():
ccriteria = ['opcode', 'rcode', 'flags', 'question', 'qname', 'qtype', 'answer'] #'authority', 'additional', 'edns'] target = 'kresd'
ccriteria = ['opcode', 'rcode', 'flags', 'question', 'qname', 'qtype', 'answer'] #'authority', 'additional', 'edns']
#ccriteria = ['opcode', 'rcode', 'flags', 'question', 'qname', 'qtype', 'answer', 'authority', 'additional', 'edns', 'nsid'] #ccriteria = ['opcode', 'rcode', 'flags', 'question', 'qname', 'qtype', 'answer', 'authority', 'additional', 'edns', 'nsid']
if False: if False:
dir_names = itertools.tee(find_querydirs(sys.argv[1]), 2) dir_names = itertools.tee(find_querydirs(sys.argv[1]), 2)
for d in dir_names: for d in dir_names:
print(d) print(d)
workdirs = itertools.islice(find_querydirs(sys.argv[1]), 100000) workdirs = itertools.islice(find_querydirs(sys.argv[1]), 100000)
print('diffs = {') print('diffs = {')
serial = False serial = False
if serial: if serial:
worker_init(ccriteria, target) worker_init(ccriteria, target)
process_results(map(compare_wrapper, workdirs)) process_results(map(compare_wrapper, workdirs))
else: else:
with pool.Pool(
processes=4,
initializer=worker_init,
initargs=(ccriteria, target)
) as p:
process_results(p.imap_unordered(compare_wrapper, workdirs, chunksize=100))
with pool.Pool(
processes=4,
initializer=worker_init,
initargs=(ccriteria, target)
) as p:
process_results(p.imap_unordered(compare_wrapper, workdirs, chunksize=100))
if __name__ == '__main__':
main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment