summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjasplin <qt-info@nokia.com>2010-04-28 10:26:52 +0200
committerjasplin <qt-info@nokia.com>2010-04-28 10:26:52 +0200
commit776f61bb811965a79526b5ed53ae577322f3333b (patch)
tree13e37f29af8bab16d64d1cc52e709cd8a8e78d18
parenta0284e23df74b4ee20fc454a2aaf8ad837e37cd4 (diff)
Individual value ranges for index contributors plots.
-rw-r--r--src/bm/bmrequest.cpp2
-rw-r--r--src/bm/plotter.cpp46
-rw-r--r--src/bm/plotter.h4
-rw-r--r--src/bm/resulthistoryinfo.cpp26
-rw-r--r--src/bm/resulthistoryinfo.h9
5 files changed, 67 insertions, 20 deletions
diff --git a/src/bm/bmrequest.cpp b/src/bm/bmrequest.cpp
index efc4276..587604a 100644
--- a/src/bm/bmrequest.cpp
+++ b/src/bm/bmrequest.cpp
@@ -7322,7 +7322,7 @@ void BMRequest_GetIXHistories::handleReply_Image(const QStringList &args) const
// Create image ...
QString error_;
Plotter *plotter =
- new HistoriesPlotter(rhInfos, true, evalTimestamp, &basePos, &extraPos, &descr);
+ new HistoriesPlotter(rhInfos, true, evalTimestamp, &basePos, &extraPos, &descr, false);
const QImage image = plotter->createImage(&error_);
// Free dynamic memory ...
diff --git a/src/bm/plotter.cpp b/src/bm/plotter.cpp
index a51784a..0430b90 100644
--- a/src/bm/plotter.cpp
+++ b/src/bm/plotter.cpp
@@ -692,13 +692,15 @@ bool IndexPlotter::drawScenes(
HistoriesPlotter::HistoriesPlotter(
const QList<ResultHistoryInfo *> &rhInfos, const bool showBenchmark, const int baseTimestamp,
- const QList<int> *basePos, const QList<QList<int> > *extraPos, const QStringList *extraDescr)
+ const QList<int> *basePos, const QList<QList<int> > *extraPos, const QStringList *extraDescr,
+ const bool commonValueRange)
: rhInfos(rhInfos)
, showBenchmark(showBenchmark)
, baseTimestamp(baseTimestamp)
, basePos(basePos)
, extraPos(extraPos)
, extraDescr(extraDescr)
+ , commonValueRange(commonValueRange)
, width(1200)
, rhHeight(
qMin(showBenchmark ? 220 : 170, qMax(showBenchmark ? 170 : 120, 800 / rhInfos.size())))
@@ -782,20 +784,22 @@ bool HistoriesPlotter::drawScenes(
}
}
- // Find global per-metric value ranges ...
QMap<QString, MetricInfo *> metricInfos;
- for (int i = 0; i < rhInfos.size(); ++i) {
- const ResultHistoryInfo *rhInfo = rhInfos.at(i);
- const QString metric = rhInfo->metric();
- if (!metricInfos.contains(metric)) {
- const qreal firstValue = rhInfo->value(0);
- metricInfos.insert(metric, new MetricInfo(firstValue, firstValue));
- }
- MetricInfo *metricInfo = metricInfos.value(metric);
- for (int j = 0; j < rhInfo->size(); ++j) {
- const qreal value = rhInfo->value(j);
- metricInfo->vmin = qMin(metricInfo->vmin, value);
- metricInfo->vmax = qMax(metricInfo->vmax, value);
+ if (commonValueRange) {
+ // Find global per-metric value ranges ...
+ for (int i = 0; i < rhInfos.size(); ++i) {
+ const ResultHistoryInfo *rhInfo = rhInfos.at(i);
+ const QString metric = rhInfo->metric();
+ if (!metricInfos.contains(metric)) {
+ const qreal firstValue = rhInfo->value(0);
+ metricInfos.insert(metric, new MetricInfo(firstValue, firstValue));
+ }
+ MetricInfo *metricInfo = metricInfos.value(metric);
+ for (int j = 0; j < rhInfo->size(); ++j) {
+ const qreal value = rhInfo->value(j);
+ metricInfo->vmin = qMin(metricInfo->vmin, value);
+ metricInfo->vmax = qMax(metricInfo->vmax, value);
+ }
}
}
@@ -825,9 +829,17 @@ bool HistoriesPlotter::drawScenes(
const qreal ymin = pad_top + rh * rhHeight + pad_rh;
const qreal ymax = pad_top + (rh + 1) * rhHeight - pad_rh;
const qreal ydefault = 0.5 * (ymin + ymax);
- MetricInfo *metricInfo = metricInfos.value(rhInfo->metric());
- const qreal vmin = metricInfo->vmin;
- const qreal vmax = metricInfo->vmax;
+ qreal vmin;
+ qreal vmax;
+ if (commonValueRange) {
+ MetricInfo *metricInfo = metricInfos.value(rhInfo->metric());
+ vmin = metricInfo->vmin;
+ vmax = metricInfo->vmax;
+ } else {
+ vmin = rhInfo->minValue();
+ vmax = rhInfo->maxValue();
+ }
+
const qreal vfact = 1 / (vmax - vmin); // zero division handled elsewhere:
const qreal yfact = vfact * (ymax - ymin);
diff --git a/src/bm/plotter.h b/src/bm/plotter.h
index d80ea24..789daae 100644
--- a/src/bm/plotter.h
+++ b/src/bm/plotter.h
@@ -102,7 +102,8 @@ public:
HistoriesPlotter(
const QList<ResultHistoryInfo *> &rhInfos, const bool showBenchmark = false,
const int baseTimestamp = -1, const QList<int> *basePos = 0,
- const QList<QList<int> > *extraPos = 0, const QStringList *extraDescr = 0);
+ const QList<QList<int> > *extraPos = 0, const QStringList *extraDescr = 0,
+ const bool commonValueRange = true);
private:
QList<ResultHistoryInfo *> rhInfos;
@@ -111,6 +112,7 @@ private:
const QList<int> *basePos;
const QList<QList<int> > *extraPos;
const QStringList *extraDescr;
+ bool commonValueRange;
qreal width;
qreal rhHeight;
qreal pad_top;
diff --git a/src/bm/resulthistoryinfo.cpp b/src/bm/resulthistoryinfo.cpp
index 94c69ff..7bd23ce 100644
--- a/src/bm/resulthistoryinfo.cpp
+++ b/src/bm/resulthistoryinfo.cpp
@@ -140,3 +140,29 @@ bool ResultHistoryInfo::getSmoothValues(int medianWinSize, QList<qreal> *smoothV
return true;
}
+
+// ### 2 B DOCUMENTED!
+qreal ResultHistoryInfo::minValue() const
+{
+ if (!hasCachedMinVal) {
+ cachedMinVal = values.first();
+ for (int i = 1; i < timestamps_.size(); ++i)
+ cachedMinVal = qMin(cachedMinVal, values.at(i));
+ hasCachedMinVal = true;
+ }
+
+ return cachedMinVal;
+}
+
+// ### 2 B DOCUMENTED!
+qreal ResultHistoryInfo::maxValue() const
+{
+ if (!hasCachedMaxVal) {
+ cachedMaxVal = values.first();
+ for (int i = 1; i < timestamps_.size(); ++i)
+ cachedMaxVal = qMax(cachedMaxVal, values.at(i));
+ hasCachedMaxVal = true;
+ }
+
+ return cachedMaxVal;
+}
diff --git a/src/bm/resulthistoryinfo.h b/src/bm/resulthistoryinfo.h
index a3af335..ae57cd7 100644
--- a/src/bm/resulthistoryinfo.h
+++ b/src/bm/resulthistoryinfo.h
@@ -38,7 +38,8 @@ public:
: bmcontextId_(bmcontextId), timestamps_(timestamps_), values(values)
, metric_(metric), platform_(platform), host_(host), gitRepo_(gitRepo)
, gitBranch_(gitBranch), testCase_(testCase), testFunction_(testFunction)
- , dataTag_(dataTag), cachedTimestamp(-1), cachedSmoothPos(-1)
+ , dataTag_(dataTag), cachedTimestamp(-1), cachedSmoothPos(-1), hasCachedMinVal(false)
+ , hasCachedMaxVal(false)
{
Q_ASSERT(!timestamps_.isEmpty());
Q_ASSERT(timestamps_.size() == values.size());
@@ -56,6 +57,8 @@ public:
int size() const { return timestamps_.size(); }
qreal timestamp(int i) const { return static_cast<qreal>(timestamps_.at(i)); }
qreal value(int i) const { return values.at(i); }
+ qreal minValue() const;
+ qreal maxValue() const;
int bmcontextId() const { return bmcontextId_; }
QString metric() const { return metric_; }
@@ -83,6 +86,10 @@ private:
QString dataTag_;
mutable bool cachedTimestamp;
mutable qreal cachedSmoothPos;
+ mutable bool hasCachedMinVal;
+ mutable bool hasCachedMaxVal;
+ mutable qreal cachedMinVal;
+ mutable qreal cachedMaxVal;
};
#endif // RESULTHISTORYINFO_H