From 382d94da9220c688f31607e41786100f55ae34ac Mon Sep 17 00:00:00 2001 From: Lionel GUEZ <guez@lmd.ens.fr> Date: Wed, 20 Apr 2022 13:28:47 +0200 Subject: [PATCH] Add timings --- cost_function.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/cost_function.py b/cost_function.py index d92408f5..6a5cd19d 100755 --- a/cost_function.py +++ b/cost_function.py @@ -78,6 +78,9 @@ def get_SHPC(array_d_ini, date_index): assert i_SHPC >= 1 return i_SHPC - 1 +t0 = time.perf_counter() +timings = open("timings.txt", "w") + if len(sys.argv) == 1: sys.exit("Required arguments: SHPC-directory [SHPC-directory] ...") @@ -100,8 +103,6 @@ delta_r_mean = -0.0094709 * 1000 #[m] delta_r_std = 8.6953 * 1000 # Load the graph_tool file: -t0 = time.perf_counter() -timings = open("timings.txt", "w") print('Loading graph...') g = graph_tool.Graph() @@ -110,15 +111,15 @@ try: except FileNotFoundError: g.load('segments.graphml') -t1 = time.perf_counter() print('Loading done...') print("Input graph:") print("Number of vertices:", g.num_vertices()) print("Number of edges:", g.num_edges()) print("Internal properties:") g.list_properties() +t1 = time.perf_counter() timings.write(f"loading: {t1 - t0} s\n") -timings.close() +t0 = t1 g.set_fast_edge_removal() g.vp['pos_first'] = g.new_vp('object') @@ -235,6 +236,9 @@ for n in g.vertices(): g.vp.first_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...") for edge in g.edges(): @@ -292,6 +296,12 @@ for edge in g.edges(): 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...") g.save('segments_cost_functions.gt') print('All done') +t1 = time.perf_counter() +timings.write(f"saving: {t1 - t0} s\n") +timings.close() -- GitLab