summaryrefslogtreecommitdiffstats
path: root/grapher/Graph.cxx
diff options
context:
space:
mode:
authorTim Moore <timoore@redhat.com>2009-12-01 12:02:24 +0100
committerTim Moore <timoore@redhat.com>2009-12-01 12:30:42 +0100
commit572a176d481c329b370ce52e7bec1a49ed76c225 (patch)
treec4979af7c8089124ee0dd30d63ec14864ea0e9f9 /grapher/Graph.cxx
parent211c338e54b096a41170c5bac99eaf33959076f2 (diff)
downloadsystemtap-steved-572a176d481c329b370ce52e7bec1a49ed76c225.tar.gz
systemtap-steved-572a176d481c329b370ce52e7bec1a49ed76c225.tar.xz
systemtap-steved-572a176d481c329b370ce52e7bec1a49ed76c225.zip
change time type from double to int64_t
* grapher/Graph.hxx (Graph): Change variables holding the time limits of the displayed graph from double to int64_t. * grapher/Graph.cxx (Graph::draw): Do calculations of time differences using int64_t. (Graph::getExtents, Graph::setExtents): Change left and right arguments to int64_t. * grapher/GraphData.hxx (GraphDataBase): Change time type to int64_t. (GraphDataBase::elementAsString): New function. (GraphData::elementAsString): Implementation of that function. * grapher/StapParser.cxx (parseData): Parse time values from the stap script as 64 bit values.
Diffstat (limited to 'grapher/Graph.cxx')
-rw-r--r--grapher/Graph.cxx37
1 files changed, 22 insertions, 15 deletions
diff --git a/grapher/Graph.cxx b/grapher/Graph.cxx
index a7fe6fcf..e9aacd55 100644
--- a/grapher/Graph.cxx
+++ b/grapher/Graph.cxx
@@ -30,7 +30,7 @@ namespace systemtap
// line separation
int linesPossible = (int)(_graphWidth / (_lineWidth + 2.0));
// Find latest time.
- double latestTime = 0.0;
+ int64_t latestTime = 0;
for (DatasetList::iterator ditr = _datasets.begin(),
de = _datasets.end();
ditr != de;
@@ -38,13 +38,13 @@ namespace systemtap
{
if (!(*ditr)->times.empty())
{
- double lastDataTime = (*ditr)->times.back();
+ int64_t lastDataTime = (*ditr)->times.back();
if (lastDataTime > latestTime)
latestTime = lastDataTime;
}
}
- double minDiff = 0.0;
- double maxTotal = 0.0;
+ int64_t minDiff = 0;
+ int64_t maxTotal = 0;
for (DatasetList::iterator ditr = _datasets.begin(),
de = _datasets.end();
ditr != de;
@@ -59,11 +59,11 @@ namespace systemtap
ritr + 1 != gtimes.rend();
ritr++)
{
- double timeDiff = *ritr - *(ritr + 1);
+ int64_t timeDiff = *ritr - *(ritr + 1);
if (timeDiff < minDiff || (timeDiff != 0 && minDiff == 0))
minDiff = timeDiff;
if (minDiff != 0
- && (totalDiff + timeDiff) / minDiff > linesPossible)
+ && ((totalDiff + timeDiff) / minDiff + 1) > linesPossible)
break;
totalDiff += timeDiff;
}
@@ -75,10 +75,11 @@ namespace systemtap
if (maxTotal != 0)
_left = latestTime - maxTotal;
else
- _left = _right - 1.0;
+ _left = _right - 1;
}
cr->save();
- double horizScale = _zoomFactor * _graphWidth / ( _right - _left);
+ double horizScale
+ = _zoomFactor * _graphWidth / static_cast<double>(_right - _left);
cr->translate(20.0, 0.0);
cr->set_line_width(_lineWidth);
@@ -186,9 +187,10 @@ namespace systemtap
}
cr->restore();
// Draw axes
- double diff = _right - _left;
- double majorUnit = pow(10.0, floor(log(diff) / log(10.0)));
- double startTime = ceil(_left / majorUnit) * majorUnit;
+ double diff = static_cast<double>(_right - _left);
+ int64_t majorUnit
+ = static_cast<int64_t>(pow(10.0, floor(log(diff) / log(10.0))));
+ int64_t startTime = (_left / majorUnit) * majorUnit;
cr->save();
cr->set_source_rgba(1.0, 1.0, 1.0, .9);
cr->set_line_cap(Cairo::LINE_CAP_BUTT);
@@ -205,14 +207,14 @@ namespace systemtap
dash[0] = _graphHeight / 10;
cr->set_dash(dash, 0);
double prevTextAdvance = 0;
- for (double tickVal = startTime; tickVal <= _right; tickVal += majorUnit)
+ for (int64_t tickVal = startTime; tickVal <= _right; tickVal += majorUnit)
{
double x = (tickVal - _left) * horizScale + 20.0;
cr->move_to(x, 0.0);
cr->line_to(x, _graphHeight);
cr->move_to(x, _graphHeight - 5);
std::ostringstream stream;
- stream << std::fixed << std::setprecision(0) << tickVal;
+ stream << tickVal;
Cairo::TextExtents extents;
cr->get_text_extents(stream.str(), extents);
// Room for this label?
@@ -239,7 +241,7 @@ namespace systemtap
_datasets.push_back(data);
}
- void Graph::getExtents(double& left, double& right, double& top,
+ void Graph::getExtents(int64_t& left, int64_t& right, double& top,
double& bottom) const
{
left = _left;
@@ -248,7 +250,7 @@ namespace systemtap
bottom = _bottom;
}
- void Graph::setExtents(double left, double right, double top, double bottom)
+ void Graph::setExtents(int64_t left, int64_t right, double top, double bottom)
{
_left = left;
_right = right;
@@ -260,4 +262,9 @@ namespace systemtap
{
return x >= _x0 && x < _x0 + _width && y >= _y0 && y < _y0 + _height;
}
+
+ int64_t Graph::getTimeAtPoint(double x)
+ {
+ return _left + (_right - _left) * ((x - 20.0)/_graphWidth);
+ }
}