docstr: Run self.func() n times and compute the average of all runs for all
  metrics after discarding the min and max values for each.
docstr_tok: ["Run","self.func","(",")","n","times","and","compute","the","average","of","all","runs","for","all","metrics","after","discarding","the","min","and","max","values","for","each","."]
code: def run(self, n=1):
      """
      Run self.func() n times and compute the average of all runs for all
      metrics after discarding the min and max values for each.
      """
      retVal = None
      # Return or create the results dict unique to the function name
      funcResultsDict = self.resultsDict.setdefault(self.name, {})
  
      # FIXME: use a proper logger
      print("Running %s" % self.name, end="", flush=True)
  
      try:
          exeTimes = []
          gpuMems = []
          gpuUtils = []
  
          if n > 1:
              print("  - iteration ", end="", flush=True)
  
          for i in range(n):
              if n > 1:
                  print(i + 1, end="...", flush=True)
              gpuPollObj = startGpuMetricPolling()
              # st = process_time_ns()
              st = clock_gettime(CLOCK_MONOTONIC_RAW)
              retVal = self.func(*self.args)
              stopGpuMetricPolling(gpuPollObj)
  
              # exeTime = (process_time_ns() - st) / 1e9
              exeTime = clock_gettime(CLOCK_MONOTONIC_RAW) - st
              exeTimes.append(exeTime)
              gpuMems.append(gpuPollObj.maxGpuUtil)
              gpuUtils.append(gpuPollObj.maxGpuMemUsed)
  
          print("  - done running %s." % self.name, flush=True)
  
      except Exception as e:
          funcResultsDict["ERROR"] = str(e)
          print(
              "   %s | %s"
              % (
                  "ERROR".ljust(self.metricNameCellWidth),
                  str(e).ljust(self.valueCellWidth),
              )
          )
          stopGpuMetricPolling(gpuPollObj)
          return
  
      funcResultsDict["exeTime"] = self.__computeValue(exeTimes)
      funcResultsDict["maxGpuUtil"] = self.__computeValue(gpuMems)
      funcResultsDict["maxGpuMemUsed"] = self.__computeValue(gpuUtils)
  
      for metricName in ["exeTime", "maxGpuUtil", "maxGpuMemUsed"]:
          val = funcResultsDict[metricName]
          print(
              "   %s | %s"
              % (
                  metricName.ljust(self.metricNameCellWidth),
                  str(val).ljust(self.valueCellWidth),
              ),
              flush=True,
          )
  
      return retVal
  
imports: from time import clock_gettime, CLOCK_MONOTONIC_RAW
  import numpy
  from gpu_metric_poller import startGpuMetricPolling, stopGpuMetricPolling
label_desc: Use image node_id 2 for calling the Benchmark obj's underlying member method code with example usage: obj.run(n) and returns: retVal