|
3 | 3 | from contextlib import contextmanager |
4 | 4 | from glob import glob, iglob |
5 | 5 | import lzma |
| 6 | +import numpy as np |
6 | 7 | import os |
7 | 8 | import os.path as osp |
8 | 9 | import pandas as pd # type: ignore |
@@ -369,7 +370,9 @@ def run_nsys_recipe(recipe, report_file, tmp_dir, output_queue): |
369 | 370 | if osp.isdir(full_path) or not osp.exists(full_path): |
370 | 371 | continue |
371 | 372 | output_queue.put((ofile, full_path, COMPRESS_NONE)) |
372 | | - print(f"{archive_name}: post-processing finished in {time.time()-start:.2f}s") |
| 373 | + print( |
| 374 | + f"{archive_name}: recipe post-processing finished in {time.time()-start:.2f}s" |
| 375 | + ) |
373 | 376 |
|
374 | 377 | def compress_and_archive(prefix, file, output_queue): |
375 | 378 | """ |
@@ -401,9 +404,25 @@ def run_nsys_stats_report(report, report_file, tmp_dir, output_queue): |
401 | 404 | ], |
402 | 405 | check=True, |
403 | 406 | ) |
404 | | - for ofile in iglob("report_" + report + ".csv", root_dir=tmp_dir): |
405 | | - compress_and_archive(tmp_dir, ofile, output_queue) |
406 | | - print(f"{archive_name}: post-processing finished in {time.time()-start:.2f}s") |
| 407 | + output_path = osp.join(tmp_dir, f"report_{report}.csv") |
| 408 | + |
| 409 | + # TODO: avoid the .csv indirection |
| 410 | + def keep_column(name): |
| 411 | + return name not in {"PID", "Lvl", "NameTree"} |
| 412 | + |
| 413 | + df = pd.read_csv( |
| 414 | + output_path, |
| 415 | + dtype={"RangeId": np.int32}, |
| 416 | + index_col="RangeId", |
| 417 | + usecols=keep_column, |
| 418 | + ) |
| 419 | + parquet_name = f"report_{report}.parquet" |
| 420 | + parquet_path = osp.join(tmp_dir, parquet_name) |
| 421 | + df.to_parquet(parquet_path) |
| 422 | + output_queue.put((parquet_name, parquet_path, COMPRESS_NONE)) |
| 423 | + print( |
| 424 | + f"{archive_name}: stats post-processing finished in {time.time()-start:.2f}s" |
| 425 | + ) |
407 | 426 |
|
408 | 427 | def save_device_stream_thread_names(tmp_dir, report, output_queue): |
409 | 428 | """ |
|
0 commit comments