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 ' '
}
}
-
- //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++;
+
+ }
}