Exemple #1
0
    def select_call_stack_by_sample_id(self, database, sample_id):
        """

        :param database:
        :param sample_id:
        :return:
        """
        table = StatementManager.performance_statistics_schema()
        engine, connection = self.spawn_connection(database)
        query = table.select().where(
            table.c.sample_id == str(sample_id)).order_by(
                table.c.cumulative_time.desc())

        results = []
        for row in self.execute_query(connection, query):
            results.append({
                "id":
                row.id,
                "test_id":
                row.test_id,
                "test_case_name":
                row.test_case_name,
                "sample_id":
                row.sample_id,
                "name_of_method_under_test":
                row.name_of_method_under_test,
                "epoch_timestamp":
                int(row.epoch_timestamp),
                "human_timestamp":
                row.human_timestamp,
                "child_path":
                row.child_path,
                "child_line_number":
                row.child_line_number,
                "child_function_name":
                row.child_function_name,
                "parent_path":
                row.parent_path,
                "parent_line_number":
                row.parent_line_number,
                "parent_function_name":
                row.parent_function_name,
                "number_of_calls":
                row.number_of_calls,
                "total_time":
                float(row.total_time),
                "cumulative_time":
                float(row.cumulative_time),
                "total_response_time":
                float(row.total_response_time)
            })
        self.close_connection(engine, connection)
        return results
Exemple #2
0
    def select_count_of_test_ids(self, database):
        """

        :param database:
        :return:
        """
        table = StatementManager.performance_statistics_schema()
        engine, connection = self.spawn_connection(database)
        query = select([func.count(table.c.test_id.distinct())])
        results = int(
            [row[0] for row in self.execute_query(connection, query)][0])
        self.close_connection(engine, connection)
        return results
Exemple #3
0
    def delete_performance_statistics_that_match_test_id(
            self, database, test_id):
        """

        :param database:
        :param test_id:
        :return:
        """
        table = StatementManager.performance_statistics_schema()
        query = table.delete().where(table.c.test_id == str(test_id))
        engine, connection = self.spawn_connection(database)
        results = self.execute_query(connection, query)
        self.close_connection(engine, connection)
        return results
Exemple #4
0
    def select_previous_test_id(self, database):
        """

        :param database:
        :return:
        """
        table = StatementManager.performance_statistics_schema()
        engine, connection = self.spawn_connection(database)
        query = select([table.c.test_id]).distinct()
        results = [
            str(row.test_id) for row in self.execute_query(connection, query)
        ]
        self.close_connection(engine, connection)
        return None if len(results) == 0 else results[-1]
Exemple #5
0
    def select_test_ids_with_performance_statistics(
            self, database, number=options.maximum_number_saved_test_results):
        """

        :param database:
        :param number:
        :return:
        """
        table = StatementManager.performance_statistics_schema()
        engine, connection = self.spawn_connection(database)
        query = select([table.c.test_id]).distinct().limit(number)
        results = [
            str(row.test_id) for row in self.execute_query(connection, query)
        ]
        self.close_connection(engine, connection)
        return results
Exemple #6
0
    def select_response_times(self, database, test_id):
        """

        :param database:
        :param test_id:
        :return:
        """
        table = StatementManager.performance_statistics_schema()
        engine, connection = self.spawn_connection(database)
        query = select(
            [table.c.sample_id.distinct(),
             table.c.total_response_time]).where(table.c.test_id == test_id)
        results = [
            float(row.total_response_time)
            for row in self.execute_query(connection, query)
        ]
        self.close_connection(engine, connection)
        return results
Exemple #7
0
    def select_test_id_description(self, database, test_id):
        """

        :param database:
        :param test_id:
        :return:
        """
        table = StatementManager.performance_statistics_schema()
        query = select([
            table.c.sample_id, table.c.name_of_method_under_test,
            table.c.human_timestamp, table.c.total_response_time
        ]).distinct().where(table.c.test_id == test_id)
        engine, connection = self.spawn_connection(database)

        results = []
        for row in self.execute_query(connection, query):
            results.append({
                "sample_id": row.sample_id,
                "name_of_method_under_test": row.name_of_method_under_test,
                "human_timestamp": row.human_timestamp,
                "total_response_time": row.total_response_time
            })
        self.close_connection(engine, connection)
        return results