예제 #1
0
파일: profilers.py 프로젝트: tincho9/plaso
  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()
예제 #2
0
    def StartProfiling(self, configuration, identifier, process_information):
        """Starts profiling.

    Args:
      configuration (ProfilingConfiguration): profiling configuration.
      identifier (str): identifier of the profiling session used to create
          the sample filename.
      process_information (ProcessInfo): process information.
    """
        if not configuration:
            return

        if configuration.HaveProfileParsers():
            identifier = '{0:s}-parsers'.format(identifier)

            self._cpu_time_profiler = profilers.CPUTimeProfiler(
                identifier, configuration)
            self._cpu_time_profiler.Start()

            self._memory_profiler = profilers.MemoryProfiler(
                identifier, configuration)
            self._memory_profiler.Start()

        self._process_information = process_information