summaryrefslogtreecommitdiff
path: root/libs/pbd
diff options
context:
space:
mode:
authorTim Mayberry <mojofunk@gmail.com>2016-09-23 23:01:18 +1000
committerTim Mayberry <mojofunk@gmail.com>2016-10-10 08:45:34 +1000
commit816f3bfb3615644ca5a3ecdb806f377922c1feb1 (patch)
treeb8e9dd5635074b28e611cdb35fcd6bdf87e0f682 /libs/pbd
parente84fbfe6e5a48915e2e3b01b7867e0f3ff2a64ce (diff)
Use std::vector::reserve to improve performance of adding properties
The number of properties per node roughly corresponds to the number of members of the class the node is representing and should be fairly low. Use std::vector::reserve to prevent reallocation on insert for most node types, there are exceptions like Region(~40 properties). This seems worth it as part(maybe 1/10th of the total time) of saving a Session is a combination of what occurs in "Create" and "Write" in this test. Perf results before changes: XMLTest::testPerfMediumXMLDocumentTiming Create : Count: 10 Min: 30610 Max: 42656 Total: 376672 Avg: 37667 (37 msecs) Write : Count: 10 Min: 42804 Max: 54277 Total: 460455 Avg: 46045 (46 msecs) Read : Count: 10 Min: 70364 Max: 85484 Total: 750909 Avg: 75090 (75 msecs) XMLTest::testPerfLargeXMLDocumentTiming Create : Count: 10 Min: 164360 Max: 356995 Total: 3064482 Avg: 306448 (306 msecs) Write : Count: 10 Min: 308655 Max: 372953 Total: 3226707 Avg: 322670 (322 msecs) Read : Count: 10 Min: 517243 Max: 541839 Total: 5289950 Avg: 528995 (528 msecs) Perf results after changes: XMLTest::testPerfMediumXMLDocumentTiming Create : Count: 10 Min: 30375 Max: 48253 Total: 431727 Avg: 43172 (43 msecs) Write : Count: 10 Min: 42553 Max: 49163 Total: 453353 Avg: 45335 (45 msecs) Read : Count: 10 Min: 70307 Max: 75987 Total: 734923 Avg: 73492 (73 msecs) XMLTest::testPerfLargeXMLDocumentTiming Create : Count: 10 Min: 154486 Max: 307856 Total: 2678989 Avg: 267898 (267 msecs) Write : Count: 10 Min: 304273 Max: 343274 Total: 3169158 Avg: 316915 (316 msecs) Read : Count: 10 Min: 496920 Max: 541394 Total: 5260410 Avg: 526041 (526 msecs)
Diffstat (limited to 'libs/pbd')
-rw-r--r--libs/pbd/xml++.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/libs/pbd/xml++.cc b/libs/pbd/xml++.cc
index 3b0da66dbc..e19a5ab244 100644
--- a/libs/pbd/xml++.cc
+++ b/libs/pbd/xml++.cc
@@ -215,10 +215,13 @@ XMLTree::write_buffer() const
return retval;
}
+static const int PROPERTY_RESERVE_COUNT = 16;
+
XMLNode::XMLNode(const string& n)
: _name(n)
, _is_content(false)
{
+ _proplist.reserve (PROPERTY_RESERVE_COUNT);
}
XMLNode::XMLNode(const string& n, const string& c)
@@ -226,10 +229,12 @@ XMLNode::XMLNode(const string& n, const string& c)
, _is_content(true)
, _content(c)
{
+ _proplist.reserve (PROPERTY_RESERVE_COUNT);
}
XMLNode::XMLNode(const XMLNode& from)
{
+ _proplist.reserve (PROPERTY_RESERVE_COUNT);
*this = from;
}