# Copyright (c) 2011-present, Facebook, Inc. All rights reserved. # This source code is licensed under both the GPLv2 (found in the # COPYING file in the root directory) and Apache 2.0 License # (found in the LICENSE.Apache file in the root directory). from advisor.bench_runner import BenchmarkRunner from advisor.db_log_parser import DataSource, DatabaseLogs, NO_COL_FAMILY from advisor.db_stats_fetcher import ( LogStatsParser, OdsStatsFetcher, DatabasePerfContext ) import shutil import subprocess import time ''' NOTE: This is not thread-safe, because the output file is simply overwritten. ''' class DBBenchRunner(BenchmarkRunner): OUTPUT_FILE = "temp/dbbench_out.tmp" ERROR_FILE = "temp/dbbench_err.tmp" DB_PATH = "DB path" THROUGHPUT = "ops/sec" PERF_CON = " PERF_CONTEXT:" @staticmethod def is_metric_better(new_metric, old_metric): # for db_bench 'throughput' is the metric returned by run_experiment return new_metric >= old_metric @staticmethod def get_opt_args_str(misc_options_dict): # given a dictionary of options and their values, return a string # that can be appended as command-line arguments optional_args_str = "" for option_name, option_value in misc_options_dict.items(): if option_value: optional_args_str += ( " --" + option_name + "=" + str(option_value) ) return optional_args_str def __init__(self, positional_args, ods_args=None): # parse positional_args list appropriately self.db_bench_binary = positional_args[0] self.benchmark = positional_args[1] self.db_bench_args = None if len(positional_args) > 2: # options list with each option given as "