递增 AverageTimer32 性能计数器

发布于 2024-09-27 22:39:17 字数 775 浏览 1 评论 0原文

我将一些检测转移到 PostSharp 方面,基本上增加计时计数器的代码如下所示:

MyPerformanceCounter.IncrementBy(elapsed);
MyPerformanceCounterBase.Increment();

这工作正常,我看到 Perfmon 中更新了正确的值(MyPerformanceCounter 是 AverageTimer32,MyPerformanceCounterBase 是 AverageBase)。

然而,在执行此操作时,我注意到已经存在一些仪器方面的问题:

Marcin Kaluza 的这个

和 PostSharp 示例中的这个非常相似

在这两个示例中,它们都只有第一行 - AverageBase 基数上的增量丢失了。如果我尝试这样做,那么计数器将停止工作(没有错误,但在 perfmon 中看不到任何内容)。

我错过了什么吗?这两种实现都不需要显式更新基本计数器,这似乎太巧合了。我正在测试这个的机器上使用 Vista 64。

I'm moving some instrumentation into PostSharp aspects, basically the code which is incrementing the timing counters looks something like the following:

MyPerformanceCounter.IncrementBy(elapsed);
MyPerformanceCounterBase.Increment();

This works fine and I see the correct values getting updated in Perfmon (MyPerformanceCounter is an AverageTimer32, MyPerformanceCounterBase is an AverageBase).

However whilst doing this I noticed that there were already a couple of instrumentation aspects floating around:

This one by Marcin Kaluza

and this very similar one from the PostSharp examples

In both of them they only have the first line - the increment on the AverageBase base is missing. If I try this then the counter stops working (no errors, but nothing visible in perfmon).

Am I missing something? It seems to be too much of a coincidence for both of these implementations to not need the explicit update to the base counter. I'm using Vista 64 on machine where I'm testing this.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

勿忘初心 2024-10-04 22:39:17

就 PostSharp 网站而言,我(可耻地)认为我没有真正测试它们,现在,查看文档,我发现您可能是对的。

In the case of the PostSharp web site, I (shamefully) think I did not really test them, and now, looking at the documentation, I see you're probably right.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文