[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lmi] ~50% speedup for Input::read()
From: |
Greg Chicares |
Subject: |
Re: [lmi] ~50% speedup for Input::read() |
Date: |
Sat, 20 Dec 2008 13:46:16 +0000 |
User-agent: |
Thunderbird 2.0.0.18 (Windows/20081105) |
On 2008-12-19 17:49Z, Vaclav Slavik wrote:
>
> [...] I noticed that 50%
> of Input::read()'s time is spent in std::vector<>::erase(), here:
>
> if(member_names.end() != current_member)
> {
> operator[](node_tag) = xml_lmi::get_content(*child);
> // TODO ?? Perhaps a std::list would perform better.
> member_names.erase(current_member);
> }
And Input::read() must account for about one-third of the time
it takes to read an input file, because I measured it with the
patch below [0] and got these timings:
Total time: 19169 milliseconds [without your patch]
Total time: 15999 milliseconds [with your patch]
for a 1296-cell census, which now loads in about 5/6 the time.
BTW, it appears that this erasure is required for correctness
of the ensuing backward-compatibility code, so it couldn't just
be removed. But it doesn't have to be slow, and of course I'll
apply your patch soon.
A long time ago, I ran a profiler on an ancient predecessor of
lmi, and found that forty percent of its run time was spent on
rounding. Bottlenecks are often surprising, and profitable to
fix; I'd be glad to know of any others.
---------
[0] "the patch below":
Index: multiple_cell_document.cpp
===================================================================
RCS file: /sources/lmi/lmi/multiple_cell_document.cpp,v
retrieving revision 1.25
diff -U 3 -r1.25 multiple_cell_document.cpp
--- multiple_cell_document.cpp 3 Aug 2008 23:23:14 -0000 1.25
+++ multiple_cell_document.cpp 20 Dec 2008 13:06:28 -0000
@@ -205,11 +205,14 @@
}
}
+#include "timer.hpp"
//============================================================================
void multiple_cell_document::read(std::istream const& is)
{
+Timer timer;
xml_lmi::dom_parser parser(is);
parse(parser.root_node(xml_root_name()));
+warning() << "Total time: " << timer.stop().elapsed_msec_str() << std::flush;
}
//============================================================================