summaryrefslogtreecommitdiffstats
path: root/src/debug
diff options
context:
space:
mode:
authorMenTaLguY <mental@rydia.net>2008-07-08 19:16:01 +0000
committermental <mental@users.sourceforge.net>2008-07-08 19:16:01 +0000
commit5621aed042ec29e9606b2bdce44a1f42f61c8e6b (patch)
treebc37f3fce13514460ab4f87a9aaad8862beeced3 /src/debug
parentdisable motion hints again; still some subtle issues to work out (diff)
downloadinkscape-5621aed042ec29e9606b2bdce44a1f42f61c8e6b.tar.gz
inkscape-5621aed042ec29e9606b2bdce44a1f42f61c8e6b.zip
instrument event latency
(bzr r6231)
Diffstat (limited to 'src/debug')
-rw-r--r--src/debug/CMakeLists.txt1
-rw-r--r--src/debug/Makefile_insert1
-rw-r--r--src/debug/gdk-event-latency-tracker.cpp65
-rw-r--r--src/debug/gdk-event-latency-tracker.h52
4 files changed, 119 insertions, 0 deletions
diff --git a/src/debug/CMakeLists.txt b/src/debug/CMakeLists.txt
index 88c8b8e29..5eb0b3cfe 100644
--- a/src/debug/CMakeLists.txt
+++ b/src/debug/CMakeLists.txt
@@ -5,5 +5,6 @@ log-display-config.cpp
logger.cpp
sysv-heap.cpp
timestamp.cpp
+gdk-event-latency-tracker.cpp
)
diff --git a/src/debug/Makefile_insert b/src/debug/Makefile_insert
index 96a12f3f4..699ceac84 100644
--- a/src/debug/Makefile_insert
+++ b/src/debug/Makefile_insert
@@ -14,5 +14,6 @@ debug_libinkdebug_a_SOURCES = \
debug/log-display-config.cpp debug/log-display-config.h \
debug/simple-event.h \
debug/sysv-heap.cpp debug/sysv-heap.h \
+ debug/gdk-event-latency-tracker.cpp debug/gdk-event-latency-tracker.h \
debug/timestamp.cpp debug/timestamp.h
diff --git a/src/debug/gdk-event-latency-tracker.cpp b/src/debug/gdk-event-latency-tracker.cpp
new file mode 100644
index 000000000..8e34d2fc2
--- /dev/null
+++ b/src/debug/gdk-event-latency-tracker.cpp
@@ -0,0 +1,65 @@
+/*
+ * Inkscape::Debug::GdkEventLatencyTracker - tracks backlog of GDK events
+ *
+ * Authors:
+ * MenTaLguY <mental@rydia.net>
+ *
+ * Copyright (C) 2008 MenTaLguY
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "debug/gdk-event-latency-tracker.h"
+
+namespace Inkscape {
+namespace Debug {
+
+GdkEventLatencyTracker::GdkEventLatencyTracker()
+: start_seconds(0.0), max_latency(0.0)
+{
+ elapsed.stop();
+ elapsed.reset();
+}
+
+boost::optional<double> GdkEventLatencyTracker::process(GdkEvent const *event) {
+ guint32 const timestamp=gdk_event_get_time(const_cast<GdkEvent *>(event));
+ if (timestamp == GDK_CURRENT_TIME) {
+ return boost::optional<double>();
+ }
+ double const timestamp_seconds = timestamp / 1000.0;
+
+ if (start_seconds == 0.0) {
+ elapsed.start();
+ start_seconds = timestamp_seconds;
+ return boost::optional<double>(0.0);
+ } else {
+ double const current_seconds = elapsed.elapsed() + start_seconds;
+ double delta = current_seconds - timestamp_seconds;
+ if (delta < 0.0) {
+ start_seconds += -delta;
+ delta = 0.0;
+ } else if (delta > max_latency) {
+ max_latency = delta;
+ }
+ return boost::optional<double>(delta);
+ }
+}
+
+GdkEventLatencyTracker &GdkEventLatencyTracker::default_tracker() {
+ static GdkEventLatencyTracker tracker;
+ return tracker;
+}
+
+}
+}
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
diff --git a/src/debug/gdk-event-latency-tracker.h b/src/debug/gdk-event-latency-tracker.h
new file mode 100644
index 000000000..8a22fec82
--- /dev/null
+++ b/src/debug/gdk-event-latency-tracker.h
@@ -0,0 +1,52 @@
+/*
+ * Inkscape::Debug::GdkEventLatencyTracker - tracks backlog of GDK events
+ *
+ * Authors:
+ * MenTaLguY <mental@rydia.net>
+ *
+ * Copyright (C) 2008 MenTaLguY
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#ifndef SEEN_INKSCAPE_DEBUG_GDK_EVENT_LATENCY_TRACKER_H
+#define SEEN_INKSCAPE_DEBUG_GDK_EVENT_LATENCY_TRACKER_H
+
+#include <gdk/gdkevents.h>
+#include <glibmm/timer.h>
+#include <boost/optional.hpp>
+
+namespace Inkscape {
+namespace Debug {
+
+class GdkEventLatencyTracker {
+public:
+ GdkEventLatencyTracker();
+ boost::optional<double> process(GdkEvent const *e);
+ double maxLatency() const { return max_latency; }
+
+ static GdkEventLatencyTracker &default_tracker();
+
+private:
+ GdkEventLatencyTracker(GdkEventLatencyTracker const &); // no copy
+ void operator=(GdkEventLatencyTracker const &); // no assign
+
+ double start_seconds;
+ double max_latency;
+ Glib::Timer elapsed;
+};
+
+}
+}
+
+#endif
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :