Is QSettings usable with large files?
-
I store my object structure in the ini file. Recently I created quite a lot of new objects and saved them. All was ok, but my ini file grew to 630 KB. But now loading object structure from that file takes a lot of time (almost a minute). Is QSettings usable with such large inis?
Here's example code how I load objects:for(auto & it: objs) { m_pConnection->beginGroup(objectSectionName(it)); Signal* pSig=dynamic_cast<Signal*>(it); pSig->setType(dynamic_cast<SignalType*>(m_pFactory->getObject(m_pConnection->value("SignalTypeGuid").toInt()))); pSig->setCheckpoint(dynamic_cast<Checkpoint*>(m_pFactory->getObject(m_pConnection->value("CheckpointGuid").toInt()))); pSig->m_bAnalog=m_pConnection->value("Analog").toBool(); pSig->m_bHardware=m_pConnection->value("Hardware").toBool(); int v=QMetaEnum::fromType<ARMSStatus>().keyToValue(m_pConnection->value("StatusOnSet").toString().toLatin1().data(), &ok); pSig->m_eStatusOnSet=(ok ? (ARMSStatus)v : ARMSStatus::Normal); pSig->m_iPriorityOnSet=m_pConnection->value("PriorityOnSet").toInt(); pSig->m_sMessageOnSet=m_pConnection->value("MessageOnSet").toString(); v=QMetaEnum::fromType<ARMSStatus>().keyToValue(m_pConnection->value("StatusOnClear").toString().toLatin1().data(), &ok); pSig->m_eStatusOnClear=(ok ? (ARMSStatus)v : ARMSStatus::Normal); pSig->m_iPriorityOnClear=m_pConnection->value("PriorityOnClear").toInt(); pSig->m_sMessageOnClear=m_pConnection->value("MessageOnClear").toString(); pSig->m_iInputNumber=m_pConnection->value("InputNumber").toInt(); m_pConnection->beginGroup("CurrentData"); pSig->m_cLastDateTime=QDateTime::fromString(m_pConnection->value("DateTime").toString(), "yyyy-MM-dd hh:mm:ss.zzz"); pSig->m_dLastAnalogValue=m_pConnection->value("AnalogValue").toDouble(); pSig->m_bLastBitValue=m_pConnection->value("BitValue").toBool(); pSig->m_bLastBitChanged=m_pConnection->value("BitChanged").toBool(); pSig->m_cLastBitChangedDateTime=QDateTime::fromString(m_pConnection->value("BitChangedDateTime").toString(), "yyyy-MM-dd hh:mm:ss.zzz"); pSig->m_cLastArchiveDateTime=QDateTime::fromString(m_pConnection->value("ArchiveDateTime").toString(), "yyyy-MM-dd hh:mm:ss.zzz"); pSig->m_dLastArchiveAnalogValue=m_pConnection->value("ArchiveAnalogValue").toDouble(); pSig->m_bLastArchiveBitValue=m_pConnection->value("ArchiveBitValue").toBool(); m_pConnection->endGroup(); //CurrentData m_pConnection->endGroup(); //Object it->m_bActivated=true; } -
Turned out QSettings was not the cause of the problem. I used QMultiMap::keys() instead of uniqueKeys() creating a lot of extra useless iterations.
-
@Max-Fedotov said in Is QSettings usable with large files?:
file takes a lot of time (almost a minute). Is QSettings usable with such large inis?
Doesn't this already answer your question?
I would use a small sqlite db or (de)serialize the data structure with QDataStream instead. -
Thanks. I still need to be able to edit config file manually from text editor. Maybe I'll make caching ini parser, that loads the entire file once.
-
@Max-Fedotov said in Is QSettings usable with large files?:
I still need to be able to edit config file manually from text editor
This just cries for problems but it's not mine :)
-
Turned out QSettings was not the cause of the problem. I used QMultiMap::keys() instead of uniqueKeys() creating a lot of extra useless iterations.