QDecompressHelper: update the benchmark

After the zip bomb checks were added the benchmark was not
adjusted.

Also move the QByteArray creation outside the loop, to not include
the time it takes to make a heap allocation.

Pick-to: 6.7 6.5
Change-Id: Ia958d497dd27fc61e0084b6f5c11d76886bb24c4
Reviewed-by: Mate Barany <mate.barany@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Mårten Nordheim 2024-01-22 14:36:50 +01:00
parent 392c5fab81
commit 6f2ef2eacb

View File

@ -51,13 +51,14 @@ void tst_QDecompressHelper::decompress()
file.seek(0); file.seek(0);
QDecompressHelper helper; QDecompressHelper helper;
helper.setEncoding(encoding); helper.setEncoding(encoding);
helper.setDecompressedSafetyCheckThreshold(-1);
QVERIFY(helper.isValid()); QVERIFY(helper.isValid());
helper.feed(file.readAll()); helper.feed(file.readAll());
qsizetype bytes = 0; qsizetype bytes = 0;
QByteArray out(64 * 1024, Qt::Uninitialized);
while (helper.hasData()) { while (helper.hasData()) {
QByteArray out(64 * 1024, Qt::Uninitialized);
qsizetype bytesRead = helper.read(out.data(), out.size()); qsizetype bytesRead = helper.read(out.data(), out.size());
bytes += bytesRead; bytes += bytesRead;
} }