docstr: A simple test runner for a perspective-python benchmark. See
  `scenarios/gil_test.py` for example usage.
docstr_tok: ["A","simple","test","runner","for","a","perspective-python","benchmark",".","See","`","scenarios\/gil_test.py","`","for","example","usage","."]
code: def __init__(self, task):
      """A simple test runner for a perspective-python benchmark. See
      `scenarios/gil_test.py` for example usage."""
      self.task = task
      self.parser = argparse.ArgumentParser(
          description="Runs a task against a remote `perspective-python` server using multiple websocket clients."
      )
  
      self.parser.add_argument(
          "-c",
          "--clients",
          type=int,
          default=10,
          dest="num_clients",
          help="The number of clients that will be run against the remote server, each on a separate thread.",
      )
      self.parser.add_argument(
          "-r",
          "--runs",
          type=int,
          default=1,
          dest="num_runs",
          help="The number of times to run `task` on each client.",
      )
      self.parser.add_argument(
          "-s",
          "--sleep",
          type=float,
          default=0,
          dest="sleep_time",
          help="The number of seconds to sleep between each run of `task` on each client.",
      )
      self.parser.add_argument(
          "-d",
          "--delay",
          type=float,
          default=0,
          dest="delay_time",
          help="The number of seconds to delay between initializing each client.",
      )
      self.parser.add_argument(
          "--interpolate",
          dest="interpolate",
          type=str,
          choices=["clients", "runs", "sleep", "delay"],
          default=None,
          help="A single axis to interpolate - choose between `clients`, \
                    `runs`, `sleep`, or `delay`. \n Uses the values of \
                    `--range` and `--step` to interpolate, or defaults to 3 \
                     increments with steps of 5, i.e. interpolating 10 clients \
                     by --range=3 and --step=2 will run the suite 4 times, \
                     for [10, 12, 14, 16] clients respectively.",
      )
      self.parser.add_argument(
          "--range",
          dest="interpolate_range",
          type=int,
          default=3,
          help="How many times to interpolate the axis.",
      )
      self.parser.add_argument(
          "--step",
          dest="interpolate_step",
          type=int,
          default=3,
          help="A value to increment/decrement the axis by on every interpolation.",
      )
  
      self.parser.add_argument("url", type=str)
      self.parser.parse_args(namespace=self)
  
      logging.critical(
          "Running task %d times over %d clients against %s",
          self.num_runs,
          self.num_clients,
          self.url,
      )
  
      self.interpolate_options = {
          "clients": "num_clients",
          "runs": "num_runs",
          "sleep": "sleep_time",
          "delay": "delay_time",
      }
  
      # Only interpolate one axis at a time
      self.interpolate_attr = self.interpolate_options.get(
          self.interpolate
      )
  
      # num of interpolated runs + 1 un-interpolated run
      self.interpolate_range += 1
  
      # Deref parser as it cannot be pickled for multiprocessing, and we
      # don't need it once we have the args parsed.
      self.parser = None
  
file_path: perspective/python/perspective/bench/tornado/bench.py
imports: import logging
  import argparse
  import numpy
  import multiprocessing
  import asyncio
  import perspective
  from functools import partial
label_desc: Use image node_id 1 to create a new PerspectiveTornadoBenchmark object from inherited base classes: object with example: obj = PerspectiveTornadoBenchmark(task)