diff --git a/src/TDB2.cpp b/src/TDB2.cpp index 2c5ed1b4a..21d03e014 100644 --- a/src/TDB2.cpp +++ b/src/TDB2.cpp @@ -1503,6 +1503,7 @@ void TDB2::revert () int TDB2::gc () { context.timer_gc.start (); + unsigned long load_start = context.timer_load.total (); // Allowed as a temporary override. if (context.config.getBoolean ("gc")) @@ -1611,7 +1612,11 @@ int TDB2::gc () // TODO Remove dangling dependencies } + // Stop and remove accumulated load time from the GC time, because they + // overlap. context.timer_gc.stop (); + context.timer_gc.subtract (context.timer_load.total () - load_start); + return 0; } diff --git a/src/Timer.cpp b/src/Timer.cpp index eb03ebb9f..6564c3777 100644 --- a/src/Timer.cpp +++ b/src/Timer.cpp @@ -105,4 +105,12 @@ unsigned long Timer::total () const } //////////////////////////////////////////////////////////////////////////////// +void Timer::subtract (unsigned long value) +{ + if (value > _total) + _total = 0; + else + _total -= value; +} +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/Timer.h b/src/Timer.h index 69777dc4f..8eb7cc616 100644 --- a/src/Timer.h +++ b/src/Timer.h @@ -44,6 +44,7 @@ public: void start (); void stop (); unsigned long total () const; + void subtract (unsigned long); private: std::string _description;