diff --git a/profiler/src/main.cpp b/profiler/src/main.cpp index 67ef0dcd..3228bec3 100644 --- a/profiler/src/main.cpp +++ b/profiler/src/main.cpp @@ -3,9 +3,11 @@ #include #include "imgui_impl_glfw.h" #include "imgui_impl_opengl3.h" +#include #include #include #include +#include #include #include #include @@ -17,6 +19,7 @@ # include #endif +#include "../../server/tracy_pdqsort.h" #include "../../server/TracyBadVersion.hpp" #include "../../server/TracyFileRead.hpp" #include "../../server/TracyImGui.hpp" @@ -90,6 +93,36 @@ int main( int argc, char** argv ) } } + std::string connHistFile = tracy::GetSavePath( "connection.history" ); + std::unordered_map connHistMap; + std::vector::const_iterator> connHistVec; + { + FILE* f = fopen( connHistFile.c_str(), "rb" ); + if( f ) + { + uint64_t sz; + fread( &sz, 1, sizeof( sz ), f ); + for( uint64_t i=0; isecond > rhs->second; } ); + } + } + // Setup window glfwSetErrorCallback(glfw_error_callback); if( !glfwInit() ) return 1; @@ -233,6 +266,17 @@ int main( int argc, char** argv ) ImGui::InputText( "Address", addr, 1024 ); if( ImGui::Button( ICON_FA_WIFI " Connect" ) && *addr && !loadThread.joinable() ) { + std::string addrStr( addr ); + auto it = connHistMap.find( addr ); + if( it != connHistMap.end() ) + { + it->second++; + } + else + { + connHistMap.emplace( std::move( addr ), 1 ); + } + view = std::make_unique( addr, fixedWidth, SetWindowTitleCallback ); } ImGui::Separator(); @@ -361,22 +405,24 @@ int main( int argc, char** argv ) } } - FILE* f = fopen( winPosFile.c_str(), "wb" ); - if( f ) { + FILE* f = fopen( winPosFile.c_str(), "wb" ); + if( f ) + { #ifdef GLFW_MAXIMIZED - uint32_t maximized = glfwGetWindowAttrib( window, GLFW_MAXIMIZED ); - if( maximized ) glfwRestoreWindow( window ); + uint32_t maximized = glfwGetWindowAttrib( window, GLFW_MAXIMIZED ); + if( maximized ) glfwRestoreWindow( window ); #else - uint32_t maximized = 0; + uint32_t maximized = 0; #endif - glfwGetWindowPos( window, &x, &y ); - glfwGetWindowSize( window, &w, &h ); + glfwGetWindowPos( window, &x, &y ); + glfwGetWindowSize( window, &w, &h ); - uint32_t data[5] = { uint32_t( x ), uint32_t( y ), uint32_t( w ), uint32_t( h ), maximized }; - fwrite( data, 1, sizeof( data ), f ); - fclose( f ); + uint32_t data[5] = { uint32_t( x ), uint32_t( y ), uint32_t( w ), uint32_t( h ), maximized }; + fwrite( data, 1, sizeof( data ), f ); + fclose( f ); + } } // Cleanup @@ -387,5 +433,22 @@ int main( int argc, char** argv ) glfwDestroyWindow(window); glfwTerminate(); + { + FILE* f = fopen( connHistFile.c_str(), "wb" ); + if( f ) + { + uint64_t sz = uint64_t( connHistMap.size() ); + fwrite( &sz, 1, sizeof( uint64_t ), f ); + for( auto& v : connHistMap ) + { + sz = uint64_t( v.first.size() ); + fwrite( &sz, 1, sizeof( uint64_t ), f ); + fwrite( v.first.c_str(), 1, sz, f ); + fwrite( &v.second, 1, sizeof( v.second ), f ); + } + fclose( f ); + } + } + return 0; }