|
| 1 | +import csv |
| 2 | +import re |
| 3 | + |
| 4 | +from redisbench_admin.utils.local import check_if_needs_remote_fetch |
| 5 | + |
| 6 | + |
| 7 | +def prepare_tsbs_run_queries_redistimeseries_benchmark_command( |
| 8 | + executable_path: str, |
| 9 | + server_private_ip: object, |
| 10 | + server_plaintext_port: object, |
| 11 | + benchmark_config: object, |
| 12 | + current_workdir, |
| 13 | + result_file: str, |
| 14 | + remote_queries_file, |
| 15 | +): |
| 16 | + """ |
| 17 | + Prepares tsbs_run_queries_redistimeseries command parameters |
| 18 | + :param executable_path: |
| 19 | + :param server_private_ip: |
| 20 | + :param server_plaintext_port: |
| 21 | + :param benchmark_config: |
| 22 | + :param current_workdir: |
| 23 | + :return: [string] containing the required command to run the benchmark given the configurations |
| 24 | + """ |
| 25 | + command_arr = [executable_path] |
| 26 | + |
| 27 | + command_arr.extend( |
| 28 | + ["--host", "{}:{}".format(server_private_ip, server_plaintext_port)] |
| 29 | + ) |
| 30 | + |
| 31 | + for k in benchmark_config["parameters"]: |
| 32 | + if "workers" in k: |
| 33 | + command_arr.extend(["--workers", str(k["workers"])]) |
| 34 | + if "file" in k: |
| 35 | + input_file = k["file"] |
| 36 | + input_file = check_if_needs_remote_fetch( |
| 37 | + input_file, "/tmp", None, remote_queries_file |
| 38 | + ) |
| 39 | + command_arr.extend(["--file", input_file]) |
| 40 | + |
| 41 | + command_arr.extend(["--results-file", result_file]) |
| 42 | + command_arr.extend(["--print-interval", "1000"]) |
| 43 | + |
| 44 | + command_str = " ".join(command_arr) |
| 45 | + return command_arr, command_str |
| 46 | + |
| 47 | + |
| 48 | +def post_process_ycsb_results(stdout, start_time_ms, start_time_str): |
| 49 | + results_dict = { |
| 50 | + "Tests": {}, |
| 51 | + "StartTime": start_time_ms, |
| 52 | + "StartTimeHuman": start_time_str, |
| 53 | + } |
| 54 | + if type(stdout) == bytes: |
| 55 | + stdout = stdout.decode("ascii") |
| 56 | + csv_data = list(csv.reader(stdout.splitlines(), delimiter=",")) |
| 57 | + start_row = 0 |
| 58 | + for row in csv_data: |
| 59 | + if len(row) >= 1: |
| 60 | + if "[OVERALL]" in row[0]: |
| 61 | + break |
| 62 | + start_row = start_row + 1 |
| 63 | + for row in csv_data[start_row:]: |
| 64 | + if len(row) >= 3: |
| 65 | + op_group = row[0].strip()[1:-1] |
| 66 | + metric_name = row[1].strip() |
| 67 | + metric_name = re.sub("[^0-9a-zA-Z]+", "_", metric_name) |
| 68 | + value = row[2].strip() |
| 69 | + if op_group not in results_dict["Tests"]: |
| 70 | + results_dict["Tests"][op_group] = {} |
| 71 | + results_dict["Tests"][op_group][metric_name] = value |
| 72 | + return results_dict |
0 commit comments