diff options
author | jasplin <qt-info@nokia.com> | 2010-04-28 09:46:09 +0200 |
---|---|---|
committer | jasplin <qt-info@nokia.com> | 2010-04-28 09:46:09 +0200 |
commit | a0284e23df74b4ee20fc454a2aaf8ad837e37cd4 (patch) | |
tree | af70b2a467e1f1eeb3538bb03a3a24a1f57ef291 | |
parent | ba708bd6409d6bf2ff27aaf934fabec69ad3949b (diff) |
Show base percentages.
-rw-r--r-- | src/bm/bmrequest.cpp | 53 | ||||
-rw-r--r-- | src/bm/plotter.cpp | 55 |
2 files changed, 59 insertions, 49 deletions
diff --git a/src/bm/bmrequest.cpp b/src/bm/bmrequest.cpp index 43ae06c..efc4276 100644 --- a/src/bm/bmrequest.cpp +++ b/src/bm/bmrequest.cpp @@ -5560,21 +5560,30 @@ void BMRequest_IndexGetValues::handleReply_HTML(const QStringList &args) const reply += "<br /><br />"; reply += "The <u>change</u> in index value between any two points in time indicates the "; - reply += "average performance increase during this time period in terms of a log2-based "; - reply += "difference. "; - reply += "An index value <u>change</u> of 1, 0, and -1 thus indicates a doubled, unchanged, "; + reply += "average performance increase during this time period in terms of a "; + reply += "<u>log2</u>-based difference. "; + reply += "An index value change of 1, 0, and -1 thus indicates a doubled, unchanged, "; reply += "and halved performance respectively. "; - reply += "(The corresponding linear factors would be 2, 1, and 0.5.)."; reply += "<br /><br />"; reply += "<b>Note:</b> Individual index values bear no useful meaning when regarded in "; reply += "isolation. The graph is however shifted vertically so that each individual index "; - reply += "value indicates the change from the index value at the given base time."; + reply += "value indicates the change from the index value at the given base time "; + reply += "(the latter being indicated by blue lines). "; reply += "<br /><br />"; - reply += "The base time is indicated by a blue vertical line."; + reply += "The <u>lefthand vertical axis</u> indicates how much the index value differs "; + reply += "from the index value at the base time. Note that the scale as such is linear "; + reply += "even though the values represent logarithmic differences."; + + reply += "<br /><br />"; + + reply += "The <u>rigthand vertical axis</u> indicates the performance as a percentage of "; + reply += "the performance at the base time. Note that the scale as such is logarithmic. "; + reply += "For example, the lefthand values -2, -1, 0, 1, and 2 map to the righthand values "; + reply += "25%, 50%, 100%, 200%, and 400% respectively."; reply += "</td></tr></table>\n"; @@ -5808,15 +5817,21 @@ void BMRequest_IndexGetValues::handleReply_HTML(const QStringList &args) const const int baseValuePos = argsElem.attributeNode("baseValuePos").value().toInt(&ok); Q_ASSERT(ok); const qreal baseValue = indexValues.at(baseValuePos); - const qreal linearBaseValue = qPow(2, baseValue); + + // Absolute log2 base diffs that are at or below minColorAbsVal will be highlighted by the + // "weakest" (i.e. least saturated) color (red or green depending on the sign), while those + // that are at or above maxColorAbsVal will be highlighted by the "strongest" (i.e. most + // saturated) color: + const qreal minColorAbsVal = 0.0; + const qreal maxColorAbsVal = 0.5; // Table 3 (log2 base diff factor) ... reply += "<td style=\"border: 0px\"><table>\n"; - reply += "<tr><th>Base diff (log2)</th></tr>\n"; + reply += "<tr><th>Base diff</th></tr>\n"; for (int i = 0; i < valueNodes.size(); ++i) { const int i_ = (valueNodes.size() - 1) - i; - const qreal indexValue = indexValues.at(i_) - baseValue; + const qreal baseDiff = indexValues.at(i_) - baseValue; const int contributions_ = contributions.at(i_); const QString style = "index_table"; @@ -5824,10 +5839,10 @@ void BMRequest_IndexGetValues::handleReply_HTML(const QStringList &args) const reply += "<tr>"; if (contributions_ > 0) { reply += QString( - "<td class=\"%1\" style=\"background-color:%2\">%3</td>") + "<td class=\"%1\" style=\"background-color:%2; text-align:right\">%3</td>") .arg(style) - .arg(BMMisc::redToGreenColor(indexValue, 0.01, 0.5, true)) - .arg(indexValue); + .arg(BMMisc::redToGreenColor(baseDiff, minColorAbsVal, maxColorAbsVal, true)) + .arg(QString().setNum(baseDiff, 'f', 4)); } else { reply += QString( "<td class=\"%1\" style=\"color:red; background-color:white\">n/a</td>").arg(style); @@ -5836,14 +5851,14 @@ void BMRequest_IndexGetValues::handleReply_HTML(const QStringList &args) const } reply += "</td></table>\n"; - // Table 4 (linear base diff factor) ... + // Table 4 (base %) ... reply += "<td style=\"border: 0px\"><table>\n"; - reply += "<tr><th>Base diff (linear)</th></tr>\n"; + reply += "<tr><th>Base %</th></tr>\n"; for (int i = 0; i < valueNodes.size(); ++i) { const int i_ = (valueNodes.size() - 1) - i; - const qreal indexValue = indexValues.at(i_) - baseValue; - const qreal linearIndexValue = linearIndexValues.at(i_) - linearBaseValue; + const qreal baseDiff = indexValues.at(i_) - baseValue; + const qreal basePercentage = 100 * qPow(2, baseDiff); const int contributions_ = contributions.at(i_); const QString style = "index_table"; @@ -5851,10 +5866,10 @@ void BMRequest_IndexGetValues::handleReply_HTML(const QStringList &args) const reply += "<tr>"; if (contributions_ > 0) { reply += QString( - "<td class=\"%1\" style=\"background-color:%2\">%3</td>") + "<td class=\"%1\" style=\"background-color:%2; text-align:right\">%3</td>") .arg(style) - .arg(BMMisc::redToGreenColor(indexValue, 0.01, 0.5, true)) - .arg(linearIndexValue); + .arg(BMMisc::redToGreenColor(baseDiff, minColorAbsVal, maxColorAbsVal, true)) + .arg(QString().setNum(basePercentage, 'f', 3)); } else { reply += QString( "<td class=\"%1\" style=\"color:red; background-color:white\">n/a</td>").arg(style); diff --git a/src/bm/plotter.cpp b/src/bm/plotter.cpp index 1569eef..a51784a 100644 --- a/src/bm/plotter.cpp +++ b/src/bm/plotter.cpp @@ -405,7 +405,6 @@ bool IndexPlotter::drawScenes( // Shift curve vertically according to base value if present ... QList<qreal> dispValues(values); const qreal dispBaseValue = 0.0; // by definition -// const qreal linearDispBaseValue = 0.0; // by definition qreal baseValue = 0.0; if (baseValuePos >= 0) { @@ -440,14 +439,6 @@ bool IndexPlotter::drawScenes( const qreal vfact = 1 / (vmax - vmin); // zero division handled elsewhere const qreal yfact = vfact * (ymax - ymin); - qreal linearVMin = 0.0; - qreal linearVMax = 0.0; - if ((baseValuePos >= 0) && (vminPos >= 0) && (vmaxPos >= 0)) { - const qreal linearBaseValue = qPow(2, baseValue); - linearVMin = qPow(2, values.at(vminPos)) - linearBaseValue; - linearVMax = qPow(2, values.at(vmaxPos)) - linearBaseValue; - } - // Compute scene coordinates of history curve ... QList<qreal> x; QList<qreal> y; @@ -494,16 +485,14 @@ bool IndexPlotter::drawScenes( if (baseValuePos >= 0) { // Draw line indicating the base value ... - QColor color(0, 0, 255); - color.setAlpha(100); + QColor color(50, 50, 255); const qreal y_base = BMMisc::v2y(dispBaseValue, ymax, vmin, yfact, ydefault); - scene_far->addLine(xmin, y_base, xmax, y_base, QPen(color, 1)); + scene_far->addLine(xmin, y_base, xmax, y_base, QPen(color, 2)); } if ((baseTimestamp >= timestamps.first()) && (baseTimestamp <= timestamps.last())) { // Draw line indicating the base timestamp ... - QColor color(0, 0, 255); - color.setAlpha(200); + QColor color(50, 50, 255); const qreal btx = xmin + (baseTimestamp - loTimestamp) * xfact; scene_far->addLine(btx, ymin, btx, ymax, QPen(color, 2)); } @@ -569,12 +558,14 @@ bool IndexPlotter::drawScenes( const qreal labelPad = 10; const qreal captionPad = 4; qreal captionHeight; + QFont axisCaptionFont; + axisCaptionFont.setPointSize(14); + QFont axisNumberFont; + axisNumberFont.setFamily("mono"); // ... left y axis ... { - QFont font; - font.setPointSize(14); - QGraphicsSimpleTextItem *text = scene_near->addSimpleText("base diff (log2)", font); + QGraphicsSimpleTextItem *text = scene_near->addSimpleText("base diff", axisCaptionFont); const qreal x_ = xmin - text->boundingRect().height() - captionPad; const qreal y_ = (ymin + ymax) / 2 + text->boundingRect().width() / 2; text->setTransform(QTransform().translate(x_, y_).rotate(-90)); @@ -582,14 +573,14 @@ bool IndexPlotter::drawScenes( } { QGraphicsSimpleTextItem *text = - scene_near->addSimpleText(QString().setNum(vmin)); + scene_near->addSimpleText(QString().setNum(vmin), axisNumberFont); text->setPos( xmin - captionPad - captionHeight - labelPad - text->boundingRect().width(), ymax - text->boundingRect().height() / 2); } { QGraphicsSimpleTextItem *text = - scene_near->addSimpleText(QString().setNum(vmax)); + scene_near->addSimpleText(QString().setNum(vmax), axisNumberFont); text->setPos( xmin - captionPad - captionHeight - labelPad - text->boundingRect().width(), ymin - text->boundingRect().height() / 2); @@ -597,7 +588,7 @@ bool IndexPlotter::drawScenes( if ((baseValuePos >= 0) && (dispBaseValue >= vmin) && (dispBaseValue <= vmax)) { QGraphicsSimpleTextItem *text = - scene_near->addSimpleText(QString().setNum(dispBaseValue)); + scene_near->addSimpleText(QString().setNum(dispBaseValue), axisNumberFont); const qreal y_base = BMMisc::v2y(dispBaseValue, ymax, vmin, yfact, ydefault); text->setPos( xmin - captionPad - captionHeight - labelPad - text->boundingRect().width(), @@ -611,12 +602,11 @@ bool IndexPlotter::drawScenes( } -#if 0 // ... right y axis ... + const qreal basePercentageLo = 100 * qPow(2, vmin); + const qreal basePercentageHi = 100 * qPow(2, vmax); { - QFont font; - font.setPointSize(14); - QGraphicsSimpleTextItem *text = scene_near->addSimpleText("base diff (linear)", font); + QGraphicsSimpleTextItem *text = scene_near->addSimpleText("base %", axisCaptionFont); const qreal x_ = xmax + captionPad; const qreal y_ = (ymin + ymax) / 2 + text->boundingRect().width() / 2; text->setTransform(QTransform().translate(x_, y_).rotate(-90)); @@ -624,23 +614,29 @@ bool IndexPlotter::drawScenes( } { QGraphicsSimpleTextItem *text = - scene_near->addSimpleText(QString().setNum(linearVMin)); + scene_near->addSimpleText( + QString("%1 %") + .arg(QString().setNum(basePercentageLo, 'f', 3).rightJustified(7, ' ')), + axisNumberFont); text->setPos( xmax + captionPad + captionHeight + labelPad, ymax - text->boundingRect().height() / 2); } { QGraphicsSimpleTextItem *text = - scene_near->addSimpleText(QString().setNum(linearVMax)); + scene_near->addSimpleText( + QString("%1 %") + .arg(QString().setNum(basePercentageHi, 'f', 3).rightJustified(7, ' ')), + axisNumberFont); text->setPos( xmax + captionPad + captionHeight + labelPad, ymin - text->boundingRect().height() / 2); } - if ((baseValuePos >= 0) - && (linearDispBaseValue >= linearVMin) && (linearDispBaseValue <= linearVMax)) { + if ((baseValuePos >= 0) && (basePercentageLo <= 100) && (100 <= basePercentageHi)) { QGraphicsSimpleTextItem *text = - scene_near->addSimpleText(QString().setNum(linearDispBaseValue)); + scene_near->addSimpleText( + QString("%1 %").arg(QString().setNum(100.0, 'f', 3)), axisNumberFont); const qreal y_base = BMMisc::v2y(dispBaseValue, ymax, vmin, yfact, ydefault); text->setPos( xmax + captionPad + captionHeight + labelPad, @@ -652,7 +648,6 @@ bool IndexPlotter::drawScenes( delete text; } } -#endif // ... top x axis ... |