def Run(benchmark_spec):
  """Run memtier_benchmark against Redis.

  Args:
    benchmark_spec: The benchmark specification. Contains all data that is
        required to run the benchmark.

  Returns:
    A list of sample.Sample objects.
  """
  vms = benchmark_spec.vms
  redis_vm = vms[0]
  load_vms = vms[1:]
  latency = 0.0
  latency_threshold = 1000000.0
  threads = 0
  results = []
  num_servers = redis_vm.num_cpus * FLAGS.redis_numprocesses
  max_throughput_for_completion_latency_under_1ms = 0.0

  while latency < latency_threshold:
    threads += max(1, int(threads * .15))
    num_loaders = len(load_vms) * num_servers
    args = [((redis_vm, load_vms[i % len(load_vms)], threads / num_loaders +
              (0 if (i + 1) > num_loaders % threads else 1),
              FIRST_PORT + i % num_servers, i),
             {}) for i in range(num_loaders)]
    client_results = [i for i in vm_util.RunThreaded(RunLoad, args)
                      if i is not None]
    logging.info('Redis results by client: %s', client_results)
    throughput = sum(r.throughput for r in client_results)

    if not throughput:
      raise errors.Benchmarks.RunError(
          'Zero throughput for {} threads: {}'.format(threads, client_results))

    # Average latency across clients
    latency = (sum(client_latency * client_throughput
                   for client_latency, client_throughput in client_results) /
               throughput)

    if latency < 1.0:
        max_throughput_for_completion_latency_under_1ms = max(
            max_throughput_for_completion_latency_under_1ms,
            throughput)
    results.append(sample.Sample('throughput', throughput, 'req/s',
                                 {'latency': latency, 'threads': threads}))
    logging.info('Threads : %d  (%f, %f) < %f', threads, throughput, latency,
                 latency_threshold)
    if threads == 1:
      latency_threshold = latency * 20

  results.append(sample.Sample(
                 'max_throughput_for_completion_latency_under_1ms',
                 max_throughput_for_completion_latency_under_1ms,
                 'req/s'))

  return results
dataset/ETHPy150Open GoogleCloudPlatform/PerfKitBenchmarker/perfkitbenchmarker/linux_benchmarks/redis_benchmark.py/Run/swapped operands of `%`