diff options
author | Milian Wolff <milian.wolff@kdab.com> | 2014-11-14 16:50:32 +0100 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2014-11-14 20:56:05 +0100 |
commit | 815b8d99c588fa88dd4bbe65ec49011c10bb3e91 (patch) | |
tree | 2c2c13b42a89659837c8d03d32652260928cd9bd /tests/auto | |
parent | dc9fb163aee08a8bca854bc2f100b7606a266beb (diff) |
Enforce that we never try to allocate unexpectedly huge items.
This also allows us to greatly simplify the code while at it.
If future subclasses ever become larger than our maxObjectSize,
we can either force them to overload operator new themselves
or increase the maxObjectSize in the allocator.
That never happens in practice and just increases the codesize
and also slows down the code. The benchmark now shows the following
numbers for perf's instr:k counter on my machine:
********* Start testing of tst_QFrameAllocator *********
Config: Using QtTest library 5.5.0, Qt 5.5.0 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC
4.9.2)
PASS : tst_QFrameAllocator::initTestCase()
PASS : tst_QFrameAllocator::benchmarkAllocateSmall()
RESULT : tst_QFrameAllocator::benchmarkAllocateSmall():
880,438 instructions per iteration (total: 880,438, iterations: 1)
PASS : tst_QFrameAllocator::benchmarkAllocateBig()
RESULT : tst_QFrameAllocator::benchmarkAllocateBig():
965,937 instructions per iteration (total: 965,937, iterations: 1)
PASS : tst_QFrameAllocator::benchmarkDeallocateSmall()
RESULT : tst_QFrameAllocator::benchmarkDeallocateSmall():
701,573 instructions per iteration (total: 701,573, iterations: 1)
PASS : tst_QFrameAllocator::benchmarkDeallocateBig()
RESULT : tst_QFrameAllocator::benchmarkDeallocateBig():
701,572 instructions per iteration (total: 701,572, iterations: 1)
PASS : tst_QFrameAllocator::benchmarkAllocateRaw()
RESULT : tst_QFrameAllocator::benchmarkAllocateRaw():
867,893 instructions per iteration (total: 867,893, iterations: 1)
PASS : tst_QFrameAllocator::benchmarkDeallocateRaw()
RESULT : tst_QFrameAllocator::benchmarkDeallocateRaw():
771,701 instructions per iteration (total: 771,701, iterations: 1)
PASS : tst_QFrameAllocator::cleanupTestCase()
Totals: 8 passed, 0 failed, 0 skipped, 0 blacklisted
********* Finished testing of tst_QFrameAllocator *********
Change-Id: I0500a206e8460e27b5157d6238a06bee355b7318
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/core/qframeallocator/tst_qframeallocator.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/tests/auto/core/qframeallocator/tst_qframeallocator.cpp b/tests/auto/core/qframeallocator/tst_qframeallocator.cpp index 7ef9a758c..64f3faa22 100644 --- a/tests/auto/core/qframeallocator/tst_qframeallocator.cpp +++ b/tests/auto/core/qframeallocator/tst_qframeallocator.cpp @@ -538,8 +538,8 @@ void tst_QFrameAllocator::allocateWithQFrameAllocator() void tst_QFrameAllocator::deallocateWithQFrameAllocator() { - Qt3D::QFrameAllocator f2(96, 16); - QCOMPARE(f2.allocatorPoolSize(), 6); + Qt3D::QFrameAllocator f2(256, 4); + QCOMPARE(f2.allocatorPoolSize(), 256 / 4); small *s = f2.allocate<small>(); QVERIFY(s); @@ -562,8 +562,6 @@ void tst_QFrameAllocator::testAllocationComposedValues() composed t; - qDebug() << sizeof(QVector<int>); - QVector<int> *v = f.allocate<QVector<int> >(); QVERIFY(v); |