[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lmi] PDF generation performance
From: |
Vadim Zeitlin |
Subject: |
Re: [lmi] PDF generation performance |
Date: |
Wed, 7 Feb 2018 22:49:16 +0100 |
On Wed, 7 Feb 2018 21:40:46 +0100 I wrote:
Me> I think it should be possible to obtain much more than microscopic
Me> refinements.
Just FYI, applying this simple and still not really optimal (because
operator<<() is very slow on its own) patch:
---------------------------------- >8 --------------------------------------
diff --git a/ledger_text_formats.cpp b/ledger_text_formats.cpp
index 9e5a7ef6d..952b98d13 100644
--- a/ledger_text_formats.cpp
+++ b/ledger_text_formats.cpp
@@ -1227,11 +1227,22 @@ void FlatTextLedgerPrinter::PrintTabularDetail() const
,std::pair<int,oenum_format_style> f
)
{
- std::stringstream interpreter;
- std::locale loc;
- std::locale new_loc(loc, new comma_punct);
- interpreter.imbue(new_loc);
- interpreter.setf(std::ios_base::fixed, std::ios_base::floatfield);
+ static std::stringstream interpreter;
+ static bool initialized = false;
+ if(!initialized)
+ {
+ initialized = true;
+ std::locale loc;
+ std::locale new_loc(loc, new comma_punct);
+ interpreter.imbue(new_loc);
+ interpreter.setf(std::ios_base::fixed, std::ios_base::floatfield);
+ }
+ else
+ {
+ interpreter.str(std::string{});
+ interpreter.clear();
+ }
+
interpreter.precision(f.first);
std::string s;
if(f.second)
---------------------------------- >8 --------------------------------------
speeds the code by 50% for me, i.e. makes it exactly twice faster (status
bar shows ~6800ms instead of ~13700ms for me) without any non-trivial
change in the generated output files (they're still different solely
because the "CreationDate" field in the generated PDFs changes -- I think
it would be nice to have some way to call wxPdfDocument::SetCreationDate()
with some fixed date for testing to allow checking for the changes in
output just using diff, instead of having to use diffpdf as I do now).
I don't necessarily advocate applying the patch above (although neither do
I see anything really wrong with doing this), but IMO this definitely
proves my quoted statement in the beginning of this email.
Regards,
VZ