简体   繁体   English

监控多线程性能

[英]Monitor multiple thread performance

I have create a windows service having multiple threads (approx 4-5 threads). 我创建了一个具有多个线程(大约4-5个线程)的Windows服务。 In this service thread created at specific internal and abort. 在此服务中,在特定内部创建线程并中止。 Once thread is created it performs some I/O operations & db operation. 创建线程后,它将执行一些I / O操作和db操作。

I have a GUI for this service to provide configuration which is required by this service. 我有此服务的GUI,以提供此服务所需的配置。 In this GUI I want to add one more functionality which shows me the performance of windows service with respect to all threads. 在此GUI中,我想添加一个功能,向我展示Windows服务相对于所有线程的性能。 I want show CPU utilization (if multicore processor is available than all the processors utilization) with its memory utilization. 我想显示CPU利用率(如果多核处理器可用,而不是所有处理器利用率)及其内存利用率。

If you look at Windows Task Manager it shows CPU (Per core basis) + Memory Utilization, I want to build the same thing but only for threads running by my windows service. 如果您查看Windows Task Manager,它显示的是CPU(每核)+内存利用率,我想构建相同的东西,但仅针对Windows服务运行的线程。

Can anybody help me out how to get CPU% and memory utilization per thread? 有人可以帮助我如何获得每个线程的CPU%和内存利用率吗?

I think you cannot get the CPU and Memory utilization of Threads. 我认为您无法获得线程的CPU和内存利用率。 Instead you can get the same for your service. 相反,您可以获得相同的服务。

My question is, why would you require to build your own functionality, where SysInternals Process explorer gives more details for you? 我的问题是,为什么您需要构建自己的功能,而SysInternals Process Explorer在其中为您提供更多详细信息? Any specific needs? 有什么特殊需要吗?

If you need to monitor the thread activities, you could better log some information using Log4net or other logging tools. 如果需要监视线程活动,则最好使用Log4net或其他日志记录工具记录一些信息。 This will get you an idea about the threads and what they are doing. 这将使您对线程及其作用有所了解。

To be more specific, you could publish the logs using TelNetAppender, which can be received by your application. 更具体地说,您可以使用TelNetAppender发布日志,您的应用程序可以接收这些日志。 This will help you to look into the Process in real time. 这将帮助您实时查看流程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM