summaryrefslogtreecommitdiffstats
path: root/src/util/timer.cpp
diff options
context:
space:
mode:
authorRJ Ryan <rryan@mixxx.org>2014-11-14 00:19:33 -0500
committerRJ Ryan <rryan@mixxx.org>2014-11-14 01:18:40 -0500
commit25a5fef18eadece78e65390f808abdd66e359796 (patch)
tree47cf3fd6b31face5706bb3c032ef822164459c65 /src/util/timer.cpp
parent0e6aeeeb947a675fa373a0fd9a7d08938d421523 (diff)
Add experiment modes for rapid development and testing.
- Adds a static Experiment class with a tri-state mode flag that indicates whether the experiment mode is OFF, BASE, or EXPERIMENT. - Adds an "Enable Base" and "Enable Experiment" option to the Developer menu (shown when in --developer mode) with the Ctrl+Shift+B and Ctrl+Shift+E global shortcuts. Each one toggles between OFF and BASE/EXPERIMENT so you can choose exactly what time spans you would like to collect in your base and experiment buckets. - Updates StatsManager to segment collected stats into a base and experiment bucket. This allows you to quickly measure the difference a code change has on relevant counters / timers within the same execution of Mixxx. This is useful for quickly enabling and disabling a code change without a re-compile/re-run cycle to get an anecdotal sense of how it "feels" as well as a quantified sense of how it differs in terms of stats Mixxx collects. All stats collected via the usual Counter/Timer/ScopedTimer/etc. tools are segmented into a BASE STATS and EXPERIMENT STATS section printed to the log on exit.
Diffstat (limited to 'src/util/timer.cpp')
-rw-r--r--src/util/timer.cpp23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/util/timer.cpp b/src/util/timer.cpp
index e4d53e3106..11fddb1323 100644
--- a/src/util/timer.cpp
+++ b/src/util/timer.cpp
@@ -1,8 +1,9 @@
#include "util/timer.h"
+#include "util/experiment.h"
Timer::Timer(const QString& key, Stat::ComputeFlags compute)
: m_key(key),
- m_compute(compute),
+ m_compute(Stat::experimentFlags(compute)),
m_running(false) {
}
@@ -15,7 +16,11 @@ int Timer::restart(bool report) {
if (m_running) {
int nsec = m_time.restart();
if (report) {
- Stat::track(m_key, Stat::DURATION_NANOSEC, m_compute, nsec);
+ // Ignore the report if it crosses the experiment boundary.
+ Experiment::Mode oldMode = Stat::modeFromFlags(m_compute);
+ if (oldMode == Experiment::mode()) {
+ Stat::track(m_key, Stat::DURATION_NANOSEC, m_compute, nsec);
+ }
}
return nsec;
} else {
@@ -27,7 +32,11 @@ int Timer::restart(bool report) {
int Timer::elapsed(bool report) {
int nsec = m_time.elapsed();
if (report) {
- Stat::track(m_key, Stat::DURATION_NANOSEC, m_compute, nsec);
+ // Ignore the report if it crosses the experiment boundary.
+ Experiment::Mode oldMode = Stat::modeFromFlags(m_compute);
+ if (oldMode == Experiment::mode()) {
+ Stat::track(m_key, Stat::DURATION_NANOSEC, m_compute, nsec);
+ }
}
return nsec;
}
@@ -57,9 +66,11 @@ void SuspendableTimer::go() {
int SuspendableTimer::elapsed(bool report) {
m_leapTime += m_time.elapsed();
if (report) {
- Stat::track(m_key, Stat::DURATION_NANOSEC, m_compute, m_leapTime);
+ // Ignore the report if it crosses the experiment boundary.
+ Experiment::Mode oldMode = Stat::modeFromFlags(m_compute);
+ if (oldMode == Experiment::mode()) {
+ Stat::track(m_key, Stat::DURATION_NANOSEC, m_compute, m_leapTime);
+ }
}
return m_leapTime;
}
-
-