From 259f39f2d295d8d0dd28952fbdfb57db4045d817 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Mon, 20 Feb 2012 09:26:52 -0500 Subject: [PATCH] Performance - Corrected performance measurement. The TDB2::gc requires data to be loaded first, but load time is measured separately. This resulted in repeat counting. Now the gc time subtracts any load time that is accumulated *during* the gc. This is now a fair accounting of the time. --- src/TDB2.cpp | 5 +++++ src/Timer.cpp | 8 ++++++++ src/Timer.h | 1 + 3 files changed, 14 insertions(+) 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;