forked from qt-creator/qt-creator
QmlProfiler: Make time formatting available to all timeline models
... and remove some dead code. Change-Id: Ifdec932b87e8d33420d9713bfde9c4002f34844b Reviewed-by: Kai Koehne <kai.koehne@digia.com>
This commit is contained in:
@@ -544,7 +544,7 @@ void QmlProfilerEventsMainView::parseModelProxy()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (d->m_fieldShown[TotalTime]) {
|
if (d->m_fieldShown[TotalTime]) {
|
||||||
newRow << new EventsViewItem(displayTime(event.duration));
|
newRow << new EventsViewItem(QmlProfilerSimpleModel::formatTime(event.duration));
|
||||||
newRow.last()->setData(QVariant(event.duration));
|
newRow.last()->setData(QVariant(event.duration));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -554,22 +554,22 @@ void QmlProfilerEventsMainView::parseModelProxy()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (d->m_fieldShown[TimePerCall]) {
|
if (d->m_fieldShown[TimePerCall]) {
|
||||||
newRow << new EventsViewItem(displayTime(event.timePerCall));
|
newRow << new EventsViewItem(QmlProfilerSimpleModel::formatTime(event.timePerCall));
|
||||||
newRow.last()->setData(QVariant(event.timePerCall));
|
newRow.last()->setData(QVariant(event.timePerCall));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (d->m_fieldShown[MedianTime]) {
|
if (d->m_fieldShown[MedianTime]) {
|
||||||
newRow << new EventsViewItem(displayTime(event.medianTime));
|
newRow << new EventsViewItem(QmlProfilerSimpleModel::formatTime(event.medianTime));
|
||||||
newRow.last()->setData(QVariant(event.medianTime));
|
newRow.last()->setData(QVariant(event.medianTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (d->m_fieldShown[MaxTime]) {
|
if (d->m_fieldShown[MaxTime]) {
|
||||||
newRow << new EventsViewItem(displayTime(event.maxTime));
|
newRow << new EventsViewItem(QmlProfilerSimpleModel::formatTime(event.maxTime));
|
||||||
newRow.last()->setData(QVariant(event.maxTime));
|
newRow.last()->setData(QVariant(event.maxTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (d->m_fieldShown[MinTime]) {
|
if (d->m_fieldShown[MinTime]) {
|
||||||
newRow << new EventsViewItem(displayTime(event.minTime));
|
newRow << new EventsViewItem(QmlProfilerSimpleModel::formatTime(event.minTime));
|
||||||
newRow.last()->setData(QVariant(event.minTime));
|
newRow.last()->setData(QVariant(event.minTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -604,16 +604,6 @@ void QmlProfilerEventsMainView::parseModelProxy()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QmlProfilerEventsMainView::displayTime(double time)
|
|
||||||
{
|
|
||||||
if (time < 1e6)
|
|
||||||
return QString::number(time/1e3,'f',3) + trUtf8(" \xc2\xb5s");
|
|
||||||
if (time < 1e9)
|
|
||||||
return QString::number(time/1e6,'f',3) + tr(" ms");
|
|
||||||
|
|
||||||
return QString::number(time/1e9,'f',3) + tr(" s");
|
|
||||||
}
|
|
||||||
|
|
||||||
QString QmlProfilerEventsMainView::nameForType(int typeNumber)
|
QString QmlProfilerEventsMainView::nameForType(int typeNumber)
|
||||||
{
|
{
|
||||||
switch (typeNumber) {
|
switch (typeNumber) {
|
||||||
@@ -828,13 +818,13 @@ void QmlProfilerEventRelativesView::rebuildTree(QmlProfilerEventRelativesModelPr
|
|||||||
// no indirections at this level of abstraction!
|
// no indirections at this level of abstraction!
|
||||||
newRow << new EventsViewItem(event.displayName);
|
newRow << new EventsViewItem(event.displayName);
|
||||||
newRow << new EventsViewItem(QmlProfilerEventsMainView::nameForType(event.eventType));
|
newRow << new EventsViewItem(QmlProfilerEventsMainView::nameForType(event.eventType));
|
||||||
newRow << new EventsViewItem(QmlProfilerEventsMainView::displayTime(event.duration));
|
newRow << new EventsViewItem(QmlProfilerSimpleModel::formatTime(event.duration));
|
||||||
newRow << new EventsViewItem(QString::number(event.calls));
|
newRow << new EventsViewItem(QString::number(event.calls));
|
||||||
newRow << new EventsViewItem(event.details);
|
newRow << new EventsViewItem(event.details);
|
||||||
|
|
||||||
// newRow << new EventsViewItem(event->reference->displayName);
|
// newRow << new EventsViewItem(event->reference->displayName);
|
||||||
// newRow << new EventsViewItem(QmlProfilerEventsMainView::nameForType(event->reference->eventType));
|
// newRow << new EventsViewItem(QmlProfilerEventsMainView::nameForType(event->reference->eventType));
|
||||||
// newRow << new EventsViewItem(QmlProfilerEventsMainView::displayTime(event->duration));
|
// newRow << new EventsViewItem(QmlProfilerSimpleModel::formatTime(event->duration));
|
||||||
// newRow << new EventsViewItem(QString::number(event->calls));
|
// newRow << new EventsViewItem(QString::number(event->calls));
|
||||||
// newRow << new EventsViewItem(event->reference->details);
|
// newRow << new EventsViewItem(event->reference->details);
|
||||||
newRow.at(0)->setData(QVariant(key), EventHashStrRole);
|
newRow.at(0)->setData(QVariant(key), EventHashStrRole);
|
||||||
|
|||||||
@@ -115,7 +115,6 @@ public:
|
|||||||
void copyTableToClipboard() const;
|
void copyTableToClipboard() const;
|
||||||
void copyRowToClipboard() const;
|
void copyRowToClipboard() const;
|
||||||
|
|
||||||
static QString displayTime(double time);
|
|
||||||
static QString nameForType(int typeNumber);
|
static QString nameForType(int typeNumber);
|
||||||
|
|
||||||
void getStatisticsInRange(qint64 rangeStart, qint64 rangeEnd);
|
void getStatisticsInRange(qint64 rangeStart, qint64 rangeEnd);
|
||||||
|
|||||||
@@ -56,7 +56,6 @@ public:
|
|||||||
PaintEventsModelProxyPrivate(PaintEventsModelProxy *qq) : q(qq) {}
|
PaintEventsModelProxyPrivate(PaintEventsModelProxy *qq) : q(qq) {}
|
||||||
~PaintEventsModelProxyPrivate() {}
|
~PaintEventsModelProxyPrivate() {}
|
||||||
|
|
||||||
QString displayTime(double time);
|
|
||||||
void computeAnimationCountLimit();
|
void computeAnimationCountLimit();
|
||||||
|
|
||||||
int minAnimationCount;
|
int minAnimationCount;
|
||||||
@@ -281,16 +280,6 @@ const QVariantList PaintEventsModelProxy::getLabelsForCategory(int category) con
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString PaintEventsModelProxy::PaintEventsModelProxyPrivate::displayTime(double time)
|
|
||||||
{
|
|
||||||
if (time < 1e6)
|
|
||||||
return QString::number(time/1e3,'f',3) + trUtf8(" \xc2\xb5s");
|
|
||||||
if (time < 1e9)
|
|
||||||
return QString::number(time/1e6,'f',3) + tr(" ms");
|
|
||||||
|
|
||||||
return QString::number(time/1e9,'f',3) + tr(" s");
|
|
||||||
}
|
|
||||||
|
|
||||||
void PaintEventsModelProxy::PaintEventsModelProxyPrivate::computeAnimationCountLimit()
|
void PaintEventsModelProxy::PaintEventsModelProxyPrivate::computeAnimationCountLimit()
|
||||||
{
|
{
|
||||||
minAnimationCount = 1;
|
minAnimationCount = 1;
|
||||||
@@ -321,7 +310,8 @@ const QVariantList PaintEventsModelProxy::getEventDetails(int index) const
|
|||||||
// duration
|
// duration
|
||||||
{
|
{
|
||||||
QVariantMap valuePair;
|
QVariantMap valuePair;
|
||||||
valuePair.insert(QCoreApplication::translate(trContext, "Duration:"), QVariant(d->displayTime(d->range(index).duration)));
|
valuePair.insert(QCoreApplication::translate(trContext, "Duration:"),
|
||||||
|
QVariant(QmlProfilerSimpleModel::formatTime(d->range(index).duration)));
|
||||||
result << valuePair;
|
result << valuePair;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -105,4 +105,14 @@ QString QmlProfilerSimpleModel::getHashString(const QmlProfilerSimpleModel::QmlE
|
|||||||
QString::number(event.bindingType));
|
QString::number(event.bindingType));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString QmlProfilerSimpleModel::formatTime(qint64 timestamp)
|
||||||
|
{
|
||||||
|
if (timestamp < 1e6)
|
||||||
|
return QString::number(timestamp/1e3f,'f',3) + trUtf8(" \xc2\xb5s");
|
||||||
|
if (timestamp < 1e9)
|
||||||
|
return QString::number(timestamp/1e6f,'f',3) + tr(" ms");
|
||||||
|
|
||||||
|
return QString::number(timestamp/1e9f,'f',3) + tr(" s");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ public:
|
|||||||
qint64 lastTimeMark() const;
|
qint64 lastTimeMark() const;
|
||||||
|
|
||||||
static QString getHashString(const QmlProfilerSimpleModel::QmlEventData &event);
|
static QString getHashString(const QmlProfilerSimpleModel::QmlEventData &event);
|
||||||
|
static QString formatTime(qint64 timestamp);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QVector<QmlEventData> eventList;
|
QVector<QmlEventData> eventList;
|
||||||
|
|||||||
@@ -64,8 +64,6 @@ public:
|
|||||||
void findBindingLoops();
|
void findBindingLoops();
|
||||||
void computeRowStarts();
|
void computeRowStarts();
|
||||||
|
|
||||||
QString displayTime(double time);
|
|
||||||
|
|
||||||
QVector <BasicTimelineModel::QmlRangeEventData> eventDict;
|
QVector <BasicTimelineModel::QmlRangeEventData> eventDict;
|
||||||
QVector <QString> eventHashes;
|
QVector <QString> eventHashes;
|
||||||
QVector <CategorySpan> categorySpan;
|
QVector <CategorySpan> categorySpan;
|
||||||
@@ -443,16 +441,6 @@ const QVariantList BasicTimelineModel::getLabelsForCategory(int category) const
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString BasicTimelineModel::BasicTimelineModelPrivate::displayTime(double time)
|
|
||||||
{
|
|
||||||
if (time < 1e6)
|
|
||||||
return QString::number(time/1e3,'f',3) + trUtf8(" \xc2\xb5s");
|
|
||||||
if (time < 1e9)
|
|
||||||
return QString::number(time/1e6,'f',3) + tr(" ms");
|
|
||||||
|
|
||||||
return QString::number(time/1e9,'f',3) + tr(" s");
|
|
||||||
}
|
|
||||||
|
|
||||||
const QVariantList BasicTimelineModel::getEventDetails(int index) const
|
const QVariantList BasicTimelineModel::getEventDetails(int index) const
|
||||||
{
|
{
|
||||||
QVariantList result;
|
QVariantList result;
|
||||||
@@ -468,7 +456,8 @@ const QVariantList BasicTimelineModel::getEventDetails(int index) const
|
|||||||
// duration
|
// duration
|
||||||
{
|
{
|
||||||
QVariantMap valuePair;
|
QVariantMap valuePair;
|
||||||
valuePair.insert(QCoreApplication::translate(trContext, "Duration:"), QVariant(d->displayTime(d->range(index).duration)));
|
valuePair.insert(QCoreApplication::translate(trContext, "Duration:"),
|
||||||
|
QVariant(QmlProfilerSimpleModel::formatTime(d->range(index).duration)));
|
||||||
result << valuePair;
|
result << valuePair;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -443,7 +443,7 @@ void QV8ProfilerEventsMainView::QV8ProfilerEventsMainViewPrivate::buildV8ModelFr
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_fieldShown[TotalTime]) {
|
if (m_fieldShown[TotalTime]) {
|
||||||
newRow << new EventsViewItem(displayTime(v8event->totalTime));
|
newRow << new EventsViewItem(QmlProfilerSimpleModel::formatTime(v8event->totalTime));
|
||||||
newRow.last()->setData(QVariant(v8event->totalTime));
|
newRow.last()->setData(QVariant(v8event->totalTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -453,7 +453,7 @@ void QV8ProfilerEventsMainView::QV8ProfilerEventsMainViewPrivate::buildV8ModelFr
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_fieldShown[SelfTime]) {
|
if (m_fieldShown[SelfTime]) {
|
||||||
newRow << new EventsViewItem(displayTime(v8event->selfTime));
|
newRow << new EventsViewItem(QmlProfilerSimpleModel::formatTime(v8event->selfTime));
|
||||||
newRow.last()->setData(QVariant(v8event->selfTime));
|
newRow.last()->setData(QVariant(v8event->selfTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -480,28 +480,6 @@ void QV8ProfilerEventsMainView::QV8ProfilerEventsMainViewPrivate::buildV8ModelFr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QV8ProfilerEventsMainView::displayTime(double time)
|
|
||||||
{
|
|
||||||
if (time < 1e6)
|
|
||||||
return QString::number(time/1e3,'f',3) + trUtf8(" \xc2\xb5s");
|
|
||||||
if (time < 1e9)
|
|
||||||
return QString::number(time/1e6,'f',3) + tr(" ms");
|
|
||||||
|
|
||||||
return QString::number(time/1e9,'f',3) + tr(" s");
|
|
||||||
}
|
|
||||||
|
|
||||||
QString QV8ProfilerEventsMainView::nameForType(int typeNumber)
|
|
||||||
{
|
|
||||||
switch (typeNumber) {
|
|
||||||
case 0: return QV8ProfilerEventsMainView::tr("Paint");
|
|
||||||
case 1: return QV8ProfilerEventsMainView::tr("Compile");
|
|
||||||
case 2: return QV8ProfilerEventsMainView::tr("Create");
|
|
||||||
case 3: return QV8ProfilerEventsMainView::tr("Binding");
|
|
||||||
case 4: return QV8ProfilerEventsMainView::tr("Signal");
|
|
||||||
}
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
|
|
||||||
int QV8ProfilerEventsMainView::selectedEventId() const
|
int QV8ProfilerEventsMainView::selectedEventId() const
|
||||||
{
|
{
|
||||||
QModelIndex index = selectedItem();
|
QModelIndex index = selectedItem();
|
||||||
@@ -687,7 +665,7 @@ void QV8ProfilerEventRelativesView::rebuildTree(QList<QV8EventSub*> events)
|
|||||||
foreach (QV8EventSub *event, events) {
|
foreach (QV8EventSub *event, events) {
|
||||||
QList<QStandardItem *> newRow;
|
QList<QStandardItem *> newRow;
|
||||||
newRow << new EventsViewItem(event->reference->displayName);
|
newRow << new EventsViewItem(event->reference->displayName);
|
||||||
newRow << new EventsViewItem(QV8ProfilerEventsMainView::displayTime(event->totalTime));
|
newRow << new EventsViewItem(QmlProfilerSimpleModel::formatTime(event->totalTime));
|
||||||
newRow << new EventsViewItem(event->reference->functionName);
|
newRow << new EventsViewItem(event->reference->functionName);
|
||||||
newRow.at(0)->setData(QVariant(event->reference->eventId), EventIdRole);
|
newRow.at(0)->setData(QVariant(event->reference->eventId), EventIdRole);
|
||||||
newRow.at(1)->setData(QVariant(event->totalTime));
|
newRow.at(1)->setData(QVariant(event->totalTime));
|
||||||
|
|||||||
@@ -101,9 +101,6 @@ public:
|
|||||||
void copyTableToClipboard() const;
|
void copyTableToClipboard() const;
|
||||||
void copyRowToClipboard() const;
|
void copyRowToClipboard() const;
|
||||||
|
|
||||||
static QString displayTime(double time);
|
|
||||||
static QString nameForType(int typeNumber);
|
|
||||||
|
|
||||||
int selectedEventId() const;
|
int selectedEventId() const;
|
||||||
|
|
||||||
void setShowExtendedStatistics(bool);
|
void setShowExtendedStatistics(bool);
|
||||||
|
|||||||
Reference in New Issue
Block a user