def RunLoad(redis_vm, load_vm, threads, port, test_id):
  """Spawn a memteir_benchmark on the load_vm against the redis_vm:port.

  Args:
    redis_vm: The target of the memtier_benchmark
    load_vm: The vm that will run the memtier_benchmark.
    threads: The number of threads to run in this memtier_benchmark process.
    port: the port to target on the redis_vm.
  Returns:
    A throughput, latency tuple, or None if threads was 0.
  """
  if threads == 0:
    return None
  base_cmd = ('memtier_benchmark -s %s  -p %d  -d 128 '
              '--ratio %s --key-pattern S:S -x 1 -c 1 -t %d '
              '--test-time=%d --random-data > %s ;')
  final_cmd = (base_cmd % (redis_vm.internal_ip, port,
                           FLAGS.redis_setgetratio, threads, 10,
                           '/dev/null') +
               base_cmd % (redis_vm.internal_ip, port,
                           FLAGS.redis_setgetratio, threads, 20,
                           'outfile-%d' % test_id) +
               base_cmd % (redis_vm.internal_ip, port,
                           FLAGS.redis_setgetratio, threads, 10,
                           '/dev/null'))

  load_vm.RemoteCommand(final_cmd)
  output, _ = load_vm.RemoteCommand('cat outfile-%d | grep Totals | '
                                    'tr -s \' \' | cut -d \' \' -f 2' % test_id)
  throughput = float(output)
  output, _ = load_vm.RemoteCommand('cat outfile-%d | grep Totals | '
                                    'tr -s \' \' | cut -d \' \' -f 5' % test_id)
  latency = float(output)

  output, _ = load_vm.RemoteCommand('cat outfile-%d' % test_id)
  logging.info(output)

  return RedisResult(throughput, latency)
dataset/ETHPy150Open GoogleCloudPlatform/PerfKitBenchmarker/perfkitbenchmarker/linux_benchmarks/redis_benchmark.py/RunLoad/original