BTW: I fixed a few compiler issues, but I do not seem to have write
access to the sword lib. Here is my patch.
--
David
David Trotz wrote:
Troy,
Good news, after you went to sleep, I tried fully optimized code
(preferring speed over size) and I got the results we expected.
For reference these are my old timings:
***********************************************
OLD
KJV version of Psalm 119 w/ all options off.
<snip>
m_modCurText->SetKey(keyCur);
0.009748 s
sprintf(strNum, i"386483203", pvHeading++);
0.002622 s
SWBuf preverseHeading = m_modCurText->getEntryAttributes()...
0.134881 s
if (preverseHeading.length()) {...
0.000000 s
s = GetVerseHeader(keyCur);...
0.062169 s
s += (TCHAR *)m_modCurText->RenderText();...
4.705670 s
s += ;
0.002992 s
if (s.length() > 0) {...
0.094492 s
if (keyCur.Verse() == GetMaxVerses())...
0.000000 s
Total Time ...
5.036635 s
</snip>
***********************************************
NEW
KJV version of Psalm 119 w/ all options off.
<snip>
m_modCurText->SetKey(keyCur);
0.008105
sprintf(strNum, i"1472589783", pvHeading++);
0.002758
SWBuf preverseHeading = m_modCurText->getEntryAttributes()...
0.021899
if (preverseHeading.length()) {...
0.000000
s = GetVerseHeader(keyCur);...
0.024966
s += (TCHAR *)m_modCurText->RenderText();...
1.635440
s += ;
0.001546
if (s.length() > 0) {...
0.051099
if (keyCur.Verse() == GetMaxVerses())...
0.000000
Total Time ...
1.765442
</snip>
***********************************************
Much better results and more manageable. Thanks for looking more into
this. I really appreciate it.
In Christ,
David Trotz
_______________________________________________
sword-devel mailing list: sword-devel@crosswire.org
http://www.crosswire.org/mailman/listinfo/sword-devel
Instructions to unsubscribe/change your settings at above page
Index: include/versemgr.h
===================================================================
--- include/versemgr.h (revision 2188)
+++ include/versemgr.h (working copy)
@@ -86,7 +86,7 @@
friend class System;
friend struct BookOffsetLess;
class Private;
- Private *p;
+ Private *p;
/** book name */
SWBuf longName;
Index: src/mgr/versemgr.cpp
===================================================================
--- src/mgr/versemgr.cpp (revision 2188)
+++ src/mgr/versemgr.cpp (working copy)
@@ -79,7 +79,10 @@
};
struct BookOffsetLess {
- bool operator() (const VerseMgr::Book &o1, const long &o2) const {
return o1.p->offsetPrecomputed[0] < o2; }
+ bool operator() (const VerseMgr::Book &o1, const VerseMgr::Book &o2) const
{ return o1.p->offsetPrecomputed[0] < o2.p->offsetPrecomputed[0]; }
+ bool operator() (const long &o1, const VerseMgr::Book &o2) const { return
o1 < o2.p->offsetPrecomputed[0]; }
+ bool operator() (const VerseMgr::Book &o1, const long &o2) const { return
o1.p->offsetPrecomputed[0] < o2; }
+ bool operator() (const long &o1, const long &o2) const { return o1 < o2; }
};
void VerseMgr::Book::init() {
@@ -103,7 +106,7 @@
ntStartOffset = other.ntStartOffset;
}
-VerseMgr::System::System &VerseMgr::System::operator =(const System &other) {
+VerseMgr::System &VerseMgr::System::operator =(const System &other) {
name = other.name;
BMAX[0] = other.BMAX[0];
BMAX[1] = other.BMAX[1];
@@ -140,7 +143,7 @@
Book &b = p->books[p->books.size()-1];
p->osisLookup[b.getOSISName()] = p->books.size();
for (int i = 0; i < ot->chapmax; i++) {
- b.p->verseMax.push_back(chMax[chap]);
+ b.p->verseMax.push_back(chMax[chap]);
offset++; // chapter heading
b.p->offsetPrecomputed.push_back(offset);
offset += chMax[chap++];
@@ -181,7 +184,7 @@
(*p) = *(other.p);
}
-VerseMgr::Book::Book& VerseMgr::Book::operator =(const Book &other) {
+VerseMgr::Book& VerseMgr::Book::operator =(const Book &other) {
longName = other.longName;
osisName = other.osisName;
prefAbbrev = other.prefAbbrev;
@@ -229,7 +232,7 @@
char VerseMgr::System::getVerseFromOffset(long offset, int *book, int
*chapter, int *verse) const {
// binary search for book
- vector<Book>::iterator b = lower_bound(p->books.begin(),
p->books.end(), offset, BookOffsetLess());
+ vector<Book>::iterator b = lower_bound(p->books.begin(), p->books.end(),
offset, BookOffsetLess());
b--;
vector<long>::iterator c = lower_bound(b->p->offsetPrecomputed.begin(),
b->p->offsetPrecomputed.end(), offset);
c--;
_______________________________________________
sword-devel mailing list: sword-devel@crosswire.org
http://www.crosswire.org/mailman/listinfo/sword-devel
Instructions to unsubscribe/change your settings at above page