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

Add timings

parent 738166b7
No related branches found
No related tags found
No related merge requests found
...@@ -78,6 +78,9 @@ def get_SHPC(array_d_ini, date_index): ...@@ -78,6 +78,9 @@ def get_SHPC(array_d_ini, date_index):
assert i_SHPC >= 1 assert i_SHPC >= 1
return i_SHPC - 1 return i_SHPC - 1
t0 = time.perf_counter()
timings = open("timings.txt", "w")
if len(sys.argv) == 1: if len(sys.argv) == 1:
sys.exit("Required arguments: SHPC-directory [SHPC-directory] ...") sys.exit("Required arguments: SHPC-directory [SHPC-directory] ...")
...@@ -100,8 +103,6 @@ delta_r_mean = -0.0094709 * 1000 #[m] ...@@ -100,8 +103,6 @@ delta_r_mean = -0.0094709 * 1000 #[m]
delta_r_std = 8.6953 * 1000 delta_r_std = 8.6953 * 1000
# Load the graph_tool file: # Load the graph_tool file:
t0 = time.perf_counter()
timings = open("timings.txt", "w")
print('Loading graph...') print('Loading graph...')
g = graph_tool.Graph() g = graph_tool.Graph()
...@@ -110,15 +111,15 @@ try: ...@@ -110,15 +111,15 @@ try:
except FileNotFoundError: except FileNotFoundError:
g.load('segments.graphml') g.load('segments.graphml')
t1 = time.perf_counter()
print('Loading done...') print('Loading done...')
print("Input graph:") print("Input graph:")
print("Number of vertices:", g.num_vertices()) print("Number of vertices:", g.num_vertices())
print("Number of edges:", g.num_edges()) print("Number of edges:", g.num_edges())
print("Internal properties:") print("Internal properties:")
g.list_properties() g.list_properties()
t1 = time.perf_counter()
timings.write(f"loading: {t1 - t0} s\n") timings.write(f"loading: {t1 - t0} s\n")
timings.close() t0 = t1
g.set_fast_edge_removal() g.set_fast_edge_removal()
g.vp['pos_first'] = g.new_vp('object') g.vp['pos_first'] = g.new_vp('object')
...@@ -235,6 +236,9 @@ for n in g.vertices(): ...@@ -235,6 +236,9 @@ for n in g.vertices():
g.vp.first_av_rad[n] = radii g.vp.first_av_rad[n] = radii
g.vp.last_av_rad[n] = radii g.vp.last_av_rad[n] = radii
t1 = time.perf_counter()
timings.write(f"iterating on vertices: {t1 - t0} s\n")
t0 = t1
print("Iterating on edges...") print("Iterating on edges...")
for edge in g.edges(): for edge in g.edges():
...@@ -292,6 +296,12 @@ for edge in g.edges(): ...@@ -292,6 +296,12 @@ for edge in g.edges():
g.ep.nl_cost_function[edge] = cf g.ep.nl_cost_function[edge] = cf
t1 = time.perf_counter()
timings.write(f"iterating on edges: {t1 - t0} s\n")
t0 = t1
print("Saving...") print("Saving...")
g.save('segments_cost_functions.gt') g.save('segments_cost_functions.gt')
print('All done') print('All done')
t1 = time.perf_counter()
timings.write(f"saving: {t1 - t0} s\n")
timings.close()
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