def _store_percentiles(self):
     """Stores the LaTeX string representing the query percentiles table
     on the output object."""
     db_constraint_list = self._config.get_constraint_list(
         require_correct=True)
     db_categories = self._config.results_db.get_unique_query_values(
         simple_fields=[(t1s.DBF_TABLENAME, t1s.DBF_NUMRECORDS),
                        (t1s.DBF_TABLENAME, t1s.DBF_RECORDSIZE)],
         constraint_list=db_constraint_list)
     # the object to be stored and then iterated over in jinja:
     self._outp["databases"] = {}
     for (dbnr, dbrs) in db_categories:
         db_inp = t1ai.Input()
         db_inp[t1s.DBF_NUMRECORDS] = dbnr
         db_inp[t1s.DBF_RECORDSIZE] = dbrs
         query_constraint_list = db_constraint_list + db_inp.get_constraint_list(
         )
         query_categories = self._config.results_db.get_unique_query_values(
             simple_fields=[(t1s.DBF_TABLENAME, t1s.DBF_CAT),
                            (t1s.DBP_TABLENAME, t1s.DBP_SELECTIONCOLS)],
             constraint_list=query_constraint_list)
         self._outp["databases"][(dbnr, dbrs)] = {
             'name': db_inp.test_db.get_short_database_name(),
             'query_cats': []
         }
         for (query_cat, selection_cols) in query_categories:
             query_inp = t1ai.Input()
             query_inp[t1s.DBF_CAT] = query_cat
             query_inp[t1s.DBF_NUMRECORDS] = dbnr
             query_inp[t1s.DBF_RECORDSIZE] = dbrs
             query_inp[t1s.DBP_SELECTIONCOLS] = selection_cols
             latency_percentiles = LatencyPercentiles(
                 self, self._config, query_inp)
             self._outp["databases"][(
                 dbnr, dbrs)]['query_cats'].append(latency_percentiles)
Beispiel #2
0
 def test_get_complete_constraint_list(self):
     db_num_records = 800
     db_record_size = 10
     cat = t1s.CATEGORIES.to_string(t1s.CATEGORIES.P1)
     subcat = t1s.SUBCATEGORIES[t1s.CATEGORIES.P1].to_string(
         t1s.SUBCATEGORIES[t1s.CATEGORIES.P1].eqcnf)
     subsubcat = sr.choice(
         t1s.SUBSUBCATEGORIES[(t1s.CATEGORIES.P1,
                               t1s.SUBCATEGORIES[t1s.CATEGORIES.P1].eqcnf)])
     selection_cols = sr.choice(t1s.SELECTION_COLS)
     field = sr.choice(sv.VARS.numbers_list())
     inp = t1ai.Input()
     inp[t1s.DBF_NUMRECORDS] = db_num_records
     inp[t1s.DBF_RECORDSIZE] = db_record_size
     inp[t1s.DBF_CAT] = cat
     inp[t1s.DBF_SUBCAT] = subcat
     inp[t1s.DBF_SUBSUBCAT] = subsubcat
     inp[t1s.DBP_SELECTIONCOLS] = selection_cols
     inp[t1s.DBA_FIELD] = field
     expected_constraint_list = [
         (t1s.DBF_TABLENAME, t1s.DBF_NUMRECORDS, db_num_records),
         (t1s.DBF_TABLENAME, t1s.DBF_RECORDSIZE, db_record_size),
         (t1s.DBF_TABLENAME, t1s.DBF_CAT, cat),
         (t1s.DBF_TABLENAME, t1s.DBF_SUBCAT, subcat),
         (t1s.DBF_TABLENAME, t1s.DBF_SUBSUBCAT, subsubcat),
         (t1s.DBP_TABLENAME, t1s.DBP_SELECTIONCOLS, selection_cols),
         (t1s.DBA_TABLENAME, t1s.DBA_FIELD, field)
     ]
     actual_constraint_list = inp.get_constraint_list()
     self.assertEquals(expected_constraint_list, actual_constraint_list)
Beispiel #3
0
 def test_get_constraint_list(self):
     inp = t1ai.Input()
     inp[t1s.DBF_NUMRECORDS] = 800
     cat = t1s.CATEGORIES.to_string(t1s.CATEGORIES.EQ)
     inp[t1s.DBF_CAT] = cat
     expected_constraint_list = [(t1s.DBF_TABLENAME,
                                  t1s.DBF_NUMRECORDS, 800),
                                 (t1s.DBF_TABLENAME, t1s.DBF_CAT, cat)]
     actual_constraint_list = inp.get_constraint_list()
     self.assertEquals(expected_constraint_list, actual_constraint_list)
Beispiel #4
0
 def test_get_test_database(self):
     db_num_records = 800
     db_record_size = 10
     inp = t1ai.Input()
     inp[t1s.DBF_NUMRECORDS] = db_num_records
     inp[t1s.DBF_RECORDSIZE] = db_record_size
     self.assertEquals(
         inp.test_db,
         t1tdb.TestDatabase(
             short_database_names=config.SHORT_DATABASE_NAMES,
             db_num_records=db_num_records,
             db_record_size=db_record_size))
Beispiel #5
0
 def _store_query_latency_table(self):
     """Stores the LaTeX string representing the query latency table
     on the output object."""
     constraint_list = self._config.get_constraint_list(
         require_correct=True)
     categories = self._config.results_db.get_unique_query_values(
         simple_fields=[(t1s.DBF_TABLENAME, t1s.DBF_NUMRECORDS),
                        (t1s.DBF_TABLENAME, t1s.DBF_RECORDSIZE),
                        (t1s.DBP_TABLENAME, t1s.DBP_SELECTIONCOLS),
                        (t1s.DBF_TABLENAME, t1s.DBF_CAT)],
         constraint_list=constraint_list)
     # create the latency table:
     latency_table = latex_classes.LatexTable(
         "Query Latency vs. Number of Records Returned Best Fit Functions",
         "lat_main", [
             "DBNR", "DBRS", "Select", "Query Type", "Best-Fit Func",
             "R-Squared"
         ])
     # compute correctness for every query category:
     for (dbnr, dbrs, selection_cols, query_cat) in categories:
         inp = t1ai.Input()
         inp[t1s.DBF_CAT] = query_cat
         inp[t1s.DBF_NUMRECORDS] = dbnr
         inp[t1s.DBF_RECORDSIZE] = dbrs
         inp[t1s.DBP_SELECTIONCOLS] = selection_cols
         this_constraint_list = constraint_list + inp.get_constraint_list()
         [x_values, y_values] = self._config.results_db.get_query_values(
             simple_fields=[(t1s.DBP_TABLENAME,
                             t1s.DBP_NUMNEWRETURNEDRECORDS),
                            (t1s.DBP_TABLENAME, t1s.DBP_QUERYLATENCY)],
             constraint_list=this_constraint_list)
         try:
             inputs = [x_values]
             outputs = y_values
             function = regression.regress(
                 function_to_regress=self._config.ql_all_ftr,
                 outputs=outputs,
                 inputs=inputs)
             function_string = function.string
             rsquared = function.get_rsquared(inputs, outputs)
         except regression.BadRegressionInputError:
             function_string = "-"
             rsquared = "-"
         latency_table.add_content([
             inp.test_db.get_db_num_records_str(),
             inp.test_db.get_db_record_size_str(), selection_cols,
             query_cat, function_string, rsquared
         ])
     self._outp["query_latency_table"] = latency_table.get_string()
 def test_get_tag(self):
     this_config = ta1_config.Ta1Config()
     this_config.performername = "white knight"
     this_config.results_db_path = ":memory:"
     this_report_generator = t1rg.Ta1ReportGenerator(jinja_env=None,
                                                     config=this_config)
     this_section = ta1_section.Ta1Section(
         jinja_template=None, report_generator=this_report_generator)
     this_db_num_records = 101
     this_query_subcat = "eq-and"
     this_selection_cols = "*"
     this_inp = t1ai.Input()
     this_inp[t1s.DBF_NUMRECORDS] = this_db_num_records
     this_inp[t1s.DBF_SUBCAT] = this_query_subcat
     this_inp[t1s.DBP_SELECTIONCOLS] = this_selection_cols
     self.assertEqual(this_section.get_tag(inp=this_inp),
                      "Ta1Section_whiteknight_101_eq-and_*")
Beispiel #7
0
 def _store_query_throughput_table(self):
     """Stores the LaTeX string representing the query throughput table
     on the output object."""
     constraint_list = self._config.get_constraint_list(throughput=True)
     categories = self._config.results_db.get_unique_query_values(
         simple_fields=[(t1s.DBF_TABLENAME, t1s.DBF_NUMRECORDS),
                        (t1s.DBF_TABLENAME, t1s.DBF_RECORDSIZE),
                        (t1s.DBP_TABLENAME, t1s.DBP_SELECTIONCOLS),
                        (t1s.DBF_TABLENAME, t1s.DBF_CAT),
                        (t1s.DBP_TABLENAME, t1s.DBP_TESTCASEID)],
         constraint_list=constraint_list)
     # create the latency table:
     throughput_table = latex_classes.LatexTable(
         "Query Throughputs",
         "thru_main",
         ["DBNR", "DBRS", "Select", "Query Type",
          "testcase", "count", "throughput"])
     # compute correctness for every query category:
     for (dbnr, dbrs, selection_cols, query_cat, tcid) in categories:
         inp = t1ai.Input()
         inp[t1s.DBF_CAT] = query_cat
         inp[t1s.DBF_NUMRECORDS] = dbnr
         inp[t1s.DBF_RECORDSIZE] = dbrs
         inp[t1s.DBP_SELECTIONCOLS] = selection_cols
         this_constraint_list = constraint_list + inp.get_constraint_list() + [
             (t1s.DBP_TABLENAME, t1s.DBP_TESTCASEID, tcid)]
         [starttimes, endtimes] = self._config.results_db.get_query_values(
             simple_fields=[(t1s.DBP_TABLENAME, t1s.DBP_SENDTIME),
                            (t1s.DBP_TABLENAME, t1s.DBP_RESULTSTIME)],
             constraint_list=this_constraint_list)
         numqueries = len(starttimes)
         assert len(endtimes) == numqueries
         starttime = min(starttimes)
         endtime = max(endtimes)
         duration = endtime - starttime
         if numqueries > 0:
             throughput = numqueries / duration
             throughput_table.add_content(
                 [inp.test_db.get_db_num_records_str(),
                  inp.test_db.get_db_record_size_str(),
                  selection_cols, query_cat,
                  tcid, str(numqueries), str(round(throughput, 3))])
     self._outp["query_throughput_table"] = throughput_table.get_string()
Beispiel #8
0
 def _store_query_percentiles_table(self):
     """Stores the LaTeX string representing the query percentiles table
     on the output object."""
     constraint_list = self._config.get_constraint_list(
         require_correct=True)
     categories = self._config.results_db.get_unique_query_values(
         simple_fields=[(t1s.DBF_TABLENAME, t1s.DBF_NUMRECORDS),
                        (t1s.DBF_TABLENAME, t1s.DBF_RECORDSIZE),
                        (t1s.DBP_TABLENAME, t1s.DBP_SELECTIONCOLS),
                        (t1s.DBF_TABLENAME, t1s.DBF_CAT)],
         constraint_list=constraint_list)
     # create the percentiles table:
     caption = "Number of Percentiles passing the $%s+%sx$ requirement" % (
         str(self._config.a_req), str(self._config.b_req))
     percentiles_table = latex_classes.LatexTable(
         caption, "perc_main",
         ["DBNR", "DBRS", "Select", "Query Type", "Num Passing $\%$iles"])
     # compute number of percentiles met for every query category:
     for (dbnr, dbrs, selection_cols, query_cat) in categories:
         inp = t1ai.Input()
         inp[t1s.DBF_CAT] = query_cat
         inp[t1s.DBF_NUMRECORDS] = dbnr
         inp[t1s.DBF_RECORDSIZE] = dbrs
         inp[t1s.DBP_SELECTIONCOLS] = selection_cols
         performer_constraint_list = self._config.get_constraint_list(
             usebaseline=False) + inp.get_constraint_list()
         baseline_constraint_list = self._config.get_constraint_list(
             usebaseline=True) + inp.get_constraint_list()
         percentile_getter = percentiles.Ta1PercentileGetter(
             self._config.results_db, performer_constraint_list,
             baseline_constraint_list)
         if percentile_getter.has_values():
             all_met = percentile_getter.get_all_met(
                 self._config.a_req, self._config.b_req)
             percentiles_table.add_content([
                 inp.test_db.get_db_num_records_str(),
                 inp.test_db.get_db_record_size_str(), selection_cols,
                 query_cat,
                 len(all_met)
             ])
     self._outp["query_percentiles_table"] = percentiles_table.get_string()
Beispiel #9
0
    def get_tag(self, inp=None, aux=None):
        """Returns the tag for the LaTeX object.
        Attributes are listed in the tag in a canonical order.

        Args:
            inp: an Input object
            aux: any auxiliary string
        """
        if not inp: inp = t1ai.Input()
        tag = "_".join([
            str(arg).replace(" ", "") for arg in [
                type(self).__name__, self._config.performername,
                inp.get(t1s.DBF_NUMRECORDS),
                inp.get(t1s.DBF_RECORDSIZE),
                inp.get(t1s.DBF_CAT),
                inp.get(t1s.DBF_SUBCAT),
                inp.get(t1s.DBF_SUBSUBCAT),
                inp.get(t1s.DBA_FIELD),
                inp.get(t1s.DBP_SELECTIONCOLS), aux
            ] if arg != None
        ])
        tag.replace("*", "star")
        return tag
Beispiel #10
0
 def __init__(self, jinja_template, report_generator):
     """Initializes the section with a jinja template, a report generator,
     and a query category."""
     super(Ta1OverviewSection, self).__init__(
         jinja_template, report_generator)
     # create the input object for this section:
     self._inp = t1ai.Input()
     # find the present databases:
     present_databases = self._report_generator.get_present_cats(
         cat=False, subcat=False, subsubcat=False, dbnr=True, dbrs=True)
     for (numrecords, recordsize) in config.MAIN_DB_HEIRARCHY:
         if (numrecords,
             recordsize) in present_databases:
             self._inp[t1s.DBF_NUMRECORDS] = numrecords
             self._inp[t1s.DBF_RECORDSIZE] = recordsize
             break
     if not (self._inp.get(t1s.DBF_NUMRECORDS)
             and self._inp.get(t1s.DBF_RECORDSIZE)):
         self._inp[t1s.DBF_NUMRECORDS] = 0
         self._inp[t1s.DBF_RECORDSIZE] = 0
         for (numrecords,
              recordsize) in present_databases:
             if numrecords > self._inp[t1s.DBF_NUMRECORDS]:
                 self._inp[t1s.DBF_NUMRECORDS] = numrecords
                 self._inp[t1s.DBF_RECORDSIZE] = recordsize
             elif numrecords == self._inp[t1s.DBF_NUMRECORDS]:
                 if recordsize > self._inp[t1s.DBF_RECORDSIZE]:
                     self._inp[t1s.DBF_RECORDSIZE] = recordsize
         if (self._inp.get(t1s.DBF_NUMRECORDS)
             and self._inp.get(t1s.DBF_RECORDSIZE)):
             LOGGER.warning(
                 "No 'official' databases found! Using the one with "
                 "the largest number of records (%s records of size %s)." % (
                     str(self._inp[t1s.DBF_NUMRECORDS]),
                     str(self._inp[t1s.DBF_RECORDSIZE])))
         else:
             assert False, "No useable data in the results database."