# Path: hardware/benchmark/utils.py
# def get_value(hw_lst, level1, level2, level3):
# def get_one_cpu_per_socket(hw_lst):


import re
import subprocess
import sys
from hardware.benchmark import utils

    sysbench_cmd.rstrip('&')
    sysbench_cmd += ')'

    global_perf = 0
    process = subprocess.Popen(
        sysbench_cmd, shell=True, stdout=subprocess.PIPE)
    for line in process.stdout:
        line = line.decode()
        if "transferred" in line:
            _, right = line.rstrip('\n').replace(' ', '').split('(')
            perf, _ = right.split('.')
            global_perf += int(perf)

    hw_lst.append(('cpu', 'logical', 'forked_bandwidth_%s' %
                   (block_size), str(global_perf)))


def mem_perf(hw_lst, max_time=5):
    """Report the memory performance."""
    all_cpu_testing_time = 5
    block_size_list = ['1K', '4K', '1M', '16M', '128M', '1G', '2G']
    logical = utils.get_value(hw_lst, 'cpu', 'logical', 'number')
    physical = utils.get_value(hw_lst, 'cpu', 'physical', 'number')
    if physical:
        eta = int(physical) * len(block_size_list) * max_time
        eta += 2 * (all_cpu_testing_time * len(block_size_list))
        sys.stderr.write('Memory Performance: %d logical CPU'
                         ' to test (ETA: %d seconds)\n'
                         % (int(physical), int(eta)))

# Path: hardware/benchmark/utils.py
# def get_value(hw_lst, level1, level2, level3):
# def get_one_cpu_per_socket(hw_lst):


# Path: hardware/benchmark/mem.py
import re
import subprocess
import sys
from hardware.benchmark import utils


    sysbench_cmd.rstrip('&')
    sysbench_cmd += ')'

    global_perf = 0
    process = subprocess.Popen(
        sysbench_cmd, shell=True, stdout=subprocess.PIPE)
    for line in process.stdout:
        line = line.decode()
        if "transferred" in line:
            _, right = line.rstrip('\n').replace(' ', '').split('(')
            perf, _ = right.split('.')
            global_perf += int(perf)

    hw_lst.append(('cpu', 'logical', 'forked_bandwidth_%s' %
                   (block_size), str(global_perf)))


def mem_perf(hw_lst, max_time=5):
    """Report the memory performance."""
    all_cpu_testing_time = 5
    block_size_list = ['1K', '4K', '1M', '16M', '128M', '1G', '2G']
    logical = utils.get_value(hw_lst, 'cpu', 'logical', 'number')
    physical = utils.get_value(hw_lst, 'cpu', 'physical', 'number')
    if physical:
        eta = int(physical) * len(block_size_list) * max_time
        eta += 2 * (all_cpu_testing_time * len(block_size_list))
        sys.stderr.write('Memory Performance: %d logical CPU'
                         ' to test (ETA: %d seconds)\n'
                         % (int(physical), int(eta)))

        for cpu_nb in utils.get_one_cpu_per_socket(hw_lst):