2
0
Эх сурвалжийг харах

Merge pull request #59153 from Calinou/debug-stringnames-improve

Improve `--debug-stringnames` to be more useful
Rémi Verschelde 3 жил өмнө
parent
commit
fb28025785

+ 14 - 2
core/string/string_name.cpp

@@ -73,11 +73,23 @@ void StringName::cleanup() {
 				d = d->next;
 				d = d->next;
 			}
 			}
 		}
 		}
-		print_line("\nStringName Reference Ranking:\n");
+
+		print_line("\nStringName reference ranking (from most to least referenced):\n");
+
 		data.sort_custom<DebugSortReferences>();
 		data.sort_custom<DebugSortReferences>();
-		for (int i = 0; i < MIN(100, data.size()); i++) {
+		int unreferenced_stringnames = 0;
+		int rarely_referenced_stringnames = 0;
+		for (int i = 0; i < data.size(); i++) {
 			print_line(itos(i + 1) + ": " + data[i]->get_name() + " - " + itos(data[i]->debug_references));
 			print_line(itos(i + 1) + ": " + data[i]->get_name() + " - " + itos(data[i]->debug_references));
+			if (data[i]->debug_references == 0) {
+				unreferenced_stringnames += 1;
+			} else if (data[i]->debug_references < 5) {
+				rarely_referenced_stringnames += 1;
+			}
 		}
 		}
+
+		print_line(vformat("\nOut of %d StringNames, %d StringNames were never referenced during this run (0 times) (%.2f%%).", data.size(), unreferenced_stringnames, unreferenced_stringnames / float(data.size()) * 100));
+		print_line(vformat("Out of %d StringNames, %d StringNames were rarely referenced during this run (1-4 times) (%.2f%%).", data.size(), rarely_referenced_stringnames, rarely_referenced_stringnames / float(data.size()) * 100));
 	}
 	}
 #endif
 #endif
 	int lost_strings = 0;
 	int lost_strings = 0;

+ 1 - 0
main/main.cpp

@@ -348,6 +348,7 @@ void Main::print_help(const char *p_binary) {
 #if defined(DEBUG_ENABLED)
 #if defined(DEBUG_ENABLED)
 	OS::get_singleton()->print("  --debug-collisions                           Show collision shapes when running the scene.\n");
 	OS::get_singleton()->print("  --debug-collisions                           Show collision shapes when running the scene.\n");
 	OS::get_singleton()->print("  --debug-navigation                           Show navigation polygons when running the scene.\n");
 	OS::get_singleton()->print("  --debug-navigation                           Show navigation polygons when running the scene.\n");
+	OS::get_singleton()->print("  --debug-stringnames                          Print all StringName allocations to stdout when the engine quits.\n");
 #endif
 #endif
 	OS::get_singleton()->print("  --frame-delay <ms>                           Simulate high CPU load (delay each frame by <ms> milliseconds).\n");
 	OS::get_singleton()->print("  --frame-delay <ms>                           Simulate high CPU load (delay each frame by <ms> milliseconds).\n");
 	OS::get_singleton()->print("  --time-scale <scale>                         Force time scale (higher values are faster, 1.0 is normal speed).\n");
 	OS::get_singleton()->print("  --time-scale <scale>                         Force time scale (higher values are faster, 1.0 is normal speed).\n");

+ 1 - 0
misc/dist/shell/_godot.zsh-completion

@@ -66,6 +66,7 @@ _arguments \
   '--remote-debug[enable remote debugging]:remote debugger address' \
   '--remote-debug[enable remote debugging]:remote debugger address' \
   '--debug-collisions[show collision shapes when running the scene]' \
   '--debug-collisions[show collision shapes when running the scene]' \
   '--debug-navigation[show navigation polygons when running the scene]' \
   '--debug-navigation[show navigation polygons when running the scene]' \
+  '--debug-stringnames[print all StringName allocations to stdout when the engine quits]' \
   '--frame-delay[simulate high CPU load (delay each frame by the given number of milliseconds)]:number of milliseconds' \
   '--frame-delay[simulate high CPU load (delay each frame by the given number of milliseconds)]:number of milliseconds' \
   '--time-scale[force time scale (higher values are faster, 1.0 is normal speed)]:time scale' \
   '--time-scale[force time scale (higher values are faster, 1.0 is normal speed)]:time scale' \
   '--disable-render-loop[disable render loop so rendering only occurs when called explicitly from script]' \
   '--disable-render-loop[disable render loop so rendering only occurs when called explicitly from script]' \

+ 1 - 0
misc/dist/shell/godot.bash-completion

@@ -69,6 +69,7 @@ _complete_godot_options() {
 --remote-debug
 --remote-debug
 --debug-collisions
 --debug-collisions
 --debug-navigation
 --debug-navigation
+--debug-stringnames
 --frame-delay
 --frame-delay
 --time-scale
 --time-scale
 --disable-render-loop
 --disable-render-loop

+ 1 - 0
misc/dist/shell/godot.fish

@@ -79,6 +79,7 @@ complete -c godot -l gpu-abort -d "Abort on GPU errors (usually validation layer
 complete -c godot -l remote-debug -d "Enable remote debugging"
 complete -c godot -l remote-debug -d "Enable remote debugging"
 complete -c godot -l debug-collisions -d "Show collision shapes when running the scene"
 complete -c godot -l debug-collisions -d "Show collision shapes when running the scene"
 complete -c godot -l debug-navigation -d "Show navigation polygons when running the scene"
 complete -c godot -l debug-navigation -d "Show navigation polygons when running the scene"
+complete -c godot -l debug-stringnames -d "Print all StringName allocations to stdout when the engine quits"
 complete -c godot -l frame-delay -d "Simulate high CPU load (delay each frame by the given number of milliseconds)" -x
 complete -c godot -l frame-delay -d "Simulate high CPU load (delay each frame by the given number of milliseconds)" -x
 complete -c godot -l time-scale -d "Force time scale (higher values are faster, 1.0 is normal speed)" -x
 complete -c godot -l time-scale -d "Force time scale (higher values are faster, 1.0 is normal speed)" -x
 complete -c godot -l disable-render-loop -d "Disable render loop so rendering only occurs when called explicitly from script"
 complete -c godot -l disable-render-loop -d "Disable render loop so rendering only occurs when called explicitly from script"