From 1980fa59ca24f2d687fc07fbee11e0342fad26a6 Mon Sep 17 00:00:00 2001 From: Lionel GUEZ <guez@lmd.ens.fr> Date: Wed, 12 Apr 2023 13:01:03 +0200 Subject: [PATCH] Write timings to separate file To ease comparison of runs. --- Trajectories/segments.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Trajectories/segments.py b/Trajectories/segments.py index 10191b0d..191b416b 100755 --- a/Trajectories/segments.py +++ b/Trajectories/segments.py @@ -21,6 +21,7 @@ if len(sys.argv) != 3: sys.exit("Required arguments: input-file output-file") if pathlib.Path(sys.argv[2]).suffix not in {".gt", ".graphml"}: sys.exit('Output file suffix must be ".gt" or ".graphml"') +timings_file = open("timings_segments.txt", "w") t0 = time.perf_counter() print('Loading edgelist file...') g = graph_tool.load_graph_from_csv(sys.argv[1], @@ -33,7 +34,7 @@ print("Number of edges:", g.num_edges()) print("Internal properties:") g.list_properties() t1 = time.perf_counter() -print(f'Loading done in {t1 - t0:.0f} s') +timings_file.write(f'Loading done in {t1 - t0:.0f} s\n') t0 = t1 # Processing: @@ -73,13 +74,13 @@ for v in g.vertices(): verts_to_del.append(v) t1 = time.perf_counter() -print(f'Done collapsing in {t1 - t0:.0f} s') +timings_file.write(f'Done collapsing in {t1 - t0:.0f} s\n') t0 = t1 print('Number of circumvented nodes:', len(verts_to_del)) print('Deleting circumvented nodes...') g.remove_vertex(verts_to_del, fast=True) t1 = time.perf_counter() -print(f"Done deleting in {t1 - t0:.0f} s") +timings_file.write(f"Done deleting in {t1 - t0:.0f} s\n") t0 = t1 print("Graph of segments:") print("Number of vertices:", g.num_vertices()) @@ -89,5 +90,6 @@ g.list_properties() print('Saving graph...') g.save(sys.argv[2]) t1 = time.perf_counter() -print(f'Done saving in {t1 - t0:.0f} s') +timings_file.write(f'Done saving in {t1 - t0:.0f} s\n') +timings_file.close() print("Everything is cool.") -- GitLab