diff --git a/code/modules/unit_tests/unit_test.dm b/code/modules/unit_tests/unit_test.dm index 9a318938143..1fdafe33017 100644 --- a/code/modules/unit_tests/unit_test.dm +++ b/code/modules/unit_tests/unit_test.dm @@ -18,6 +18,8 @@ GLOBAL_LIST_EMPTY(unit_test_mapping_logs) /// Global assoc list of required mapping items, [item typepath] to [required item datum]. GLOBAL_LIST_EMPTY(required_map_items) +GLOBAL_LIST_EMPTY(test_run_times) + /// A list of every test that is currently focused. /// Use the PERFORM_ALL_TESTS macro instead. GLOBAL_VAR_INIT(focused_tests, focused_tests()) @@ -237,6 +239,8 @@ GLOBAL_VAR_INIT(focused_tests, focused_tests()) log_test(message) test_output_desc += " [duration / 10]s" + if(duration > 10) + GLOB.test_run_times[test_path] = duration if (test.succeeded) log_world("[TEST_OUTPUT_GREEN("PASS")] [test_output_desc]") @@ -394,6 +398,12 @@ GLOBAL_VAR_INIT(focused_tests, focused_tests()) RunUnitTest(unit_path, test_results) SSticker.delay_end = FALSE + log_world("::group::Expensive Unit Test Times") + sortTim(GLOB.test_run_times, cmp = GLOBAL_PROC_REF(cmp_numeric_dsc), associative = TRUE) + for(var/type, duration in GLOB.test_run_times) + log_world("[type] took [duration/10]s") + log_world("::endgroup::") + var/file_name = "data/unit_tests.json" fdel(file_name) file(file_name) << json_encode(test_results)