def METHOD_NAME(vm,
        target,
        rate,
        connections=1,
        duration=60,
        script_path=None,
        threads=None):
  """Runs wrk against a given target.
  Args:
    vm: Virtual machine.
    target: URL to fetch.
    rate: int. Target request rate, in QPS.
    connections: Number of concurrent connections.
    duration: Duration of the test, in seconds.
    script_path: If specified, a lua script to execute.
    threads: Number of threads. Defaults to min(connections, num_cores).
  Yields:
    sample.Sample objects with results.
  """
  if threads is None:
    threads = min(connections, vm.NumCpusForBenchmark())
  cmd = ('{wrk} '
         '--rate={rate} '
         '--connections={connections} '
         '--threads={threads} '
         '--duration={duration} '
         '--{corrected}').format(
             wrk=WRK2_PATH,
             connections=connections,
             threads=threads,
             rate=rate,
             duration=duration,
             corrected=('latency' if _CORRECTED.value else 'u_latency'))
  if script_path:
    cmd += ' --script ' + script_path
  cmd += ' ' + target
  stdout, _ = vm.RemoteCommand(cmd)
  for variable, value, unit in _ParseOutput(stdout):
    yield sample.Sample(
        variable,
        value,
        unit,
        metadata={
            'connections': connections,
            'threads': threads,
            'duration': duration,
            'target_rate': rate,
            'corrected': _CORRECTED.value
        })