QXlsx
QXlsx copied to clipboard
fix QDateTime performance on Qt6
Switching from Qt 5.15.2 to Qt6.5.1 on Windows platform introduces HUGE performance regression in parsing of date fields when opening the XLSX files. On my laptop (i7-10510U, 32 GB RAM, Windows 10 Pro) opening of 2 MB file takes roughly 3 sec on Qt 5.15.2 and more than 3 minutes (!) on Qt 6.5.1.
The change seems to be related to some underlying changes in QDateTime class implementation - specifically performance of copy constructors seems to have degraded a lot in Qt6.
I was able to solve the problem by switching implementation of datetimeFromNumber() to new QDateTime::fromMSecsSinceEpoch() function introduced in Qt6.5.
You are likely using a debug relase of Qt which indeed see degraded perfomance, still I don't like the ifdefs as this could be used byt Qt5 and 6, also it seems more interesting to have a QDateTime static than qint64 especially since we should be using std::chrono where possible
This happens with Qt 6.5.1 in release (not debug) build using MSVC 2019 compiler.
This might be related to the issue and suggested fix I posted here: https://github.com/QtExcel/QXlsx/issues/322
@dfaure-kdab you asked about a PR related to QDateTime, I know you know this issue better, and I didn't have time to dig much into this, do you think this fix is ok?
This fix looks OK, actually. I just wonder why the version check says > 6.5 while this API exists in 6.0 already. It seems to me it could be changed to say QT_VERSION_CHECK(6, 0, 0) instead, no?