summaryrefslogtreecommitdiff
path: root/libs/pbd/stateful.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2017-03-25 15:08:58 +0100
committerRobin Gareus <robin@gareus.org>2017-03-25 15:10:02 +0100
commite965e5edcdd9fdc8a4c68b4d50656cd4e0c53f18 (patch)
treec4bc7471d08f1e9fb3e02a30f9cea51d0bbb6a4f /libs/pbd/stateful.cc
parentf5931457fb4f341fb67ee4ea63ace5068d898407 (diff)
profile instant.xml save
This does clutter up stderr, but only because instant.xml is arguably saved much too often (and it's not really instant :)
Diffstat (limited to 'libs/pbd/stateful.cc')
-rw-r--r--libs/pbd/stateful.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/libs/pbd/stateful.cc b/libs/pbd/stateful.cc
index 8b8219f7e2..59aa1f896a 100644
--- a/libs/pbd/stateful.cc
+++ b/libs/pbd/stateful.cc
@@ -23,6 +23,7 @@
#else
#include <unistd.h>
#endif
+#include <iomanip> // std::setprecision
#include <glibmm/fileutils.h>
#include <glibmm/miscutils.h>
@@ -112,6 +113,9 @@ Stateful::save_extra_xml (const XMLNode& node)
void
Stateful::add_instant_xml (XMLNode& node, const std::string& directory_path)
{
+#ifndef NDEBUG
+ const int64_t save_start_time = g_get_monotonic_time();
+#endif
if (!Glib::file_test (directory_path, Glib::FILE_TEST_IS_DIR)) {
if (g_mkdir_with_parents (directory_path.c_str(), 0755) != 0) {
error << string_compose(_("Error: could not create directory %1"), directory_path) << endmsg;
@@ -147,6 +151,10 @@ Stateful::add_instant_xml (XMLNode& node, const std::string& directory_path)
if (!tree.write()) {
error << string_compose(_("Error: could not write %1"), instant_xml_path) << endmsg;
}
+#ifndef NDEBUG
+ const int64_t elapsed_time_us = g_get_monotonic_time() - save_start_time;
+ cerr << "saved '"<< instant_xml_path << "' in " << fixed << setprecision (1) << elapsed_time_us / 1000. << " ms\n";
+#endif
}
XMLNode *