Skip to content
Snippets Groups Projects
Commit 1980fa59 authored by Lionel GUEZ's avatar Lionel GUEZ
Browse files

Write timings to separate file

To ease comparison of runs.
parent 13822dea
No related branches found
No related tags found
No related merge requests found
......@@ -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.")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment