You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-07 12:30:27 +00:00
Add Startup benchmarking support
This adds support for benchmarking engine startup (and editor startup if used). The goal is to use this in the benchmarking server to track improvements and changes to engine, editor, importer and scene loading startup times.
This commit is contained in:
@@ -33,7 +33,9 @@
|
||||
#include "core/authors.gen.h"
|
||||
#include "core/config/project_settings.h"
|
||||
#include "core/donors.gen.h"
|
||||
#include "core/io/json.h"
|
||||
#include "core/license.gen.h"
|
||||
#include "core/os/os.h"
|
||||
#include "core/version.h"
|
||||
|
||||
void Engine::set_physics_ticks_per_second(int p_ips) {
|
||||
@@ -307,6 +309,43 @@ Engine::Engine() {
|
||||
singleton = this;
|
||||
}
|
||||
|
||||
void Engine::startup_begin() {
|
||||
startup_benchmark_total_from = OS::get_singleton()->get_ticks_usec();
|
||||
}
|
||||
|
||||
void Engine::startup_benchmark_begin_measure(const String &p_what) {
|
||||
startup_benchmark_section = p_what;
|
||||
startup_benchmark_from = OS::get_singleton()->get_ticks_usec();
|
||||
}
|
||||
void Engine::startup_benchmark_end_measure() {
|
||||
uint64_t total = OS::get_singleton()->get_ticks_usec() - startup_benchmark_from;
|
||||
double total_f = double(total) / double(1000000);
|
||||
|
||||
startup_benchmark_json[startup_benchmark_section] = total_f;
|
||||
}
|
||||
|
||||
void Engine::startup_dump(const String &p_to_file) {
|
||||
uint64_t total = OS::get_singleton()->get_ticks_usec() - startup_benchmark_total_from;
|
||||
double total_f = double(total) / double(1000000);
|
||||
startup_benchmark_json["total_time"] = total_f;
|
||||
|
||||
if (!p_to_file.is_empty()) {
|
||||
Ref<FileAccess> f = FileAccess::open(p_to_file, FileAccess::WRITE);
|
||||
if (f.is_valid()) {
|
||||
Ref<JSON> json;
|
||||
json.instantiate();
|
||||
f->store_string(json->stringify(startup_benchmark_json, "\t", false, true));
|
||||
}
|
||||
} else {
|
||||
List<Variant> keys;
|
||||
startup_benchmark_json.get_key_list(&keys);
|
||||
print_line("STARTUP BENCHMARK:");
|
||||
for (const Variant &K : keys) {
|
||||
print_line("\t-", K, ": ", startup_benchmark_json[K], +" sec.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Engine::Singleton::Singleton(const StringName &p_name, Object *p_ptr, const StringName &p_class_name) :
|
||||
name(p_name),
|
||||
ptr(p_ptr),
|
||||
|
||||
Reference in New Issue
Block a user