]> git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/tools/advisor/advisor/bench_runner.py
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / rocksdb / tools / advisor / advisor / bench_runner.py
1 # Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
2 # This source code is licensed under both the GPLv2 (found in the
3 # COPYING file in the root directory) and Apache 2.0 License
4 # (found in the LICENSE.Apache file in the root directory).
5
6 from abc import ABC, abstractmethod
7 import re
8
9
10 class BenchmarkRunner(ABC):
11 @staticmethod
12 @abstractmethod
13 def is_metric_better(new_metric, old_metric):
14 pass
15
16 @abstractmethod
17 def run_experiment(self):
18 # should return a list of DataSource objects
19 pass
20
21 @staticmethod
22 def get_info_log_file_name(log_dir, db_path):
23 # Example: DB Path = /dev/shm and OPTIONS file has option
24 # db_log_dir=/tmp/rocks/, then the name of the log file will be
25 # 'dev_shm_LOG' and its location will be /tmp/rocks. If db_log_dir is
26 # not specified in the OPTIONS file, then the location of the log file
27 # will be /dev/shm and the name of the file will be 'LOG'
28 file_name = ''
29 if log_dir:
30 # refer GetInfoLogPrefix() in rocksdb/util/filename.cc
31 # example db_path: /dev/shm/dbbench
32 file_name = db_path[1:] # to ignore the leading '/' character
33 to_be_replaced = re.compile('[^0-9a-zA-Z\-_\.]')
34 for character in to_be_replaced.findall(db_path):
35 file_name = file_name.replace(character, '_')
36 if not file_name.endswith('_'):
37 file_name += '_'
38 file_name += 'LOG'
39 return file_name