|
@@ -441,20 +441,27 @@ def write_total_runtime_to_file(
|
|
|
write_perf_entry_to_stream(
|
|
|
test_name, optimization_level, TOTAL_TIME_QUANTITY, total_runtime, perf_file)
|
|
|
|
|
|
-def parse_perf_data(file_name):
|
|
|
- """Parses the performance data in the given file."""
|
|
|
+def parse_perf_data_from_stream(input_stream):
|
|
|
+ """Parses performance data from the given stream."""
|
|
|
results = defaultdict(lambda: defaultdict(list))
|
|
|
- with open(file_name, 'r') as perf_file:
|
|
|
- for line in perf_file.readlines():
|
|
|
- test_name, optimization_level, quantity, result = line.strip().split(':')
|
|
|
- results[quantity][optimization_level].append((test_name, float(result)))
|
|
|
+ for line in input_stream.readlines():
|
|
|
+ test_name, optimization_level, quantity, result = line.strip().split(':')
|
|
|
+ results[quantity][optimization_level].append((test_name, float(result)))
|
|
|
return {
|
|
|
quantity: sorted(result_dict.items(), key=operator.itemgetter(0))
|
|
|
for quantity, result_dict in results.items()
|
|
|
}
|
|
|
|
|
|
+def parse_perf_data(file_name):
|
|
|
+ """Parses the performance data in the given file."""
|
|
|
+ if file_name is None:
|
|
|
+ return parse_perf_data_from_stream(sys.stdin)
|
|
|
+
|
|
|
+ with open(file_name, 'r') as perf_file:
|
|
|
+ return parse_perf_data_from_stream(perf_file)
|
|
|
+
|
|
|
def write_perf_data_to_stream(perf_data, output_stream):
|
|
|
- """Writes the given performance data to the given file."""
|
|
|
+ """Writes the given performance data to the given stream."""
|
|
|
for quantity, opt_level_dict in perf_data.items():
|
|
|
for opt_level, data_points in opt_level_dict:
|
|
|
for test_name, measurement in data_points:
|