diff --git a/.efrocachemap b/.efrocachemap index dae4e975..0b19f943 100644 --- a/.efrocachemap +++ b/.efrocachemap @@ -3932,24 +3932,24 @@ "assets/build/windows/Win32/ucrtbased.dll": "https://files.ballistica.net/cache/ba1/b5/85/f8b6d0558ddb87267f34254b1450", "assets/build/windows/Win32/vc_redist.x86.exe": "https://files.ballistica.net/cache/ba1/1c/e1/4a1a2eddda2f4aebd5f8b64ab08e", "assets/build/windows/Win32/vcruntime140d.dll": "https://files.ballistica.net/cache/ba1/50/8d/bc2600ac9491f1b14d659709451f", - "build/prefab/full/linux_x86_64/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/7e/ef/160b7c29aecf8594ce1aa3bb4d9f", - "build/prefab/full/linux_x86_64/release/ballisticacore": "https://files.ballistica.net/cache/ba1/88/29/515b5c5def018fac0176b966bd93", - "build/prefab/full/linux_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/e2/4e/146ae464fad04c9a41ae0d7e01f3", - "build/prefab/full/linux_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/7a/14/febc99c12dabf2c09cf7969bd82f", - "build/prefab/full/mac_x86_64/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/ed/78/7f2d157baabca2fb67b29d95c730", - "build/prefab/full/mac_x86_64/release/ballisticacore": "https://files.ballistica.net/cache/ba1/e4/0e/05afd617a3333be2cebc6e7937f9", - "build/prefab/full/mac_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/47/49/9aef6c1fc8986c36740ae8ae5c83", - "build/prefab/full/mac_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/de/0c/e9bedd01292d103d92b8be7e9076", - "build/prefab/full/windows_x86/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/29/02/166905a0cfcb78acccd082a5d77e", - "build/prefab/full/windows_x86/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/7a/76/df87e67aef1847f9cc4f6d8bc43b", - "build/prefab/full/windows_x86_server/debug/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/d1/3d/431f9304a0c9eeb87d93af764bb6", - "build/prefab/full/windows_x86_server/release/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/da/02/41c7bbfefbae5518f2faa2631a01", + "build/prefab/full/linux_x86_64/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/ce/ff/e8e6e21f17613013e2f9913c14b2", + "build/prefab/full/linux_x86_64/release/ballisticacore": "https://files.ballistica.net/cache/ba1/ce/7f/0b7ed6b14d89aee166a1ddf11fa7", + "build/prefab/full/linux_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/32/28/ffd1e357804e1d04661b3ae003e4", + "build/prefab/full/linux_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/c6/53/148ab447516b331f61f7a8198e93", + "build/prefab/full/mac_x86_64/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/45/e4/6682f99b25aea143469fbd65df64", + "build/prefab/full/mac_x86_64/release/ballisticacore": "https://files.ballistica.net/cache/ba1/82/1b/ceda2fa0e2af6f635e5e4d0fbe08", + "build/prefab/full/mac_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/37/47/3e2a0923c4c24919f10407ae5918", + "build/prefab/full/mac_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/71/a6/d3a856747ed2bdf69092bb5fb8c9", + "build/prefab/full/windows_x86/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/b6/04/c8f17b9768a9369c905ab4d34714", + "build/prefab/full/windows_x86/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/9e/3f/f951c9da358f124f727924fc7d5d", + "build/prefab/full/windows_x86_server/debug/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/a3/7b/b640eee424317a21f87353fe7eb7", + "build/prefab/full/windows_x86_server/release/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/78/de/bffe8a4f2fdac497302adf69f6ef", "build/prefab/lib/linux_x86_64/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/88/8a/aaeb70e76d31ce2686bee5cc4c14", "build/prefab/lib/linux_x86_64/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/fd/cd/3397d744c7405740df4d4ae567f0", "build/prefab/lib/linux_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/c2/5b/ad020af2e062e5caff25e7d0aec4", "build/prefab/lib/linux_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/54/40/8e0cc564f49f8963803834ec7995", - "build/prefab/lib/mac_x86_64/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/bd/15/6ddf0c20288b9f72e5dd2c16a62a", - "build/prefab/lib/mac_x86_64/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/b1/d0/fe3646d8225126baafec16641a93", - "build/prefab/lib/mac_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/23/b6/ada9721f37bc2a090fde0d0a1d83", - "build/prefab/lib/mac_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/99/4c/d5dd9bc0b501dcb0d817f8166243" + "build/prefab/lib/mac_x86_64/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/79/ef/70da9bfe3198a8ef252fdac9985c", + "build/prefab/lib/mac_x86_64/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/2c/3b/3a38efe86d7659542cb11ae28595", + "build/prefab/lib/mac_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/42/fd/ae04337fbde55e248f13c05c2488", + "build/prefab/lib/mac_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/87/13/13038835d3b912db1f02f0a2aa67" } \ No newline at end of file diff --git a/src/ballistica/app/app.cc b/src/ballistica/app/app.cc index cf5f4c61..9e7b1472 100644 --- a/src/ballistica/app/app.cc +++ b/src/ballistica/app/app.cc @@ -2,6 +2,7 @@ #include "ballistica/app/app.h" +#include "ballistica/app/stress_test.h" #include "ballistica/core/thread.h" #include "ballistica/game/game.h" #include "ballistica/graphics/graphics_server.h" @@ -15,7 +16,8 @@ namespace ballistica { -App::App(Thread* thread) : Module("app", thread) { +App::App(Thread* thread) + : Module("app", thread), stress_test_(std::make_unique()) { assert(g_app == nullptr); g_app = this; @@ -128,7 +130,8 @@ void App::ShutdownComplete() { void App::RunEvents() { if (!HeadlessMode()) { // there's probably a better place for this... - UpdateStressTesting(); + // UpdateStressTesting(); + stress_test_->Update(); } // Give platforms a chance to pump/handle their own events. @@ -365,23 +368,7 @@ void App::PushStringEditCall(const std::string& name, const std::string& value, void App::PushSetStressTestingCall(bool enable, int player_count) { PushCall([this, enable, player_count] { - bool was_stress_testing = stress_testing_; - stress_testing_ = enable; - stress_test_player_count_ = player_count; - - // If we're turning on, reset our intervals and things. - if (!was_stress_testing && stress_testing_) { - // So our first sample is 1 interval from now... - last_stress_test_update_time_ = GetRealTime(); - // Reset our frames-rendered tally. - if (g_graphics && g_graphics_server->renderer()) { - last_total_frames_rendered_ = - g_graphics_server->renderer()->total_frames_rendered(); - } else { - // Assume zero if there's no graphics yet. - last_total_frames_rendered_ = 0; - } - } + stress_test_->SetStressTesting(enable, player_count); }); } @@ -415,69 +402,4 @@ void App::PushCursorUpdate(bool vis) { }); } -void App::UpdateStressTesting() { - // Handle a little misc stuff here. - // If we're currently running stress-tests, update that stuff. - if (stress_testing_ && g_input) { - // Update our fake inputs to make our dudes run around. - g_input->ProcessStressTesting(stress_test_player_count_); - - // Every 10 seconds update our stress-test stats. - millisecs_t t = GetRealTime(); - if (t - last_stress_test_update_time_ >= 10000) { - if (stress_test_stats_file_ == nullptr) { - assert(g_platform); - std::string f_name = - g_platform->GetUserPythonDirectory() + "/stress_test_stats.csv"; - stress_test_stats_file_ = g_platform->FOpen(f_name.c_str(), "wb"); - if (stress_test_stats_file_ != nullptr) { - fprintf(stress_test_stats_file_, - "time,averageFps,nodes,models,collideModels,textures,sounds," - "pssMem,sharedDirtyMem,privateDirtyMem\n"); - fflush(stress_test_stats_file_); - if (g_buildconfig.ostype_android()) { - // On android, let the OS know we've added or removed a file - // (limit to android or we'll get an unimplemented warning) - g_platform->AndroidRefreshFile(f_name); - } - } - } - if (stress_test_stats_file_ != nullptr) { - // See how many frames we've rendered this past interval. - int total_frames_rendered; - if (g_graphics && g_graphics_server->renderer()) { - total_frames_rendered = - g_graphics_server->renderer()->total_frames_rendered(); - } else { - total_frames_rendered = last_total_frames_rendered_; - } - float avg = - static_cast(total_frames_rendered - - last_total_frames_rendered_) - / (static_cast(t - last_stress_test_update_time_) / 1000.0f); - last_total_frames_rendered_ = total_frames_rendered; - uint32_t model_count = 0; - uint32_t collide_model_count = 0; - uint32_t texture_count = 0; - uint32_t sound_count = 0; - uint32_t node_count = 0; - if (g_media) { - model_count = g_media->total_model_count(); - collide_model_count = g_media->total_collide_model_count(); - texture_count = g_media->total_texture_count(); - sound_count = g_media->total_sound_count(); - } - assert(g_game); - std::string mem_usage = g_platform->GetMemUsageInfo(); - fprintf(stress_test_stats_file_, "%d,%.1f,%d,%d,%d,%d,%d,%s\n", - static_cast(GetRealTime()), avg, node_count, model_count, - collide_model_count, texture_count, sound_count, - mem_usage.c_str()); - fflush(stress_test_stats_file_); - } - last_stress_test_update_time_ = t; - } - } -} - } // namespace ballistica diff --git a/src/ballistica/app/app.h b/src/ballistica/app/app.h index 655aad86..a212a939 100644 --- a/src/ballistica/app/app.h +++ b/src/ballistica/app/app.h @@ -4,6 +4,7 @@ #define BALLISTICA_APP_APP_H_ #include +#include #include #include @@ -132,15 +133,11 @@ class App : public Module { bool sys_paused_app_{}; bool user_paused_app_{}; bool actually_paused_{}; + std::unique_ptr stress_test_; millisecs_t last_resize_draw_event_time_{}; millisecs_t last_app_resume_time_{}; std::map product_prices_; std::mutex product_prices_mutex_; - FILE* stress_test_stats_file_{}; - millisecs_t last_stress_test_update_time_{}; - int last_total_frames_rendered_{}; - bool stress_testing_{}; - int stress_test_player_count_{8}; }; } // namespace ballistica diff --git a/src/ballistica/app/stress_test.cc b/src/ballistica/app/stress_test.cc index 44357a84..732645d0 100644 --- a/src/ballistica/app/stress_test.cc +++ b/src/ballistica/app/stress_test.cc @@ -10,6 +10,26 @@ namespace ballistica { +void StressTest::SetStressTesting(bool enable, int player_count) { + bool was_stress_testing = stress_testing_; + stress_testing_ = enable; + stress_test_player_count_ = player_count; + + // If we're turning on, reset our intervals and things. + if (!was_stress_testing && stress_testing_) { + // So our first sample is 1 interval from now... + last_stress_test_update_time_ = GetRealTime(); + // Reset our frames-rendered tally. + if (g_graphics && g_graphics_server->renderer()) { + last_total_frames_rendered_ = + g_graphics_server->renderer()->total_frames_rendered(); + } else { + // Assume zero if there's no graphics yet. + last_total_frames_rendered_ = 0; + } + } +} + void StressTest::Update() { assert(InMainThread()); diff --git a/src/ballistica/app/stress_test.h b/src/ballistica/app/stress_test.h index 89c8bed3..ae346649 100644 --- a/src/ballistica/app/stress_test.h +++ b/src/ballistica/app/stress_test.h @@ -16,6 +16,8 @@ class StressTest { // This used to get run from RunEvents() in App. void Update(); + void SetStressTesting(bool enable, int player_count); + private: FILE* stress_test_stats_file_{}; millisecs_t last_stress_test_update_time_{}; diff --git a/src/ballistica/ballistica.cc b/src/ballistica/ballistica.cc index d1081461..483a9eec 100644 --- a/src/ballistica/ballistica.cc +++ b/src/ballistica/ballistica.cc @@ -29,7 +29,7 @@ namespace ballistica { // These are set automatically via script; don't change here. -const int kAppBuildNumber = 20219; +const int kAppBuildNumber = 20220; const char* kAppVersion = "1.5.27"; // Our standalone globals. diff --git a/src/ballistica/core/types.h b/src/ballistica/core/types.h index d9b6c903..a3b5132b 100644 --- a/src/ballistica/core/types.h +++ b/src/ballistica/core/types.h @@ -174,6 +174,7 @@ class Sound; class SoundData; class SpriteMesh; class StackWidget; +class StressTest; class StdInputModule; class Module; class TelnetServer;