QXlsx icon indicating copy to clipboard operation
QXlsx copied to clipboard

fix QDateTime performance on Qt6

Open alexagr opened this issue 1 year ago • 5 comments

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.

alexagr avatar Jan 22 '24 10:01 alexagr

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

dantti avatar Apr 01 '24 16:04 dantti

This happens with Qt 6.5.1 in release (not debug) build using MSVC 2019 compiler.

alexagr avatar Apr 01 '24 19:04 alexagr

This might be related to the issue and suggested fix I posted here: https://github.com/QtExcel/QXlsx/issues/322

archibalduk avatar May 12 '24 10:05 archibalduk

@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?

dantti avatar Jul 03 '24 14:07 dantti

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?

dfaure-kdab avatar Jul 03 '24 14:07 dfaure-kdab