Visual Studio 宏 - 记录解决方案打开、关闭、构建等的时间戳

发布于 2024-10-01 10:48:11 字数 998 浏览 5 评论 0原文

我有一个需要一段时间才能打开的解决方案。 (5 分钟)由于我们的流程和程序,我经常在同一解决方案的不同分支之间跳转。我每天都会多次关闭和加载同一解决方案的不同变体。这已经超过 15 分钟了,光是等待我的 Visual Studio 就浪费了 30 分钟。我将罪魁祸首归咎于过时的计算机硬件。我想捕获解决方案加载时间以及构建时间的指标。我的目标是将这些指标呈现给管理层。

我正在使用 Visual Studio 宏来跟踪此信息。

就目前情况而言,我正在记录这三个事件 EnvDTE.SolutionEvents.BeforeClosing、EnvDTE.SolutionEvents.AfterClosing、EnvDTE.SolutionEvents.Opened 的时间戳。

问题是,SolutionEvents.Opened 在整个解决方案加载后触发。我需要从开始加载解决方案到完成时生成时间戳。

如何查明 Visual Studio 何时开始加载解决方案?以便我可以将其与完成加载的时间进行比较。

下面是我的代码(我的 LogWithTimeStamp() 函数只是将字符串写入以当前时间戳为前缀的文件中:

Private Sub SolutionEvents_BeforeClosing() Handles SolutionEvents.BeforeClosing
    LogWithTimeStamp("SolutionEvents.BeforeClosing")
End Sub

Private Sub SolutionEvents_AfterClosing() Handles SolutionEvents.AfterClosing
    LogWithTimeStamp("SolutionEvents.AfterClosing")
End Sub

Private Sub SolutionEvents_Opened() Handles SolutionEvents.Opened
    LogWithTimeStamp("SolutionEvents.Opened")
End Sub

I've got a solution that takes a while to open. (5 minutes) Due to our processes and procedures I'm constantly jumping around between different branches of the same solution. I'm constantly closing and loading different variations of the same solution more than a few times a day. That's over 15 minutes - 30 minutes wasted just wating for my Visual Studio. I'm blaming the outdated computer hardware as the culprit. I want to capture metrics of how long solutions are taking to load as well as how long build times are taking. My goal is to present these metrics to management.

I'm using Visual Studio Macros to track this information.

As it stands right now I'm logging time stamps on these three events EnvDTE.SolutionEvents.BeforeClosing, EnvDTE.SolutionEvents.AfterClosing, EnvDTE.SolutionEvents.Opened.

The problem is, the SolutionEvents.Opened fires after the entire solution has been loaded. I need to generate a timestamp from when I start to load the solution and when it finishes.

How can I find out when Visual Studio starts loading the solution? So that I can compare it to when it finished loading.

Below is my code (My LogWithTimeStamp() function just writes the string to a file with the current timestamp as a prefix:

Private Sub SolutionEvents_BeforeClosing() Handles SolutionEvents.BeforeClosing
    LogWithTimeStamp("SolutionEvents.BeforeClosing")
End Sub

Private Sub SolutionEvents_AfterClosing() Handles SolutionEvents.AfterClosing
    LogWithTimeStamp("SolutionEvents.AfterClosing")
End Sub

Private Sub SolutionEvents_Opened() Handles SolutionEvents.Opened
    LogWithTimeStamp("SolutionEvents.Opened")
End Sub

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文