From 4afec90b7e4c45e8878c677ec77d4f8b1d522df9 Mon Sep 17 00:00:00 2001 From: KunoiSayami Date: Mon, 15 May 2023 01:59:43 +0800 Subject: feat(exp): Add analysis script Signed-off-by: KunoiSayami --- analysis0510.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 analysis0510.py (limited to 'analysis0510.py') diff --git a/analysis0510.py b/analysis0510.py new file mode 100755 index 0000000..b51fc8c --- /dev/null +++ b/analysis0510.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python +import argparse + + +def read_from_line(line: str) -> dict[str, int | float]: + ret = {} + if 'skip:' in line: + ret.update({'skip': int(line.split('skip:', 2)[1].split(',')[0])}) + ret.update({'sample': int(line.split('length:', 2)[1].split('|', 2)[0])}) + ret.update({'custom': float(line.split('custom time: ', 2)[1].split('time')[0])}) + ret.update({'normal': float(line.rsplit('time:', 2)[1])}) + return ret + + +def read(file: str) -> None: + items = {} + with open(file) as fin: + while s := fin.readline(): + element = read_from_line(s) + if (sample := element['sample']) not in items: + items.update({sample: []}) + items[sample].append(element) + print(items) + + +if __name__ == '__main__': + arg_ = argparse.ArgumentParser() + arg_.add_argument("file") + read(arg_.parse_args().file) -- cgit v1.3.1