]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Updated get_times.cc to collect minimum times of multiple tests
authorcazamias <cazamias@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 10 Oct 2012 17:03:36 +0000 (17:03 +0000)
committercazamias <cazamias@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 10 Oct 2012 17:03:36 +0000 (17:03 +0000)
git-svn-id: https://svn.dealii.org/trunk@27057 0785d39b-7218-0410-832d-ea1e28bc413d

tests/benchmarks/gettimes/get_times.cc

index 87004bf14c8a5f31ff719009a4710077df98f5c1..8018899cd2feb73744ab99635455e928ec46ecdf 100644 (file)
 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<string> names;
        vector<double> 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++;
+
+               }
        }
 
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.