def obtain_results(self, writer_thread_class): time_when_debugged = self._get_time_from_result( self.check_case(writer_thread_class)) args = self.get_command_line() args.append(writer_thread_class.TEST_FILE) regular_time = self._get_time_from_result( self.run_process(args, writer_thread=None)) simple_trace_time = self._get_time_from_result( self.run_process(args + ['--regular-trace'], writer_thread=None)) print(writer_thread_class.BENCHMARK_NAME, time_when_debugged, regular_time, simple_trace_time) if 'SPEEDTIN_AUTHORIZATION_KEY' in os.environ: SPEEDTIN_AUTHORIZATION_KEY = os.environ[ 'SPEEDTIN_AUTHORIZATION_KEY'] # sys.path.append(r'X:\speedtin\pyspeedtin') import pyspeedtin # If the authorization key is there, pyspeedtin must be available import pydevd pydevd_cython_project_id, pydevd_pure_python_project_id = 6, 7 if writer_thread_class.CHECK == CHECK_BASELINE: project_ids = (pydevd_cython_project_id, pydevd_pure_python_project_id) elif writer_thread_class.CHECK == CHECK_REGULAR: project_ids = (pydevd_pure_python_project_id, ) elif writer_thread_class.CHECK == CHECK_CYTHON: project_ids = (pydevd_cython_project_id, ) else: raise AssertionError('Wrong check: %s' % (writer_thread_class.CHECK)) for project_id in project_ids: api = pyspeedtin.PySpeedTinApi( authorization_key=SPEEDTIN_AUTHORIZATION_KEY, project_id=project_id) benchmark_name = writer_thread_class.BENCHMARK_NAME if writer_thread_class.CHECK == CHECK_BASELINE: version = '0.0.1_baseline' return # No longer commit the baseline (it's immutable right now). else: version = pydevd.__version__, commit_id, branch, commit_date = api.git_commit_id_branch_and_date_from_path( pydevd.__file__) api.add_benchmark(benchmark_name) api.add_measurement( benchmark_name, value=time_when_debugged, version=version, released=False, branch=branch, commit_id=commit_id, commit_date=commit_date, ) api.commit()
def obtain_results(self, benchmark_name, filename): class PerformanceCheck(PerformanceWriterThread): TEST_FILE = debugger_unittest._get_debugger_test_file(filename) BENCHMARK_NAME = benchmark_name writer_thread_class = PerformanceCheck runs = RUNS all_times = [] for _ in range(runs): stdout_ref = [] def store_stdout(stdout, stderr): stdout_ref.append(stdout) with self.check_case(writer_thread_class) as writer: writer.additional_output_checks = store_stdout yield writer assert len(stdout_ref) == 1 all_times.append(self._get_time_from_result(stdout_ref[0])) print('partial for: %s: %.3fs' % (writer_thread_class.BENCHMARK_NAME, all_times[-1])) if len(all_times) > 3: all_times.remove(min(all_times)) all_times.remove(max(all_times)) time_when_debugged = sum(all_times) / float(len(all_times)) args = self.get_command_line() args.append(writer_thread_class.TEST_FILE) # regular_time = self._get_time_from_result(self.run_process(args, writer_thread=None)) # simple_trace_time = self._get_time_from_result(self.run_process(args+['--regular-trace'], writer_thread=None)) if 'SPEEDTIN_AUTHORIZATION_KEY' in os.environ: SPEEDTIN_AUTHORIZATION_KEY = os.environ['SPEEDTIN_AUTHORIZATION_KEY'] # sys.path.append(r'X:\speedtin\pyspeedtin') import pyspeedtin # If the authorization key is there, pyspeedtin must be available import pydevd pydevd_cython_project_id, pydevd_pure_python_project_id = 6, 7 if writer_thread_class.CHECK == CHECK_BASELINE: project_ids = (pydevd_cython_project_id, pydevd_pure_python_project_id) elif writer_thread_class.CHECK == CHECK_REGULAR: project_ids = (pydevd_pure_python_project_id,) elif writer_thread_class.CHECK == CHECK_CYTHON: project_ids = (pydevd_cython_project_id,) else: raise AssertionError('Wrong check: %s' % (writer_thread_class.CHECK)) for project_id in project_ids: api = pyspeedtin.PySpeedTinApi(authorization_key=SPEEDTIN_AUTHORIZATION_KEY, project_id=project_id) benchmark_name = writer_thread_class.BENCHMARK_NAME if writer_thread_class.CHECK == CHECK_BASELINE: version = '0.0.1_baseline' return # No longer commit the baseline (it's immutable right now). else: version = pydevd.__version__, commit_id, branch, commit_date = api.git_commit_id_branch_and_date_from_path(pydevd.__file__) api.add_benchmark(benchmark_name) api.add_measurement( benchmark_name, value=time_when_debugged, version=version, released=False, branch=branch, commit_id=commit_id, commit_date=commit_date, ) api.commit() self.performance_msg = '%s: %.3fs ' % (writer_thread_class.BENCHMARK_NAME, time_when_debugged)