code: def benchmark(optimizer, problem, runs=20, **kwargs):
      
      stats = {'runs': []}
  
      # Disable logging, to avoid spamming the user
      # TODO: Maybe we shouldn't disable by default?
      kwargs = copy.copy(kwargs)
      kwargs['logging_func'] = None
  
      # Determine effectiveness of metaheuristic over many runs
      # The stochastic nature of metaheuristics make this necessary
      # for an accurate evaluation
      for _ in range(runs):
          optimizer.optimize(problem, **kwargs)
  
          # Convert bool to number for mean and standard deviation calculations
          if optimizer.solution_found:
              finished_num = 1.0
          else:
              finished_num = 0.0
  
          stats_ = {
              'fitness': optimizer.best_fitness,
              'fitness_runs': optimizer.fitness_runs,
              'solution_found': finished_num
          }
          stats['runs'].append(stats_)
  
          # Little progress 'bar'
          print '.',
  
      # Mean gives a good overall idea of the metaheuristics effectiveness
      # Standard deviation (SD) shows consistency of performance
      _add_mean_sd_to_stats(stats)
  
      return stats
docs: Run an optimizer through a problem multiple times.
  
      Args:
          optimizer: Optimizer; The optimizer to benchmark.
          problem: Problem; The problem to benchmark on.
          runs: int > 0; Number of times that optimize is called on problem.
  
      Returns:
          dict; A dictionary of various statistics.