mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-23 05:45:00 +02:00
"-loadingTime" cmdline param enhancement
Improves: - the reported time accuracy (from seconds to milliseconds, now e.g. different N++ settings benchmarking is possible) - the ability to analyze various problems (now it is possible to distinguish the time taken by the app/plugin code-init from the possible file loading time) Fix #14472, close #14473
This commit is contained in:
parent
53b5055118
commit
d9d26e5981
@ -43,6 +43,8 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
chrono::steady_clock::duration g_pluginsLoadingTime{};
|
||||
|
||||
enum tb_stat {tb_saved, tb_unsaved, tb_ro, tb_monitored};
|
||||
#define DIR_LEFT true
|
||||
#define DIR_RIGHT false
|
||||
@ -457,7 +459,9 @@ LRESULT Notepad_plus::init(HWND hwnd)
|
||||
_pluginsManager.init(nppData);
|
||||
|
||||
bool enablePluginAdmin = _pluginsAdminDlg.initFromJson();
|
||||
std::chrono::steady_clock::time_point pluginsLoadingStartTP = std::chrono::steady_clock::now();
|
||||
_pluginsManager.loadPlugins(nppParam.getPluginRootDir(), enablePluginAdmin ? &_pluginsAdminDlg.getAvailablePluginUpdateInfoList() : nullptr, enablePluginAdmin ? &_pluginsAdminDlg.getIncompatibleList() : nullptr);
|
||||
g_pluginsLoadingTime = std::chrono::steady_clock::now() - pluginsLoadingStartTP;
|
||||
_restoreButton.init(_pPublicInterface->getHinst(), hwnd);
|
||||
|
||||
// ------------ //
|
||||
|
@ -45,6 +45,10 @@
|
||||
#include "md5Dlgs.h"
|
||||
#include <vector>
|
||||
#include <iso646.h>
|
||||
#include <chrono>
|
||||
|
||||
extern std::chrono::steady_clock::time_point g_nppStartTimePoint;
|
||||
extern std::chrono::steady_clock::duration g_pluginsLoadingTime;
|
||||
|
||||
|
||||
#define MENU 0x01
|
||||
|
@ -15,7 +15,6 @@
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#include <time.h>
|
||||
#include <shlwapi.h>
|
||||
#include "Notepad_plus_Window.h"
|
||||
|
||||
@ -23,7 +22,6 @@ const TCHAR Notepad_plus_Window::_className[32] = TEXT("Notepad++");
|
||||
HWND Notepad_plus_Window::gNppHWND = NULL;
|
||||
|
||||
|
||||
|
||||
namespace // anonymous
|
||||
{
|
||||
|
||||
@ -65,10 +63,6 @@ void Notepad_plus_Window::setStartupBgColor(COLORREF BgColor)
|
||||
|
||||
void Notepad_plus_Window::init(HINSTANCE hInst, HWND parent, const TCHAR *cmdLine, CmdLineParams *cmdLineParams)
|
||||
{
|
||||
time_t timestampBegin = 0;
|
||||
if (cmdLineParams->_showLoadingTime)
|
||||
timestampBegin = time(NULL);
|
||||
|
||||
Window::init(hInst, parent);
|
||||
WNDCLASS nppClass{};
|
||||
|
||||
@ -172,8 +166,13 @@ void Notepad_plus_Window::init(HINSTANCE hInst, HWND parent, const TCHAR *cmdLin
|
||||
if (cmdLineParams->_alwaysOnTop)
|
||||
::SendMessage(_hSelf, WM_COMMAND, IDM_VIEW_ALWAYSONTOP, 0);
|
||||
|
||||
std::chrono::steady_clock::duration sessionLoadingTime{};
|
||||
if (nppGUI._rememberLastSession && !nppGUI._isCmdlineNosessionActivated)
|
||||
{
|
||||
std::chrono::steady_clock::time_point sessionLoadingStartTP = std::chrono::steady_clock::now();
|
||||
_notepad_plus_plus_core.loadLastSession();
|
||||
sessionLoadingTime = std::chrono::steady_clock::now() - sessionLoadingStartTP;
|
||||
}
|
||||
|
||||
if (nppParams.doFunctionListExport() || nppParams.doPrintAndExit())
|
||||
{
|
||||
@ -297,9 +296,14 @@ void Notepad_plus_Window::init(HINSTANCE hInst, HWND parent, const TCHAR *cmdLin
|
||||
for (size_t i = 0, len = _notepad_plus_plus_core._internalFuncIDs.size() ; i < len ; ++i)
|
||||
::SendMessage(_hSelf, WM_COMMAND, _notepad_plus_plus_core._internalFuncIDs[i], 0);
|
||||
|
||||
std::chrono::steady_clock::duration cmdlineParamsLoadingTime{};
|
||||
std::vector<generic_string> fns;
|
||||
if (cmdLine)
|
||||
{
|
||||
std::chrono::steady_clock::time_point cmdlineParamsLoadingStartTP = std::chrono::steady_clock::now();
|
||||
fns = _notepad_plus_plus_core.loadCommandlineParams(cmdLine, cmdLineParams);
|
||||
cmdlineParamsLoadingTime = std::chrono::steady_clock::now() - cmdlineParamsLoadingStartTP;
|
||||
}
|
||||
|
||||
// Launch folder as workspace after all this dockable panel being restored from the last session
|
||||
// To avoid dockable panel toggle problem.
|
||||
@ -385,12 +389,14 @@ void Notepad_plus_Window::init(HINSTANCE hInst, HWND parent, const TCHAR *cmdLin
|
||||
|
||||
if (cmdLineParams->_showLoadingTime)
|
||||
{
|
||||
time_t timestampEnd = time(NULL);
|
||||
double loadTime = difftime(timestampEnd, timestampBegin);
|
||||
|
||||
char dest[256];
|
||||
sprintf(dest, "Loading time : %.0lf seconds", loadTime);
|
||||
::MessageBoxA(NULL, dest, "", MB_OK);
|
||||
std::chrono::steady_clock::duration nppInitTime = (std::chrono::steady_clock::now() - g_nppStartTimePoint) - g_pluginsLoadingTime - sessionLoadingTime - cmdlineParamsLoadingTime;
|
||||
std::wstringstream wss;
|
||||
wss << L"Notepad++ initialization: " << std::chrono::hh_mm_ss{ std::chrono::duration_cast<std::chrono::milliseconds>(nppInitTime) } << std::endl;
|
||||
wss << L"Plugins loading: " << std::chrono::hh_mm_ss{ std::chrono::duration_cast<std::chrono::milliseconds>(g_pluginsLoadingTime) } << std::endl;
|
||||
wss << L"Last session loading: " << std::chrono::hh_mm_ss{ std::chrono::duration_cast<std::chrono::milliseconds>(sessionLoadingTime) } << std::endl;
|
||||
wss << L"Command line params handling: " << std::chrono::hh_mm_ss{ std::chrono::duration_cast<std::chrono::milliseconds>(cmdlineParamsLoadingTime) } << std::endl;
|
||||
wss << L"Total loading time: " << std::chrono::hh_mm_ss{ std::chrono::duration_cast<std::chrono::milliseconds>(nppInitTime + g_pluginsLoadingTime + sessionLoadingTime + cmdlineParamsLoadingTime) };
|
||||
::MessageBoxW(NULL, wss.str().c_str(), L"Notepad++ loading time (hh:mm:ss.ms)", MB_OK);
|
||||
}
|
||||
|
||||
bool isSnapshotMode = nppGUI.isSnapshotMode();
|
||||
|
@ -377,10 +377,13 @@ void stripIgnoredParams(ParamVector & params)
|
||||
} // namespace
|
||||
|
||||
|
||||
std::chrono::steady_clock::time_point g_nppStartTimePoint{};
|
||||
|
||||
|
||||
int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE /*hPrevInstance*/, _In_ PWSTR pCmdLine, _In_ int /*nShowCmd*/)
|
||||
{
|
||||
g_nppStartTimePoint = std::chrono::steady_clock::now();
|
||||
|
||||
bool TheFirstOne = true;
|
||||
::SetLastError(NO_ERROR);
|
||||
::CreateMutex(NULL, false, TEXT("nppInstance"));
|
||||
|
Loading…
x
Reference in New Issue
Block a user