class_docstr: Benchmark that compares various ways of running tf.data benchmarks.
class_docstr_tok: ["Benchmark","that","compares","various","ways","of","running","tf.data","benchmarks","."]
code: def run_benchmark_with_session_run(
      self, dataset, make_callable=False
  ):
      iterator = dataset_ops.make_initializable_iterator(dataset)
      next_element = iterator.get_next()
  
      with session.Session() as sess:
          deltas = []
          for _ in range(self.num_reps):
              if make_callable:
                  get_next_element = sess.make_callable(next_element)
              else:
                  # Note: session.run(next_element.op) is more performant than
                  # session.run(next_element) because we avoid the cost of copying the
                  # tensor from C++ to python.
                  get_next_element = lambda: sess.run(next_element.op)
  
              sess.run(iterator.initializer)
              deltas.append(
                  timeit.timeit(get_next_element, number=self.iters)
              )
      self.report(deltas)
  
imports: import timeit
  import numpy
  from tensorflow.python.client import session
  from tensorflow.python.data.experimental.ops import testing
  from tensorflow.python.data.ops import dataset_ops
  from tensorflow.python.data.ops import options
  from tensorflow.python.eager import context
  from tensorflow.python.platform import test
label_desc: Use image node_id 13 for calling the MetaBenchmark obj's underlying member method code with example usage: obj.run_benchmark_with_session_run(dataset, make_callable) without return types