From c2a64df1c49530a90e48d1e45952d2a45d3d8288 Mon Sep 17 00:00:00 2001 From: Sebastian Piwell Date: Mon, 13 Jun 2016 16:10:31 -0400 Subject: [PATCH] Processing speed test --- modules/iswa/rendering/datacygnet.cpp | 3 ++ modules/iswa/rendering/datacygnet.h | 4 ++ modules/iswa/rendering/dataplane.cpp | 21 +++++++++- modules/iswa/util/dataprocessortext.cpp | 52 ++++++++++++++++++++----- 4 files changed, 69 insertions(+), 11 deletions(-) diff --git a/modules/iswa/rendering/datacygnet.cpp b/modules/iswa/rendering/datacygnet.cpp index 11dba221e0..c9f03d58b1 100644 --- a/modules/iswa/rendering/datacygnet.cpp +++ b/modules/iswa/rendering/datacygnet.cpp @@ -46,6 +46,9 @@ DataCygnet::DataCygnet(const ghoul::Dictionary& dictionary) ,_normValues("normValues", "Normalize Values", glm::vec2(1.0,1.0), glm::vec2(0), glm::vec2(5.0)) ,_backgroundValues("backgroundValues", "Background Values", glm::vec2(0.0), glm::vec2(0), glm::vec2(1.0)) ,_transferFunctionsFile("transferfunctions", "Transfer Functions", "${SCENE}/iswa/tfs/default.tf") + //FOR TESTING + ,_numOfBenchmarks(0) + ,_avgBenchmarkTime(0.0f) { addProperty(_dataOptions); addProperty(_useLog); diff --git a/modules/iswa/rendering/datacygnet.h b/modules/iswa/rendering/datacygnet.h index 1cfccdf7e2..67ccc62c13 100644 --- a/modules/iswa/rendering/datacygnet.h +++ b/modules/iswa/rendering/datacygnet.h @@ -102,6 +102,10 @@ protected: std::string _dataBuffer; glm::size3_t _textureDimensions; + //FOR TESTING + int _numOfBenchmarks; + double _avgBenchmarkTime; + private: bool readyToRender() const override; bool downloadTextureResource() override; diff --git a/modules/iswa/rendering/dataplane.cpp b/modules/iswa/rendering/dataplane.cpp index 2ec69aea64..c1dcfc8774 100644 --- a/modules/iswa/rendering/dataplane.cpp +++ b/modules/iswa/rendering/dataplane.cpp @@ -153,7 +153,26 @@ std::vector DataPlane::textureData(){ } } // _textureDimensions = _dataProcessor->dimensions(); - return _dataProcessor->processData(_dataBuffer, _dataOptions, _textureDimensions); + + // FOR TESTING + // =========== + std::chrono::time_point start, end; + start = std::chrono::system_clock::now(); + // =========== + std::vector d = _dataProcessor->processData(_dataBuffer, _dataOptions, _textureDimensions); + + // FOR TESTING + // =========== + end = std::chrono::system_clock::now(); + _numOfBenchmarks++; + std::chrono::duration elapsed_seconds = end-start; + _avgBenchmarkTime = ( (_avgBenchmarkTime * (_numOfBenchmarks-1)) + elapsed_seconds.count() ) / _numOfBenchmarks; + std::cout << " processData() " << name() << std::endl; + std::cout << "avg elapsed time: " << _avgBenchmarkTime << "s\n"; + std::cout << "num Benchmarks: " << _numOfBenchmarks << "\n"; + // =========== + + return d; } }// namespace openspace \ No newline at end of file diff --git a/modules/iswa/util/dataprocessortext.cpp b/modules/iswa/util/dataprocessortext.cpp index 1a665e8a26..ae1390bc7f 100644 --- a/modules/iswa/util/dataprocessortext.cpp +++ b/modules/iswa/util/dataprocessortext.cpp @@ -99,21 +99,24 @@ void DataProcessorText::addDataValues(std::string data, properties::SelectionPro std::vector values; float value; + int first, last, option, lineSize; + + while(getline(memorystream, line)){ if(line.find("#") == 0) continue; values = std::vector(); std::stringstream ss(line); copy( - std::istream_iterator (ss), + std::next( std::istream_iterator (ss), 3 ), //+3 because options x, y and z in the file std::istream_iterator (), back_inserter(values) ); - if(values.size() <= 0) continue; + if(values.size() <= 0) continue; for(int i=0; i DataProcessorText::processData(std::string data, properties: std::vector values; float value; + int first, last, option, lineSize; + std::vector dataOptions(numOptions, nullptr); for(int option : selectedOptions){ dataOptions[option] = new float[dimensions.x*dimensions.y]{0.0f}; @@ -149,20 +154,47 @@ std::vector DataProcessorText::processData(std::string data, properties: while(getline(memorystream, line)){ if(line.find("#") == 0) continue; - values = std::vector(); - int first = 0; - int last = 0; - int option = -3; - int lineSize = line.size(); + // ----------- OLD METHODS ------------------------ + // values = std::vector(); + // std::stringstream ss(line); + // float v; + // while(ss >> v){ + // values.push_back(v); + // } + + // copy( + // std::istream_iterator (ss), + // std::istream_iterator (), + // back_inserter(values) + // ); + + // copy( + // std::next( std::istream_iterator (ss), 3 ), //+3 because options x, y and z in the file + // std::istream_iterator (), + // back_inserter(values) + // ); + + // for(int option : selectedOptions){ + // value = values[option]; + // //value = values[option+3]; //+3 because options x, y and z in the file + // dataOptions[option][numValues] = processDataPoint(value, option); + // } + // ----------- OLD METHODS ------------------------ + + first = 0; + last = 0; + option = -3; + lineSize = line.size(); while(last < lineSize){ first = line.find_first_not_of(" \t", last); last = line.find_first_of(" \t", first); + last = (last > 0)? last : lineSize; + if(option >= 0){ - last = (last > 0)? last : lineSize; - // boost::spirit::qi::parse(&line[first], &line[last], boost::spirit::qi::double_, value); + // boost::spirit::qi::parse(&line[first], &line[last], boost::spirit::qi::float_, value); value = std::stof(line.substr(first, last)); if(std::find(selectedOptions.begin(), selectedOptions.end(), option) != selectedOptions.end())