code: def test_time_measure():
      T = 1.2
      measurable = mock.Mock()
      reader = mock.Mock()
      reader.diagnostics.side_effect = {"some_diags": 1}
      wait_times = [0.0, T, T]
  
      def mock_next_item():
          a = 1
          for _ in six.moves.xrange(10000):
              a += 1
          sleep(wait_times.pop(0))
          return 0
  
      measurable.next_item.side_effect = mock_next_item
      result = _time_warmup_and_work(reader, 1, 2, measurable.next_item)
      assert result.time_mean >= T / 2.0
      assert result.samples_per_second < 1.0 / T
      assert result.memory_info
  
file_path: petastorm/petastorm/tests/test_benchmark.py
imports: from time import sleep
  import six
  from unittest import mock
  from petastorm.benchmark.throughput import reader_throughput, _time_warmup_and_work, WorkerPoolType, ReadMethod
label_desc: Use image node_id 7 for calling a global function with example usage: test_time_measure() and returns: int