diff options
| author | KunoiSayami <[email protected]> | 2023-06-20 04:50:45 +0800 |
|---|---|---|
| committer | KunoiSayami <[email protected]> | 2023-06-20 04:50:45 +0800 |
| commit | 4c9b48fc37bef199b20ee58aad34df62676b9091 (patch) | |
| tree | a3ba5bcd2e48258a28b291fc40e1d9d820446f0d /analysis0617.py | |
| parent | 14e6ffcc19a47e79325fcf18778c443473ed775b (diff) | |
feat(exp): Add new analysis script
Signed-off-by: KunoiSayami <[email protected]>
Diffstat (limited to 'analysis0617.py')
| -rwxr-xr-x | analysis0617.py | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/analysis0617.py b/analysis0617.py index 2e1fe7a..4555c3d 100755 --- a/analysis0617.py +++ b/analysis0617.py @@ -14,15 +14,15 @@ async def grab_output(p: asyncio.subprocess.Process) -> float | None: return float(out.rsplit(':')[-1]) -async def run_custom_exec(p_s: str, sample: int, search: int, insertion: int, total_row: str) -> float | None: - p = (await asyncio.create_subprocess_exec(p_s, str(sample), str(search), str(insertion), total_row, +async def run_custom_exec(p_s: str, sample: int, search: int, insertion: int, total_row: int) -> float | None: + p = (await asyncio.create_subprocess_exec(p_s, str(sample), str(search), str(insertion), str(total_row), stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.STDOUT)) await p.wait() return await grab_output(p) -async def run_exec(p_s: str, search: int, insertion: int, total_row: str) -> float | None: - p = await asyncio.create_subprocess_exec(p_s, str(search), str(insertion), total_row, +async def run_exec(p_s: str, search: int, insertion: int, total_row: int) -> float | None: + p = await asyncio.create_subprocess_exec(p_s, str(search), str(insertion), str(total_row), stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.STDOUT) await p.wait() return await grab_output(p) @@ -97,9 +97,17 @@ async def main(matches: argparse.Namespace) -> None: total_run += 4 - retries result[sample][search]['normal'].append(normal) result[sample][search]['custom'].append(custom) - print(fault_run, '/', total_run) - print(result) - print(analysis(result)) + if matches.output is None: + print(fault_run, '/', total_run) + print(result) + print(analysis(result)) + else: + with open(matches.output, 'w') as fout: + fout.write(f'{fault_run} / {total_run}\n') + fout.write(str(result)) + fout.write('\n') + fout.write(str(analysis(result))) + fout.write('\n') if __name__ == '__main__': @@ -111,8 +119,9 @@ if __name__ == '__main__': run_.add_argument("exec2") run_.add_argument("sample_limit") run_.add_argument("limit") - run_.add_argument("--total-row", default=0) - run_.add_argument("--test-times", default=3) + run_.add_argument('--output', default=None) + run_.add_argument("--total-row", default=0, type=int) + run_.add_argument("--test-times", default=3, type=int) parser_ = arg_.parse_args() if parser_.sub == 'run': asyncio.run(main(parser_)) |
