简体   繁体   English

检测 .net 应用程序冷启动或热启动

[英]Detecting .net application cold or hot start

I would like to measure startup time of my .net WPF desktop application, however the startup time vary a lot depending if it is a cold or hot start.我想测量我的 .net WPF 桌面应用程序的启动时间,但是启动时间会因冷启动或热启动而有很大差异。 I would like to separate the times of hot and cold starts so I can build better statistics.我想分开热启动和冷启动的时间,以便建立更好的统计数据。 Is it possible somehow to detect hot and cold starts?是否有可能以某种方式检测冷热启动?

.net framework 4.8 without ngen, without MultiCoreJit profile optimizations. .net 框架 4.8 没有 ngen,没有 MultiCoreJit 配置文件优化。 Appication is installed with MSI installer.应用程序是使用 MSI 安装程序安装的。

Edit:编辑:

Cold start冷启动

Start after Windows OS reboot, no clr runtime dlls are loaded in physical memory Windows 操作系统重启后启动,物理 memory 中没有加载 clr 运行时 dll

Hot start热启动

The application was closed and immediately started again.该应用程序已关闭并立即重新启动。 clr runtime and eventually some of the application dlls are still loaded in OS memory so no IO occurs, only address mapping to process address space. clr 运行时和最终一些应用程序 dll 仍然加载在 OS memory 中,因此不会发生 IO,只有地址映射到进程地址空间。

This is how I explain to myself why there is a difference in startup time.这就是我向自己解释为什么启动时间不同的方式。 If I am wrong please correct me.如果我错了,请纠正我。

Persist the start and stop times of the application.保留应用程序的启动和停止时间。 Define a time window between last stop time and next start time that makes it obvious whether you're doing a hot/cold start.在上一次停止时间和下一次启动时间之间定义一个时间 window,这使得您是否在进行热/冷启动变得很明显。 (Note this window is not measuring the startup time at all). (注意这个 window 根本没有测量启动时间)。

For example, pick a 2 second window.例如,选择 2 秒 window。 A cold start requires a reboot, so it will be obvious that last stop will be much more than the 2 seconds before the next start.冷启动需要重新启动,因此很明显最后一次停止将远远超过下一次启动前的 2 秒。

You could persist these values via a script, or by changing your app to log it's start time as early as possible before any other activity, and its stop time as late as possible while app is shutting down.您可以通过脚本保存这些值,或者通过更改您的应用程序以在任何其他活动之前尽可能早地记录其开始时间,并在应用程序关闭时尽可能晚地记录其停止时间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM