You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Improve startup benchmarking
Move the benchmarking measuring methods from `Engine` to `OS` to allow for platform specific overrides (e.g: can be used to hook into platform specific benchmarking and tracing capabilities).
This commit is contained in:
@@ -33,9 +33,7 @@
|
||||
#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/variant/typed_array.h"
|
||||
#include "core/version.h"
|
||||
|
||||
@@ -319,43 +317,6 @@ 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