性能计数器应用

编程入门 行业动态 更新时间:2024-10-27 22:21:46
本文介绍了性能计数器应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

大家好, 我制作了一个读取大量文件并处理内容的应用程序.此内容可以更改. 有时应用程序非常慢.我知道这可能是因为文件很大.但是我从来没有发现什么文件.所以我想做一个性能指标.这就是我的想法: 1.申请开始 2.每次读取和处理文件时,我都会节省应用程序用于读取和处理该文件的时间(或滴答声). 3.对所有文件(大约20个)重复步骤2. 4.检查时间(或刻度)或上一次运行是否超过25%.如果是这样:警告. 5.应用程序结束并显示带有第4步值的报告 这里的问题是它永远不会非常准确.如果文件是在0.25毫秒内完成,而在下一次0.50毫秒内完成,则已经增加了25%.但是下一次运行相同文件的时间是0.25毫秒.我想要的是一个非常准确的性能指标. 有谁知道如何以最佳方式实现这一目标? 谢谢

Hi all, I have made an application that reads a lot of files and processes the contents. This content can change. Sometimes the application is very slow. I know this could be because of a file is large. But I never find out what file. So I want to make a performance counter. This is what I had in mind: 1. Application starts 2. Each time a file is read and processed I save the amount of time (or ticks) that the application used to read and process that file. 3. Repeat step 2 for all files (20 or so). 4. Check if the time (or ticks) or the previous run is more than 25%. If so: Warning. 5. Application ends and shows a report with values of step 4 Problems here is that it is never very accurate. If a file is done in 0,25 ms and the next time 0,50 ms it''s already 25% more. But the next run the same file is done in 0,25 ms. What I want is a very accurate counter on the performance. Has anyone any idea how this can be accomplished in the best way? Thanks

推荐答案

您是否消除了所有其他瓶颈,并确定是导致问题的原因仅是IO操作-您可能还在代码的其他区域可以节省一些时间-您无法真正提高实际IO操作的性能. 例如 在第2步中,检查是否要在循环中重新创建对象,因为这可能会导致问题而不是IO. 确定您要警告的实际时间阈值,而不是上一次运行的百分比-如果循环比上一次慢24%,会发生什么情况-这会很快增加.我建议您使用 StopWatch [ ^ ]类为此-请记住在每个文件之后重设时钟! 一旦您确定了阈值时间,并且循环运行超过了此时间,只需像现在一样记录文件名即可. Have you eliminated all other bottlenecks and positively identified that it is only the IO opertation that is causing the issue - there are probably other areas of your code that you can save some time on - you can''t really improve the perfromance of the actual IO operation. e.g. Within step 2, check whether you are recreating objects in your loop as this could be causing the issue rather than the IO. Decide an actual time threshold that you want to warn about rather than a percentage of the last run - what happens if loop is 24% slowly than the previous one - this would compound up pretty quickly. I would suggest that you use the StopWatch[^] class for this - remember to reset the clock after each file though! Once you have decided on you threashold time and a run through the loop exceeds this just log the filename as you are now.

更多推荐

性能计数器应用

本文发布于:2023-11-05 04:27:39,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1559899.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:计数器   性能

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!