Minor profiling & day loading performance improvements

This commit is contained in:
Mark Watkins 2013-10-13 20:13:14 +10:00
parent 79cd678e8a
commit 61cb9adc12
3 changed files with 28 additions and 15 deletions

View File

@ -282,8 +282,11 @@ void Profile::AddDay(QDate date,Day *day,MachineType mt) {
Day * Profile::GetGoodDay(QDate date,MachineType type)
{
Day *day=NULL;
if (daylist.find(date)!=daylist.end()) {
for (QList<Day *>::iterator di=daylist[date].begin();di!=daylist[date].end();di++) {
QMap<QDate,QList<Day *> >::iterator dli=daylist.find(date);
if (dli!=daylist.end()) {
for (QList<Day *>::iterator di=(*dli).begin();di!=(*dli).end();di++) {
if (type==MT_UNKNOWN) { // Who cares.. We just want to know there is data available.
day=(*di);
@ -792,6 +795,7 @@ EventDataType Profile::calcPercentile(ChannelID code, EventDataType percent, Mac
return 0;
QMap<EventDataType, qint64> wmap;
QMap<EventDataType, qint64>::iterator wmi;
QHash<ChannelID,QHash<EventStoreType, EventStoreType> >::iterator vsi;
QHash<ChannelID,QHash<EventStoreType, quint32> >::iterator tsi;
@ -827,10 +831,11 @@ EventDataType Profile::calcPercentile(ChannelID code, EventDataType percent, Mac
value=EventDataType(k.key())*gain;
SN+=weight;
if (wmap.contains(value)) {
wmap[value]+=weight;
} else {
wmi=wmap.find(value);
if (wmi==wmap.end()) {
wmap[value]=weight;
} else {
wmi.value()+=weight;
}
}
} else {
@ -839,10 +844,11 @@ EventDataType Profile::calcPercentile(ChannelID code, EventDataType percent, Mac
value=EventDataType(k.key())*gain;
SN+=weight;
if (wmap.contains(value)) {
wmap[value]+=weight;
} else {
wmi=wmap.find(value);
if (wmi==wmap.end()) {
wmap[value]=weight;
} else {
wmi.value()+=weight;
}
}
}
@ -854,10 +860,10 @@ EventDataType Profile::calcPercentile(ChannelID code, EventDataType percent, Mac
QVector<ValueCount> valcnt;
// Build sorted list of value/counts
for (QMap<EventDataType, qint64>::iterator n=wmap.begin();n!=wmap.end();n++) {
for (wmi=wmap.begin();wmi!=wmap.end();wmi++) {
ValueCount vc;
vc.value=n.key();
vc.count=n.value();
vc.value=wmi.key();
vc.count=wmi.value();
vc.p=0;
valcnt.push_back(vc);
}

View File

@ -418,7 +418,8 @@ public:
if (!m_profile->contains(STR_CS_UserEventFlagging)) (*m_profile)[STR_CS_UserEventFlagging]=false;
if (!m_profile->contains(STR_CS_AHIWindow)) (*m_profile)[STR_CS_AHIWindow]=60.0;
if (!m_profile->contains(STR_CS_AHIReset)) (*m_profile)[STR_CS_AHIReset]=false;
if (!m_profile->contains(STR_CS_ClockDrift)) (*m_profile)[STR_CS_ClockDrift]=(int)0;
if (!m_profile->contains(STR_CS_ClockDrift)) (*m_profile)[STR_CS_ClockDrift]=m_clock_drift=(int)0;
else m_clock_drift=(*m_profile)[STR_CS_ClockDrift].toInt();
}
~CPAPSettings() { }
@ -444,7 +445,7 @@ public:
double AHIWindow() { return (*m_profile)[STR_CS_AHIWindow].toDouble(); }
bool AHIReset() { return (*m_profile)[STR_CS_AHIReset].toBool(); }
bool userEventFlagging() { return (*m_profile)[STR_CS_UserEventFlagging].toBool(); }
int clockDrift() { return (*m_profile)[STR_CS_ClockDrift].toInt(); }
int clockDrift() { return m_clock_drift; }
//Setters
void setMode(CPAPMode mode) { (*m_profile)[STR_CS_PrescribedMode]=(int)mode; }
@ -465,9 +466,11 @@ public:
void setAHIReset(bool reset) { (*m_profile)[STR_CS_AHIReset]=reset; }
void setUserEventFlagging(bool flagging) { (*m_profile)[STR_CS_UserEventFlagging]=flagging; }
void setUserEventDuplicates(bool dup) { (*m_profile)[STR_CS_UserEventDuplicates]=dup; }
void setClockDrift(int seconds) { (*m_profile)[STR_CS_ClockDrift]=(int)seconds; }
void setClockDrift(int seconds) { (*m_profile)[STR_CS_ClockDrift]=m_clock_drift=(int)seconds; }
Profile *m_profile;
int m_clock_drift;
};
/*! \class ImportSettings

View File

@ -723,6 +723,10 @@ MyWebView::MyWebView(QWidget *parent):
void Daily::Load(QDate date)
{
static int calls=0;
calls++;
qDebug() << "in Load()" << date << calls;
dateDisplay->setText("<i>"+date.toString(Qt::SystemLocaleLongDate)+"</i>");
static Day * lastcpapday=NULL;
previous_date=date;