#include "ResultDatabase.h" #include #include #include #include using namespace std; #define SORT_RETAIN_ATTS_ORDER 1 bool ResultDatabase::Result::operator<(const Result &rhs) const { if (test < rhs.test) return true; if (test > rhs.test) return false; #if (SORT_RETAIN_ATTS_ORDER == 0) // For ties, sort by the value of the attribute: if (atts < rhs.atts) return true; if (atts > rhs.atts) return false; #endif return false; // less-operator returns false on equal } double ResultDatabase::Result::GetMin() const { double r = FLT_MAX; for (int i=0; i= 100) return value[n-1]; double index = ((n + 1.) * q / 100.) - 1; vector sorted = value; sort(sorted.begin(), sorted.end()); if (n == 2) return (sorted[0] * (1 - q/100.) + sorted[1] * (q/100.)); int index_lo = int(index); double frac = index - index_lo; if (frac == 0) return sorted[index_lo]; double lo = sorted[index_lo]; double hi = sorted[index_lo + 1]; return lo + (hi-lo)*frac; } double ResultDatabase::Result::GetMean() const { double r = 0; for (int i=0; i &values) { for (int i=0; i= results.size()) { Result r; r.test = test; r.atts = atts; r.unit = unit; results.push_back(r); } results[index].value.push_back(value); } // **************************************************************************** // Method: ResultDatabase::DumpDetailed // // Purpose: // Writes the full results, including all trials. // // Arguments: // out where to print // // Programmer: Jeremy Meredith // Creation: August 14, 2009 // // Modifications: // Jeremy Meredith, Wed Nov 10 14:25:17 EST 2010 // Renamed to DumpDetailed to make room for a DumpSummary. // // Jeremy Meredith, Thu Nov 11 11:39:57 EST 2010 // Added note about (*) missing value tag. // // Jeremy Meredith, Tue Nov 23 13:57:02 EST 2010 // Changed note about missing values to be worded a little better. // // **************************************************************************** void ResultDatabase::DumpDetailed(ostream &out) { vector sorted(results); stable_sort(sorted.begin(), sorted.end()); const int testNameW = 24 ; const int attW = 12; const int fieldW = 11; out << std::fixed << right << std::setprecision(4); int maxtrials = 1; for (int i=0; i maxtrials) maxtrials = sorted[i].value.size(); } // TODO: in big parallel runs, the "trials" are the procs // and we really don't want to print them all out.... out << setw(testNameW) << "test\t" << setw(attW) << "atts\t" << setw(fieldW) << "median\t" << "mean\t" << "stddev\t" << "min\t" << "max\t"; for (int i=0; i sorted(results); stable_sort(sorted.begin(), sorted.end()); const int testNameW = 24 ; const int attW = 12; const int fieldW = 9; out << std::fixed << right << std::setprecision(4); // TODO: in big parallel runs, the "trials" are the procs // and we really don't want to print them all out.... out << setw(testNameW) << "test\t" << setw(attW) << "atts\t" << setw(fieldW) << "units\t" << "median\t" << "mean\t" << "stddev\t" << "min\t" << "max\t"; out << endl; for (int i=0; i sorted(results); stable_sort(sorted.begin(), sorted.end()); //Check to see if the file is empty - if so, add the headers emptyFile = this->IsFileEmpty(fileName); //Open file and append by default ofstream out; out.open(fileName.c_str(), std::ofstream::out | std::ofstream::app); //Add headers only for empty files if(emptyFile) { // TODO: in big parallel runs, the "trials" are the procs // and we really don't want to print them all out.... out << "test, " << "atts, " << "units, " << "median, " << "mean, " << "stddev, " << "min, " << "max, "; out << endl; } for (int i=0; i ResultDatabase::GetResultsForTest(const string &test) { // get only the given test results vector retval; for (int i=0; i & ResultDatabase::GetResults() const { return results; }