From f25154d6b33da3797ce0b68fd752e9c46d64a25b Mon Sep 17 00:00:00 2001 From: cazamias Date: Wed, 10 Oct 2012 17:03:36 +0000 Subject: [PATCH] Updated get_times.cc to collect minimum times of multiple tests git-svn-id: https://svn.dealii.org/trunk@27057 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/benchmarks/gettimes/get_times.cc | 102 ++++++++++++++++--------- 1 file changed, 68 insertions(+), 34 deletions(-) diff --git a/tests/benchmarks/gettimes/get_times.cc b/tests/benchmarks/gettimes/get_times.cc index 87004bf14c..8018899cd2 100644 --- a/tests/benchmarks/gettimes/get_times.cc +++ b/tests/benchmarks/gettimes/get_times.cc @@ -12,32 +12,35 @@ using namespace std; int main(int argc, char *argv[]) { - + ifstream input; stringstream ss; const int IGNORE_LINES = 3; //Number of initial lines to ignore + const string DELIM = "*"; //String to divide test data input.open("temp.txt"); - ////cout << "Revision " << argv[1] << endl; - - //Ignore first n lines- they don't hold any useful data - for(int i = 0; i < IGNORE_LINES; i++) - { - string dummy; - getline(input, dummy); - } - vector names; vector times; - if(argc <= 1) { + //If no revision number, retrieve column names + if(argc <= 1) + { + string curr_line; + + //Ignore first n lines + delimeter- they don't hold any useful data + for(int i = 0; i < IGNORE_LINES + 1; i++) + { + getline(input, curr_line); + } + while(!input.eof()) { - //If no revision number, retrieve column names - string curr_line; + getline(input, curr_line); if(curr_line == "") continue; + if(curr_line == DELIM) + break; ////cout << "curr line: " << curr_line << endl; //Looking for the string after the '|' and ' ' @@ -61,30 +64,61 @@ int main(int argc, char *argv[]) { } } - - //Extract and execution time from each line - while(!input.eof()) + else //Else, extract execution time from each line { - string curr_line; - getline(input, curr_line); - ////cout << curr_line << endl; - if(curr_line == "") - continue; - //Looking for a number that ends with 's' - int last_s = curr_line.rfind('s'); - //In case 's' is not used in the future - assert(isdigit(curr_line[last_s - 1])); // Test: s preceded by number + int time_index = 0; + + while(!input.eof()) + { - //Find time string and convert to double - int num_start = last_s - 1; - while(curr_line[num_start] != ' ')//isdigit(curr_line[num_start]) || curr_line[num_start] == '.') - num_start--; - string timestr = curr_line.substr(num_start+1, last_s - num_start); - ////cout << timestr << endl; - double time = (double)atof(timestr.substr(0,timestr.size()-1).c_str()); - ////cout << time << endl; - times.push_back(time); + string curr_line = ""; + + //Read in line + getline(input,curr_line); + + //Check for delimeter + if(curr_line == DELIM) + { + ////cout << "Delimeter detected" << endl; + time_index = 0; + //Ignore first n lines- they don't hold any useful data + for(int i = 0; i < IGNORE_LINES; i++) + { + string dummy; + getline(input, dummy); + ////cout << "Skipping: " << dummy << endl; + } + continue; + } + + ////cout << "Reading: " << curr_line << endl; + + if(curr_line == "" && DELIM != "") + continue; + + + //Looking for a number that ends with 's' + int last_s = curr_line.rfind('s'); + //In case 's' is not used in the future + assert(isdigit(curr_line[last_s - 1])); // Test: s preceded by number + + //Find time string and convert to double + int num_start = last_s - 1; + while(curr_line[num_start] != ' ') + num_start--; + string timestr = curr_line.substr(num_start+1, last_s - num_start); + double time = (double)atof(timestr.substr(0,timestr.size()-1).c_str()); + + assert(times.size() >= time_index); + // first addition of times to vector; each loop, times.size() should be one less than time_index + if(times.size() == time_index) + times.push_back(time); + else + times[time_index] = (time < times[time_index]) ? time : times[time_index]; //else, determines minimum time and stores it + time_index++; + + } } -- 2.39.5