From c307218d291d1e4a9ec91c2935ec6477da43fda7 Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <schaller@strw.leidenuniv.nl>
Date: Wed, 18 Mar 2020 11:50:27 +0100
Subject: [PATCH] Time the update of general quantities (e.g. cooling tables)

---
 src/engine.c             | 14 ++++++++++----
 tools/analyse_runtime.py |  1 +
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/engine.c b/src/engine.c
index 6a7e5cc267..8218be32f7 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -2496,15 +2496,17 @@ void engine_step(struct engine *e) {
     e->time_step = (e->ti_current - e->ti_old) * e->time_base;
   }
 
+  /*****************************************************/
+  /* OK, we now know what the next end of time-step is */
+  /*****************************************************/
+
+  const ticks tic_updates = getticks();
+
   /* Update the cooling function */
   if ((e->policy & engine_policy_cooling) ||
       (e->policy & engine_policy_temperature))
     cooling_update(e->cosmology, e->cooling_func, e->s);
 
-  /*****************************************************/
-  /* OK, we now know what the next end of time-step is */
-  /*****************************************************/
-
   /* Update the softening lengths */
   if (e->policy & engine_policy_self_gravity)
     gravity_props_update(e->gravity_properties, e->cosmology);
@@ -2514,6 +2516,10 @@ void engine_step(struct engine *e) {
     hydro_props_update(e->hydro_properties, e->gravity_properties,
                        e->cosmology);
 
+  if (e->verbose)
+    message("Updating global quantities took %.3f %s",
+            clocks_from_ticks(getticks() - tic_updates), clocks_getunit());
+
   /* Trigger a tree-rebuild if we passed the frequency threshold */
   if ((e->policy & engine_policy_self_gravity) &&
       ((double)e->g_updates_since_rebuild >
diff --git a/tools/analyse_runtime.py b/tools/analyse_runtime.py
index fa15e3d4a7..382d4ab5ca 100755
--- a/tools/analyse_runtime.py
+++ b/tools/analyse_runtime.py
@@ -98,6 +98,7 @@ labels = [
     ["engine_drift_top_multipoles:", 0],
     ["Communicating rebuild flag", 0],
     ["Writing step info to files", 0],
+    ["Updating general quantities", 0],
     ["task_dump_all:", 0],
     ["task_dump_stats:", 0],
     ["task_dump_active:", 0],
-- 
GitLab