如何在运行时内部测量 Silverlight 应用程序的性能/资源状态?
我想测量 silverlight 应用程序在运行时的资源消耗。我不想使用外部分析器,因为我想评估整体应用程序性能(尤其是 CPU 消耗),以根据应用程序的当前性能状态显示/隐藏功能。
有办法衡量吗?
谢谢, 尤文
I want to measure the resource consumption of my silverlight application at runtime. I do NOT want to use an external profiler, since I want to evaluate the overall application performance (esp. regarding CPU consumption), to show/hide functionality depending on the current performance status of the application.
Is there a way to measure that?
Thx,
Juve
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Silverlight 沙箱模型不应允许您访问开箱即用的内容。我对 Silverlight 的了解不够,无法判断 CPU 利用率是否是该规则的例外,但如果您在 Google 上找不到任何内容,则可能是这种情况。
您最好的选择是计算一些重要方法的执行时间,或者计算帧速率或类似的值,并将其用作可用性能的间接测量。
无论如何,这样定义相关措施可能更容易。就像如果帧率< 20=>如果帧率 > 则删除内容30=>添加东西。
Silverlight 中没有秒表,但您可以在 Google。
The Silverlight sandboxing model should not allow you to access things out of the box. I don't Silverlight enough to tell if CPU-utilization is an exception to that rule, but if you can not find anything on Google that is probably the case.
You best bet is to time the execution of some of your important methods, or calculate framerate or similar and use that as an indirect measurement of available performance.
This is probably easier to define relevant measures that way anyway. Like if framerate < 20 => remove stuff, if framerate > 30 => add stuff.
There is no Stopwatch in Silverlight, but you can find implementations on Google.