summaryrefslogtreecommitdiff
path: root/plugins/qmlprofilerextension/pixmapcachemodel.cpp
blob: 98d6e9667bc53882951b6803471fc2d5ccd06512 (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc
** All rights reserved.
** For any questions to Digia, please use contact form at http://qt.digia.com <http://qt.digia.com/>
**
** This file is part of the Qt Enterprise Qt Quick Profiler Add-on.
**
** Licensees holding valid Qt Enterprise licenses may use this file in
** accordance with the Qt Enterprise License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.
**
** If you have questions regarding the use of this file, please use
** contact form at http://qt.digia.com <http://qt.digia.com/>
**
****************************************************************************/

#include "pixmapcachemodel.h"
#include "qmldebug/qmlprofilereventtypes.h"
#include "qmlprofiler/qmlprofilermodelmanager.h"
#include "qmlprofiler/sortedtimelinemodel.h"
#include "qmlprofiler/abstracttimelinemodel_p.h"

#include <QDebug>
#include <QSize>

namespace QmlProfilerExtension {
namespace Internal {

using namespace QmlProfiler;

enum CacheState {
    Uncached,    // After loading started (or some other proof of existence) or after uncaching
    ToBeCached,  // After determining the pixmap is to be cached but before knowing its size
    Cached,      // After caching a pixmap or determining the size of a ToBeCached pixmap
    Uncacheable, // If loading failed without ToBeCached or after a corrupt pixmap has been uncached
    Corrupt      // If after ToBeCached we learn that loading failed
};

enum LoadState {
    Initial,
    Loading,
    Finished,
    Error
};

struct PixmapState {
    PixmapState(int width, int height, CacheState cache = Uncached) :
        size(width, height), started(-1), loadState(Initial), cacheState(cache) {}
    PixmapState(CacheState cache = Uncached) : started(-1), loadState(Initial), cacheState(cache) {}
    QSize size;
    int started;
    LoadState loadState;
    CacheState cacheState;
};

struct Pixmap {
    Pixmap() {}
    Pixmap(const QString &url) : url(url), sizes(1) {}
    QString url;
    QVector<PixmapState> sizes;
};

class PixmapCacheModel::PixmapCacheModelPrivate :
        public SortedTimelineModel<PixmapCacheEvent,
                                   AbstractTimelineModel::AbstractTimelineModelPrivate>
{
public:
    void computeMaxCacheSize();
    void resizeUnfinishedLoads();
    void flattenLoads();
    int updateCacheCount(int lastCacheSizeEvent, qint64 startTime, qint64 pixSize,
                         PixmapCacheEvent &newEvent);

    QVector<Pixmap> pixmaps;
    int collapsedRowCount;
    void addVP(QVariantList &l, QString label, qint64 time) const;

    qint64 maxCacheSize;
private:
    Q_DECLARE_PUBLIC(PixmapCacheModel)
};

PixmapCacheModel::PixmapCacheModel(QObject *parent)
    : AbstractTimelineModel(new PixmapCacheModelPrivate(), QLatin1String("Pixmap Cache"),
                            QmlDebug::PixmapCacheEvent, QmlDebug::MaximumRangeType, parent)
{
    Q_D(PixmapCacheModel);
    d->collapsedRowCount = 1;
    d->maxCacheSize = 1;
}

int PixmapCacheModel::rowCount() const
{
    Q_D(const PixmapCacheModel);
    if (isEmpty())
        return 1;
    if (d->expanded)
        return d->pixmaps.count() + 2;
    return d->collapsedRowCount;
}

int PixmapCacheModel::rowMaxValue(int rowNumber) const
{
    Q_D(const PixmapCacheModel);
    if (rowNumber == 1) {
        return d->maxCacheSize;
    } else {
        return AbstractTimelineModel::rowMaxValue(rowNumber);
    }
}

int PixmapCacheModel::row(int index) const
{
    Q_D(const PixmapCacheModel);
    if (d->expanded)
        return eventId(index) + 1;
    return d->range(index).rowNumberCollapsed;
}

int PixmapCacheModel::eventId(int index) const
{
    Q_D(const PixmapCacheModel);
    return d->range(index).pixmapEventType == PixmapCacheCountChanged ?
                0 : d->range(index).urlIndex + 1;
}

QColor PixmapCacheModel::color(int index) const
{
    Q_D(const PixmapCacheModel);
    if (d->range(index).pixmapEventType == PixmapCacheCountChanged)
        return colorByHue(PixmapCacheCountHue);

    return colorByEventId(index);
}

float PixmapCacheModel::height(int index) const
{
    Q_D(const PixmapCacheModel);
    if (d->range(index).pixmapEventType == PixmapCacheCountChanged)
        return (float)d->range(index).cacheSize / (float)d->maxCacheSize;
    else
        return 1.0f;
}

QString getFilenameOnly(QString absUrl)
{
    int characterPos = absUrl.lastIndexOf(QLatin1Char('/'))+1;
    if (characterPos < absUrl.length())
        absUrl = absUrl.mid(characterPos);
    return absUrl;
}

QVariantList PixmapCacheModel::labels() const
{
    Q_D(const PixmapCacheModel);
    QVariantList result;

    if (d->expanded && !isEmpty()) {
        {
            // Cache Size
            QVariantMap element;
            element.insert(QLatin1String("description"), QVariant(QLatin1String("Cache Size")));

            element.insert(QLatin1String("id"), QVariant(0));
            result << element;
        }

        for (int i=0; i < d->pixmaps.count(); i++) {
            // Loading
            QVariantMap element;
            element.insert(QLatin1String("description"),
                           QVariant(getFilenameOnly(d->pixmaps[i].url)));

            element.insert(QLatin1String("id"), QVariant(i+1));
            result << element;
        }
    }

    return result;
}

void PixmapCacheModel::PixmapCacheModelPrivate::addVP(QVariantList &l, QString label, qint64 time) const
{
    if (time > 0) {
        QVariantMap res;
        res.insert(label, QVariant(QmlProfilerBaseModel::formatTime(time)));
        l << res;
    }
}

QVariantList PixmapCacheModel::details(int index) const
{
    Q_D(const PixmapCacheModel);
    QVariantList result;
    const PixmapCacheModelPrivate::Range *ev = &d->range(index);

    {
        QVariantMap res;
        if (ev->pixmapEventType == PixmapCacheCountChanged)
            res.insert(QLatin1String("displayName"), QVariant(QLatin1String("Image Cached")));
        else if (ev->pixmapEventType == PixmapLoadingStarted)
            res.insert(QLatin1String("displayName"), QVariant(QLatin1String("Image Loaded")));
        result << res;
    }

    if (ev->pixmapEventType != PixmapCacheCountChanged) {
        d->addVP(result, tr("Duration"), ev->duration );
    } else {
        QVariantMap res;
        res.insert(tr("Cache Size"), QVariant(QString::fromLatin1("%1 px")
                .arg(ev->cacheSize)));
        result << res;
    }

    {
        QVariantMap res;
        res.insert(tr("File"), QVariant(getFilenameOnly(d->pixmaps[ev->urlIndex].url)));
        result << res;
    }

    {
        QVariantMap res;
        res.insert(tr("Width"), QVariant(QString::fromLatin1("%1 px")
                .arg(d->pixmaps[ev->urlIndex].sizes[ev->sizeIndex].size.width())));
        result << res;
        res.clear();
        res.insert(tr("Height"), QVariant(QString::fromLatin1("%1 px")
                .arg(d->pixmaps[ev->urlIndex].sizes[ev->sizeIndex].size.height())));
        result << res;
    }

    if (ev->pixmapEventType == PixmapLoadingStarted &&
            d->pixmaps[ev->urlIndex].sizes[ev->sizeIndex].loadState != Finished) {
        QVariantMap res;
        res.insert(tr("Result"), QVariant(QLatin1String("Load Error")));
        result << res;
    }

    return result;
}

/* Ultimately there is no way to know which cache entry a given event refers to as long as we only
 * receive the pixmap URL from the application. Multiple copies of different sizes may be cached
 * for each URL. However, we can apply some heuristics to make the result somewhat plausible by
 * using the following assumptions:
 *
 * - PixmapSizeKnown will happen at most once for every cache entry.
 * - PixmapSizeKnown cannot happen for entries with PixmapLoadingError and vice versa.
 * - PixmapCacheCountChanged can happen for entries with PixmapLoadingError but doesn't have to.
 * - Decreasing PixmapCacheCountChanged events can only happen for entries that have seen an
 *   increasing PixmapCacheCountChanged (but that may have happened before the trace).
 * - PixmapCacheCountChanged can happen before or after PixmapSizeKnown.
 * - For every PixmapLoadingFinished or PixmapLoadingError there is exactly one
 *   PixmapLoadingStarted event, but it may be before the trace.
 * - For every PixmapLoadingStarted there is exactly one PixmapLoadingFinished or
 *   PixmapLoadingError, but it may be after the trace.
 * - Decreasing PixmapCacheCountChanged events in the presence of corrupt cache entries are more
 *   likely to clear those entries than other, correctly loaded ones.
 * - Increasing PixmapCacheCountChanged events are more likely to refer to correctly loaded entries
 *   than to ones with PixmapLoadingError.
 * - PixmapLoadingFinished and PixmapLoadingError are more likely to refer to cache entries that
 *   have seen a PixmapLoadingStarted than to ones that haven't.
 *
 * For each URL we keep an ordered list of pixmaps possibly being loaded and assign new events to
 * the first entry that "fits". If multiple sizes of the same pixmap are being loaded concurrently
 * we generally assume that the PixmapLoadingFinished and PixmapLoadingError events occur in the
 * order we learn about the existence of these sizes, subject to the above constraints. This is not
 * necessarily the order the pixmaps are really loaded but it's the best we can do with the given
 * information. If they're loaded sequentially the representation is correct.
 */

void PixmapCacheModel::loadData()
{
    Q_D(PixmapCacheModel);
    clear();
    QmlProfilerDataModel *simpleModel = d->modelManager->qmlModel();
    if (simpleModel->isEmpty())
        return;

    int lastCacheSizeEvent = -1;
    int cumulatedCount = 0;

    const QVector<QmlProfilerDataModel::QmlEventTypeData> &types = simpleModel->getEventTypes();
    foreach (const QmlProfilerDataModel::QmlEventData &event, simpleModel->getEvents()) {
        const QmlProfilerDataModel::QmlEventTypeData &type = types[event.typeIndex];
        if (!accepted(type))
            continue;

        PixmapCacheEvent newEvent;
        newEvent.pixmapEventType = type.detailType;
        qint64 startTime = event.startTime;

        newEvent.urlIndex = -1;
        for (QVector<Pixmap>::const_iterator it(d->pixmaps.cend()); it != d->pixmaps.cbegin();) {
            if ((--it)->url == type.location.filename) {
                newEvent.urlIndex = it - d->pixmaps.cbegin();
                break;
            }
        }

        newEvent.sizeIndex = -1;
        if (newEvent.urlIndex == -1) {
            newEvent.urlIndex = d->pixmaps.count();
            d->pixmaps << Pixmap(type.location.filename);
        }

        Pixmap &pixmap = d->pixmaps[newEvent.urlIndex];
        switch (newEvent.pixmapEventType) {
        case PixmapSizeKnown: {// pixmap size
            // Look for pixmaps for which we don't know the size, yet and which have actually been
            // loaded.
            for (QVector<PixmapState>::iterator i(pixmap.sizes.begin());
                    i != pixmap.sizes.end(); ++i) {
                if (i->size.isValid() || i->cacheState == Uncacheable || i->cacheState == Corrupt)
                    continue;

                // We can't have cached it before we knew the size
                Q_ASSERT(i->cacheState != Cached);

                i->size.setWidth(event.numericData1);
                i->size.setHeight(event.numericData2);
                newEvent.sizeIndex = i - pixmap.sizes.begin();
                break;
            }

            if (newEvent.sizeIndex == -1) {
                newEvent.sizeIndex = pixmap.sizes.length();
                pixmap.sizes << PixmapState(event.numericData1, event.numericData2);
            }

            PixmapState &state = pixmap.sizes[newEvent.sizeIndex];
            if (state.cacheState == ToBeCached) {
                lastCacheSizeEvent = d->updateCacheCount(lastCacheSizeEvent, startTime,
                                              state.size.width() * state.size.height(), newEvent);
                state.cacheState = Cached;
            }
            break;
        }
        case PixmapCacheCountChanged: {// Cache Size Changed Event
            startTime = event.startTime + 1; // delay 1 ns for proper sorting

            bool uncache = cumulatedCount > event.numericData3;
            cumulatedCount = event.numericData3;
            qint64 pixSize = 0;

            // First try to find a preferred pixmap, which either is Corrupt and will be uncached
            // or is uncached and will be cached.
            for (QVector<PixmapState>::iterator i(pixmap.sizes.begin());
                    i != pixmap.sizes.end(); ++i) {
                if (uncache && i->cacheState == Corrupt) {
                    newEvent.sizeIndex = i - pixmap.sizes.begin();
                    i->cacheState = Uncacheable;
                    break;
                } else if (!uncache && i->cacheState == Uncached) {
                    newEvent.sizeIndex = i - pixmap.sizes.begin();
                    if (i->size.isValid()) {
                        pixSize = i->size.width() * i->size.height();
                        i->cacheState = Cached;
                    } else {
                        i->cacheState = ToBeCached;
                    }
                    break;
                }
            }

            // If none found, check for cached or ToBeCached pixmaps that shall be uncached or
            // Error pixmaps that become corrupt cache entries. We also accept Initial to be
            // uncached as we may have missed the matching PixmapCacheCountChanged that cached it.
            if (newEvent.sizeIndex == -1) {
                for (QVector<PixmapState>::iterator i(pixmap.sizes.begin());
                        i != pixmap.sizes.end(); ++i) {
                    if (uncache && (i->cacheState == Cached || i->cacheState == ToBeCached ||
                                    i->cacheState == Uncached)) {
                        newEvent.sizeIndex = i - pixmap.sizes.begin();
                        if (i->size.isValid())
                            pixSize = -i->size.width() * i->size.height();
                        i->cacheState = Uncached;
                        break;
                    } else if (!uncache && i->cacheState == Uncacheable) {
                        newEvent.sizeIndex = i - pixmap.sizes.begin();
                        i->cacheState = Corrupt;
                        break;
                    }
                }
            }

            // If that does't work, create a new entry.
            if (newEvent.sizeIndex == -1) {
                newEvent.sizeIndex = pixmap.sizes.length();
                pixmap.sizes << PixmapState(uncache ? Uncached : ToBeCached);
            }

            lastCacheSizeEvent = d->updateCacheCount(lastCacheSizeEvent, startTime, pixSize,
                                                     newEvent);
            break;
        }
        case PixmapLoadingStarted: // Load
            // Look for a pixmap that hasn't been started, yet. There may have been a refcount
            // event, which we ignore.
            for (QVector<PixmapState>::const_iterator i(pixmap.sizes.cbegin());
                    i != pixmap.sizes.cend(); ++i) {
                if (i->loadState == Initial) {
                    newEvent.sizeIndex = i - pixmap.sizes.cbegin();
                    break;
                }
            }
            if (newEvent.sizeIndex == -1) {
                newEvent.sizeIndex = pixmap.sizes.length();
                pixmap.sizes << PixmapState();
            }
            pixmap.sizes[newEvent.sizeIndex].started = d->insertStart(startTime, newEvent);
            pixmap.sizes[newEvent.sizeIndex].loadState = Loading;
            break;
        case PixmapLoadingFinished:
        case PixmapLoadingError: {
            // First try to find one that has already started
            for (QVector<PixmapState>::const_iterator i(pixmap.sizes.cbegin());
                    i != pixmap.sizes.cend(); ++i) {
                if (i->loadState != Loading)
                    continue;
                // Pixmaps with known size cannot be errors and vice versa
                if (newEvent.pixmapEventType == PixmapLoadingError && i->size.isValid())
                    continue;

                newEvent.sizeIndex = i - pixmap.sizes.cbegin();
                break;
            }

            // If none was found use any other compatible one
            if (newEvent.sizeIndex == -1) {
                for (QVector<PixmapState>::const_iterator i(pixmap.sizes.cbegin());
                        i != pixmap.sizes.cend(); ++i) {
                    if (i->loadState != Initial)
                        continue;
                    // Pixmaps with known size cannot be errors and vice versa
                    if (newEvent.pixmapEventType == PixmapLoadingError && i->size.isValid())
                        continue;

                    newEvent.sizeIndex = i - pixmap.sizes.cbegin();
                    break;
                }
            }

            // If again none was found, create one.
            if (newEvent.sizeIndex == -1) {
                newEvent.sizeIndex = pixmap.sizes.length();
                pixmap.sizes << PixmapState();
            }

            PixmapState &state = pixmap.sizes[newEvent.sizeIndex];
            // If the pixmap loading wasn't started, start it at traceStartTime()
            if (state.loadState == Initial) {
                newEvent.pixmapEventType = PixmapLoadingStarted;
                state.started = d->insert(traceStartTime(), startTime - traceStartTime(), newEvent);

                // All other indices are wrong now as we've prepended. Fix them ...
                if (lastCacheSizeEvent >= state.started)
                    ++lastCacheSizeEvent;

                for (int pixmapIndex = 0; pixmapIndex < d->pixmaps.count(); ++pixmapIndex) {
                    Pixmap &brokenPixmap = d->pixmaps[pixmapIndex];
                    for (int sizeIndex = 0; sizeIndex < brokenPixmap.sizes.count(); ++sizeIndex) {
                        PixmapState &brokenSize = brokenPixmap.sizes[sizeIndex];
                        if ((pixmapIndex != newEvent.urlIndex || sizeIndex != newEvent.sizeIndex) &&
                                brokenSize.started >= state.started) {
                            ++brokenSize.started;
                        }
                    }
                }
            }

            d->insertEnd(state.started, startTime - d->range(state.started).start);
            if (newEvent.pixmapEventType == PixmapLoadingError) {
                state.loadState = Error;
                switch (state.cacheState) {
                case Uncached:
                    state.cacheState = Uncacheable;
                    break;
                case ToBeCached:
                    state.cacheState = Corrupt;
                    break;
                default:
                    // Cached cannot happen as size would have to be known and Corrupt or
                    // Uncacheable cannot happen as we only accept one finish or error event per
                    // pixmap.
                    Q_ASSERT(false);
                }
            } else {
                state.loadState = Finished;
            }
            break;
        }
        default:
            break;
        }

        d->modelManager->modelProxyCountUpdated(d->modelId, d->count(), 2*simpleModel->getEvents().count());
    }

    if (lastCacheSizeEvent != -1) {
        d->insertEnd(lastCacheSizeEvent, traceEndTime() - d->range(lastCacheSizeEvent).start);
    }

    d->resizeUnfinishedLoads();

    d->computeMaxCacheSize();
    d->flattenLoads();
    d->computeNesting();

    d->modelManager->modelProxyCountUpdated(d->modelId, 1, 1);
}

void PixmapCacheModel::clear()
{
    Q_D(PixmapCacheModel);
    d->clear();
    d->pixmaps.clear();
    d->collapsedRowCount = 1;
    d->maxCacheSize = 1;
    d->expanded = false;

    d->modelManager->modelProxyCountUpdated(d->modelId, 0, 1);
}

void PixmapCacheModel::PixmapCacheModelPrivate::computeMaxCacheSize()
{
    maxCacheSize = 1;
    foreach (const PixmapCacheModel::PixmapCacheEvent &event, ranges) {
        if (event.pixmapEventType == PixmapCacheModel::PixmapCacheCountChanged) {
            if (event.cacheSize > maxCacheSize)
                maxCacheSize = event.cacheSize;
        }
    }
}

void PixmapCacheModel::PixmapCacheModelPrivate::resizeUnfinishedLoads()
{
    Q_Q(PixmapCacheModel);
    // all the "load start" events with duration 0 continue till the end of the trace
    for (int i = 0; i < count(); i++) {
        if (range(i).pixmapEventType == PixmapCacheModel::PixmapLoadingStarted &&
                range(i).duration == 0) {
            insertEnd(i, q->traceEndTime() - range(i).start);
        }
    }
}

void PixmapCacheModel::PixmapCacheModelPrivate::flattenLoads()
{
    collapsedRowCount = 0;

    // computes "compressed row"
    QVector <qint64> eventEndTimes;
    for (int i = 0; i < count(); i++) {
        PixmapCacheModel::PixmapCacheEvent &event = data(i);
        const Range &start = range(i);
        if (event.pixmapEventType == PixmapCacheModel::PixmapLoadingStarted) {
            event.rowNumberCollapsed = 0;
            while (eventEndTimes.count() > event.rowNumberCollapsed &&
                   eventEndTimes[event.rowNumberCollapsed] > start.start)
                event.rowNumberCollapsed++;

            if (eventEndTimes.count() == event.rowNumberCollapsed)
                eventEndTimes << 0; // increase stack length, proper value added below
            eventEndTimes[event.rowNumberCollapsed] = start.start + start.duration;

            // readjust to account for category empty row and bargraph
            event.rowNumberCollapsed += 2;
        }
        if (event.rowNumberCollapsed > collapsedRowCount)
            collapsedRowCount = event.rowNumberCollapsed;
    }

    // Starting from 0, count is maxIndex+1
    collapsedRowCount++;
}

int PixmapCacheModel::PixmapCacheModelPrivate::updateCacheCount(int lastCacheSizeEvent,
        qint64 startTime, qint64 pixSize, PixmapCacheEvent &newEvent)
{
    newEvent.pixmapEventType = PixmapCacheCountChanged;
    newEvent.rowNumberCollapsed = 1;

    qint64 prevSize = 0;
    if (lastCacheSizeEvent != -1) {
        prevSize = range(lastCacheSizeEvent).cacheSize;
        insertEnd(lastCacheSizeEvent, startTime - range(lastCacheSizeEvent).start);
    }

    newEvent.cacheSize = prevSize + pixSize;
    return insertStart(startTime, newEvent);
}


} // namespace Internal
} // namespace QmlProfilerExtension