def Run(benchmark_spec):
  tomcat_vm = benchmark_spec.vm_groups['server'][0]
  wrk_vm = benchmark_spec.vm_groups['client'][0]

  samples = []
  errors = 0
  connections = 1
  duration = FLAGS.tomcat_wrk_test_length
  max_connections = FLAGS.tomcat_wrk_max_connections

  target = urlparse.urljoin('http://{0}:{1}'.format(tomcat_vm.ip_address,
                                                    tomcat.TOMCAT_HTTP_PORT),
                            SAMPLE_PAGE_PATH)

  logging.info('Warming up for %ds', WARM_UP_DURATION)
  list(wrk.Run(wrk_vm, connections=1, target=target, duration=WARM_UP_DURATION))

  all_by_metric = []

  while connections <= max_connections:
    run_samples = list(wrk.Run(wrk_vm, connections=connections, target=target,
                               duration=duration))

    by_metric = {i.metric: i for i in run_samples}
    errors = by_metric['errors'].value
    requests = by_metric['requests'].value
    throughput = by_metric['throughput'].value
    if requests < 1:
      logging.warn('No requests issued for %d connections.',
                   connections)
      error_rate = 1.0
    else:
      error_rate = float(errors) / requests

    if error_rate <= MAX_ERROR_RATE:
      all_by_metric.append(by_metric)
    else:
      logging.warn('Error rate exceeded maximum (%g > %g)', error_rate,
                   MAX_ERROR_RATE)

    logging.info('Ran with %d connections; %.2f%% errors, %.2f req/s',
                 connections, error_rate, throughput)

    # Retry with double the connections
    connections *= 2

  if not all_by_metric:
    raise ValueError('No requests succeeded.')

  # Annotate the sample with the best throughput
  max_throughput = max(all_by_metric, key=lambda x: x['throughput'].value)
  for sample in max_throughput.itervalues():
    sample.metadata.update(best_throughput=True)

  # ...and best 50th percentile latency
  min_p50 = min(all_by_metric, key=lambda x: x['p50 latency'].value)
  for sample in min_p50.itervalues():
    sample.metadata.update(best_p50=True)

  sort_key = operator.attrgetter('metric')
  if FLAGS.tomcat_wrk_report_all_samples:
    samples = [sample for d in all_by_metric
               for sample in sorted(d.itervalues(), key=sort_key)]
  else:
    samples = (sorted(min_p50.itervalues(), key=sort_key) +
               sorted(max_throughput.itervalues(), key=sort_key))

  for sample in samples:
    sample.metadata.update(ip_type='external', runtime_in_seconds=duration)

  return samples
Get the overall weight of topics across an entire corpus. Note: Values depend
dataset/ETHPy150Open GoogleCloudPlatform/PerfKitBenchmarker/perfkitbenchmarker/linux_benchmarks/tomcat_wrk_benchmark.py/Run--crossover with--dataset/ETHPy150Open chartbeat-labs/textacy/textacy/tm/topic_model.py/TopicModel.topic_weights