diff options
Diffstat (limited to 'grapher')
-rw-r--r-- | grapher/GraphData.hxx | 13 | ||||
-rw-r--r-- | grapher/StapParser.cxx | 56 |
2 files changed, 38 insertions, 31 deletions
diff --git a/grapher/GraphData.hxx b/grapher/GraphData.hxx index e4c08cfd..0e26fb4d 100644 --- a/grapher/GraphData.hxx +++ b/grapher/GraphData.hxx @@ -6,6 +6,8 @@ #include <vector> #include <tr1/memory> +#include <boost/circular_buffer.hpp> + namespace systemtap { struct GraphDataBase @@ -16,11 +18,12 @@ namespace systemtap DOT, EVENT }; - GraphDataBase() : scale(1.0), style(BAR) + typedef boost::circular_buffer<double> TimeList; + GraphDataBase(TimeList::capacity_type cap = 50000) + : scale(1.0), style(BAR), times(cap) { color[0] = 0.0; color[1] = 1.0; color[2] = 0.0; } - typedef std::vector<double> TimeList; // size of grid square at "normal" viewing double scale; double color[3]; @@ -36,7 +39,11 @@ namespace systemtap { public: typedef T data_type; - typedef std::vector<data_type> DataList; + typedef boost::circular_buffer<data_type> DataList; + GraphData(typename DataList::capacity_type cap = 50000) + : GraphDataBase(cap), data(cap) + { + } DataList data; }; struct CSVData diff --git a/grapher/StapParser.cxx b/grapher/StapParser.cxx index 249836d3..9e42dab6 100644 --- a/grapher/StapParser.cxx +++ b/grapher/StapParser.cxx @@ -156,18 +156,15 @@ vector<string> commaSplit(const boost::sub_range<Glib::ustring>& range) shared_ptr<GraphDataBase> gdata = itr->second; string decl; // Hack: scan from the beginning of dataString again - if (findTaggedValue(dataString, "%Title:", decl) - != string::npos) + if (findTaggedValue(dataString, "%Title:", decl)) { gdata->title = decl; } - else if (findTaggedValue(dataString, "%XAxisTitle:", decl) - != string::npos) + else if (findTaggedValue(dataString, "%XAxisTitle:", decl)) { gdata->xAxisText = decl; } - else if (findTaggedValue(dataString, "%YAxisTitle:", decl) - != string::npos) + else if (findTaggedValue(dataString, "%YAxisTitle:", decl)) { gdata->yAxisText = decl; } @@ -179,29 +176,32 @@ vector<string> commaSplit(const boost::sub_range<Glib::ustring>& range) stream >> ymax; gdata->scale = ymax; } - - if (!_csv.elements.empty()) - { - vector<string> tokens = commaSplit(dataString); - int i = 0; - double time; - vector<string>::iterator tokIter = tokens.begin(); - std::istringstream timeStream(*tokIter++); - timeStream >> time; - for (vector<string>::iterator e = tokens.end(); - tokIter != e; - ++tokIter, ++i) - { - parseData(_csv.elements[i].second, time, *tokIter); - } - } else - { - double time; - string data; - stream >> time >> data; - parseData(itr->second, time, data); - } + { + if (!_csv.elements.empty()) + { + vector<string> tokens = commaSplit(dataString); + int i = 0; + double time; + vector<string>::iterator tokIter = tokens.begin(); + std::istringstream timeStream(*tokIter++); + timeStream >> time; + for (vector<string>::iterator e = tokens.end(); + tokIter != e; + ++tokIter, ++i) + { + parseData(_csv.elements[i].second, time, + *tokIter); + } + } + else + { + double time; + string data; + stream >> time >> data; + parseData(itr->second, time, data); + } + } } } _buffer.erase(0, ret + 1); |