示例#1
0
  def testStartStop(self):
    """Tests the Start and Stop functions."""
    profiling_configuration = configurations.ProfilingConfiguration()

    with shared_test_lib.TempDirectory() as temp_directory:
      profiling_configuration.directory = temp_directory

      test_profiler = profilers.SampleFileProfiler(
          'test', profiling_configuration)

      test_profiler._FILE_HEADER = 'test'

      test_profiler.Start()

      test_profiler.Stop()
示例#2
0
  def testSample(self):
    """Tests the Sample function."""
    profiling_configuration = configurations.ProfilingConfiguration()

    with shared_test_lib.TempDirectory() as temp_directory:
      profiling_configuration.directory = temp_directory

      test_profiler = profilers.TasksProfiler('test', profiling_configuration)

      test_profiler.Start()

      for _ in range(5):
        task = tasks.Task()
        test_profiler.Sample(task, 'queued')
        time.sleep(0.01)

      test_profiler.Stop()
示例#3
0
  def testSample(self):
    """Tests the Sample function."""
    profiling_configuration = configurations.ProfilingConfiguration()

    with shared_test_lib.TempDirectory() as temp_directory:
      profiling_configuration.directory = temp_directory

      test_profiler = profilers.StorageProfiler(
          'test', profiling_configuration)

      test_profiler.Start()

      for _ in range(5):
        test_profiler.Sample('read', 'test', 1024, 128)
        time.sleep(0.01)

      test_profiler.Stop()
示例#4
0
  def testStartStopTiming(self):
    """Tests the StartTiming and StopTiming functions."""
    profiling_configuration = configurations.ProfilingConfiguration()

    with shared_test_lib.TempDirectory() as temp_directory:
      profiling_configuration.directory = temp_directory

      test_profiler = profilers.CPUTimeProfiler(
          'test', profiling_configuration)

      test_profiler.Start()

      for _ in range(5):
        test_profiler.StartTiming('test_profile')
        time.sleep(0.01)
        test_profiler.StopTiming('test_profile')

      test_profiler.Stop()
示例#5
0
  def testSample(self):
    """Tests the Sample function."""
    task_status = processing_status.TasksStatus()

    profiling_configuration = configurations.ProfilingConfiguration()

    with shared_test_lib.TempDirectory() as temp_directory:
      profiling_configuration.directory = temp_directory

      test_profiler = profilers.TaskQueueProfiler(
          'test', profiling_configuration)

      test_profiler.Start()

      for _ in range(5):
        test_profiler.Sample(task_status)
        time.sleep(0.01)

      test_profiler.Stop()
示例#6
0
  def testStartSampleStop(self):
    """Tests the Start, Sample and Stop functions."""
    self.assertTrue(profilers.GuppyMemoryProfiler.IsSupported())

    profiling_configuration = configurations.ProfilingConfiguration()

    with shared_test_lib.TempDirectory() as temp_directory:
      profiling_configuration.directory = temp_directory
      profiling_configuration.sample_rate = 1000

      test_profiler = profilers.GuppyMemoryProfiler(
          'test', profiling_configuration)

      test_profiler.Start()

      for _ in range(5):
        test_profiler.Sample()
        time.sleep(0.01)

      test_profiler.Stop()
示例#7
0
 def testHaveProfileTasks(self):
     """Tests the HaveProfileTasks function."""
     configuration = configurations.ProfilingConfiguration()
     self.assertFalse(configuration.HaveProfileTasks())
示例#8
0
 def testInitialization(self):
     """Tests the __init__ function."""
     configuration = configurations.ProfilingConfiguration()
     self.assertIsNotNone(configuration)