| 23 | using namespace GammaRay; |
| 24 | |
| 25 | class QuickInspectorBench : public QObject |
| 26 | { |
| 27 | Q_OBJECT |
| 28 | |
| 29 | private slots: |
| 30 | void initTestCase() |
| 31 | { |
| 32 | } |
| 33 | |
| 34 | void benchModelObjectAdded() |
| 35 | { |
| 36 | QQuickView view; |
| 37 | auto root = view.contentItem(); |
| 38 | QuickItemModel model; |
| 39 | model.setWindow(&view); |
| 40 | const auto items = createItems(root); |
| 41 | |
| 42 | QBENCHMARK_ONCE |
| 43 | { |
| 44 | for (auto item : items) { |
| 45 | model.objectAdded(item); |
| 46 | } |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | void benchModelItemUpdated() |
| 51 | { |
| 52 | QQuickView view; |
| 53 | auto root = view.contentItem(); |
| 54 | QuickItemModel model; |
| 55 | model.setWindow(&view); |
| 56 | const auto items = createItems(root); |
| 57 | |
| 58 | for (auto item : items) { |
| 59 | model.objectAdded(item); |
| 60 | } |
| 61 | |
| 62 | QBENCHMARK_ONCE |
| 63 | { |
| 64 | for (auto item : items) { |
| 65 | // trigger item update |
| 66 | item->setX(item->x() + 1); |
| 67 | } |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | private: |
| 72 | static QVector<QQuickItem *> createItems(QQuickItem *parent) |
| 73 | { |
| 74 | const int numberOfItems = 100; // increase when benchmarking as needed |
| 75 | QVector<QQuickItem *> items; |
| 76 | items.reserve(numberOfItems); |
| 77 | for (int i = 0; i < numberOfItems; ++i) { |
| 78 | items << new QQuickItem(parent); |
| 79 | } |
| 80 | return items; |
| 81 | } |
| 82 | }; |
nothing calls this directly
no test coverage detected