From 0db9c274aae8e0b01fceff69fe1c2f8c0d12a0fe Mon Sep 17 00:00:00 2001 From: Thorsten Ball Date: Tue, 23 Jan 2024 12:44:29 +0100 Subject: [PATCH 1/2] Make scripts/histogram ignore lines without frame duration Previously the script would choke on lines generated, for example, by `cargo run`. This just skips lines that don't contain `frame duration:`. Co-authored-by: Antonio --- script/histogram | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/histogram b/script/histogram index b9885fbc00..3a499066de 100755 --- a/script/histogram +++ b/script/histogram @@ -28,7 +28,7 @@ def parse_log_file(file_path): data = {'measurement': [], 'time': [], 'unit': [], 'log_file': []} with open(file_path, 'r') as file: for line in file: - if ':' not in line: + if 'duration:' not in line: continue parts = line.strip().split(': ') From 802a7f5b9e08822cc4154077cea1137fd8079fd8 Mon Sep 17 00:00:00 2001 From: Thorsten Ball Date: Tue, 23 Jan 2024 16:52:08 +0100 Subject: [PATCH 2/2] Print error message and skip line --- script/histogram | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/script/histogram b/script/histogram index 3a499066de..32db95134e 100755 --- a/script/histogram +++ b/script/histogram @@ -28,7 +28,7 @@ def parse_log_file(file_path): data = {'measurement': [], 'time': [], 'unit': [], 'log_file': []} with open(file_path, 'r') as file: for line in file: - if 'duration:' not in line: + if ':' not in line: continue parts = line.strip().split(': ') @@ -41,7 +41,8 @@ def parse_log_file(file_path): elif 'µs' in time_with_unit: time, unit = time_with_unit[:-2], 'µs' else: - raise ValueError(f"Invalid time unit in line: {line.strip()}") + # Print an error message if we can't parse the line and then continue with rest. + print(f'Error: Invalid time unit in line "{line.strip()}". Skipping.', file=sys.stderr) continue data['measurement'].append(measurement)