我应该如何准备添加性能计数器?

发布于 2024-10-11 02:39:08 字数 251 浏览 5 评论 0原文

我开始构建缓存机制,在该功能中我想添加对性能计数器的支持,所以问题是我如何计划此支持的头以便在进入时我需要修改尽可能少的代码这个功能

是我第一次使用这个功能,我想我现在需要(在创建缓存机制之前)创建简单的程序,以便了解我该如何准备它。.

如果我会尝试提前猜测我需要什么衡量一下,当我实施它时,它会对我的功能有帮助吗?

您对我应该如何准备添加此功能还有其他建议吗?

是否有任何已知的性能计数器替代方案?

谢谢。

I am starting to build caching mechanism, in the feature I will want to add a support for performance counter, so the question is how can I plan for a head for this support inorder I will need to modify little code as possible when I am entering this feature

Sine it my first time using this feature, I think I need now(before creating the cache mechanism) to create simple program in order to understand how can I prepare for it..

If I will try to guess for advance what I need to measure, it will help me in the in feature when I will implement it?

Do you have any another suggestion how should I prepare to add this feature?

Is there any known alternative to performance counter?

Thanks.

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

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

发布评论

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

评论(2

墨洒年华 2024-10-18 02:39:08

打开和更新性能计数器非常简单,只需要几条语句。但您确实需要考虑将报告哪些措施,以及这是否是具有一个或多个实例的计数器对象。您将需要一个安装程序(需要注册性能计数器)。

首先考虑您将报告的措施。诸如缓存使用率、缓存中的项目和缓存命中率之类的事情是显而易见的。但是还有其他什么可以帮助管理您的申请吗?如果您可以与管理和支持该应用程序的人员交谈,那么就这样做吧——他们可能对什么是有用的有自己的想法。

期望在实际使用中了解什么是有用的计数器!

如果单个系统上只有一个缓存实例,那么多实例计数器就没有意义,但如果您需要实例,那么您需要考虑如何命名实例。

最后,值得一看的是计数器类型的可用选项及其含义 - 性能计数器系统将为您做一些工作(例如计算单个计数器的增量和速率以及跨实例的总数)。

Opening and updating a performance counter is very easy, only a few statements are needed. But you do need to consider what measures you will report and will this be a counter object with one or multiple instances. And you will need an installer (performance counters need to be registered).

First consider the measures you will report on. Things like cache use rate, items in cache and cache hit ratio are obvious. But is there anything else that will help administer your application? If you can talk to the people who will administer and support the application then do so—they are likely to have their own ideas about what is useful.

Expect to learn in real use what are the useful counters!

If there will be a single instance of your cache on a single system then multiple-instance counters do not make sense, but if you need instances then you need to think how the instances will be named.

Finally, worth looking at the options available for counter types and what they mean—the performance counter system will do some work for you (like calculating deltas and rates of individual counters and totals across instances).

岁月如刀 2024-10-18 02:39:08

这取决于性能测量的复杂程度。如果它很简单并且只在少数地方需要,请使用编译器开关或类似的东西。对于复杂且更可持续的场景,我尝试了两种可能性:

  1. 您可以使用 AOP 框架之一,例如 PostSharp。虽然可能有点矫枉过正,优点是您不必以任何方式准备代码,您只需在适当的位置添加适当的性能计数“方面”即可。

  2. 您可以考虑为您的应用程序设计一种本身可配置的架构,即由通过发送和接收“消息”进行通信的松散组件组成。在这样的架构中,组件彼此不认识,它们只知道它们接收/发送消息的接收/发送点。然后,可以轻松地将正确配置的性能计数组件“插入”组件网络中的任意位置。

干杯,

保罗

It depends on the complexity of your performance measuring. If it's simple and only required at few places, use compiler switches or similar stuff. For complicated and mor sustainable scenarios I have tried two possibilities:

  1. You could go with one of the AOP frameworks, such as PostSharp. Might be an overkill though, the advantage is that you don't have to prepare your code in any way, you just add appropriate performance counting "aspect" at appropriate positions.

  2. You could consider an architecture for your application which is per se configurable, i.e. consists of loose components which communicate by sending and receiving "messages". In such architectures, components do not know each other they just know a reception/sending points from/to they receive/send messages. Then, it is easy to "insert" properly configured performance counting components at arbitrary positions in an component network.

Cheers,

Paul

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