aboutsummaryrefslogtreecommitdiffstats
path: root/src/benchmarks/auto/creation/quick/delegates_qobject_large_array.qml
blob: 01fc3cf614d7edbb325c490d8550508f1c80d579 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import QtQuick 2.0
import QmlBench 1.0

// Test allocation of QObject, with no Repeater or anything, stored in a JS
// array. The array is interesting as it's a large GC'd allocation.
// Compare with delegates_qobject.
Benchmark {
    id: root;
    count: 50;
    staticCount: 10000;

    property var items;
    onTChanged: {
        allocate();
    }

    Component {
        id: component;
        QtObject {
        }
    }

    function allocate() {
        if (items && items.length) {
            for (var i=0; i<items.length; ++i)
                items[i].destroy();
        }
        items = [];

        for (var i=0; i<root.count; ++i) {
            var object = component.createObject();
            items.push(object);
        }
    }
}