主婦と.NETと犬のぶろぐ

奥様 と プログラム と お犬様 の 楽しい日常

目次

Blog 利用状況

ニュース

書庫

日記カテゴリ

PerformanceCounter(System.Diagnostics.PerformanceCounter)

(@ @;)
PerformanceCounter で取得した値を NPlot の折れ線グラフで描画してみました。
Nplot は ここからダウンロード できます。
今日ダウンロードしたのは nplot-0.9.10.0.zip です。

NPlot はだーいぶ前に遊びで使ったことがあったんですが、
PerformanceCounter は初めて。しかも関連する情報を調べると山のようにあります...。
なんか難しいし...。
NPlot のサンプルもそのままじゃ動いてくれないし...。
でも実行結果みたら、おもろかったのでそのうち もう一度チャレンジしてみようかな...。

■参考文献
PerformanceCounter クラス
PerformanceCounterCategory クラス
パフォーマンスしきい値の監視
パフォーマンスカウンタのカテゴリ、カウンタの一覧を取得する(DOBON!さん)
NPlot

■実行画像
Process _Total %Processor Time を監視しています
Panel

Public Class PerformanceCounterTest

Private Const CATEGORY_COMBO_NAME As String = "categoryComboBox" Private Const COUNTER_COMBO_NAME As String = "counterComboBox" Private Const PLOT_AREA_NAME As String = "plotSurface"
Private m_timer As Timer = New System.Windows.Forms.Timer() Private m_graphData As List(Of Single) = New List(Of Single)
Private Sub PerformanceCounterTest_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' カテゴリの一覧を取得して ComboBox に表示する Dim categories As System.Diagnostics.PerformanceCounterCategory() = _ System.Diagnostics.PerformanceCounterCategory.GetCategories()
Dim categoryComboBox As ComboBox = New ComboBox() Me.Controls.Add(categoryComboBox) With categoryComboBox .Name = CATEGORY_COMBO_NAME .DropDownStyle = ComboBoxStyle.DropDownList .Location = New Point(0, 0) .Size = New Size(250, .Size.Height) For Each cat As System.Diagnostics.PerformanceCounterCategory In categories If cat.CategoryType = PerformanceCounterCategoryType.SingleInstance AndAlso _ cat.GetCounters().Length > 0 Then .Items.Add(cat.CategoryName) ElseIf cat.CategoryType = PerformanceCounterCategoryType.MultiInstance Then ' MultiInstance の場合は一番最初のインスタンス名をくっつける For Each instanceName As String In cat.GetInstanceNames() .Items.Add(cat.CategoryName & ":" & instanceName) Next End If Next AddHandler .SelectedIndexChanged, AddressOf CategoryComboBox_SelectedIndexChanged .SelectedIndex = -1 End With
' カウンタの ComboBox の設定 Dim counterComboBox As ComboBox = New ComboBox() Me.Controls.Add(counterComboBox) With counterComboBox .Name = COUNTER_COMBO_NAME .DropDownStyle = ComboBoxStyle.DropDownList .Location = New Point(0, 20) .Size = New Size(250, .Size.Height) End With
' 表示ボタン Dim execButton As Button = New Button() Me.Controls.Add(execButton) With execButton .Location = New Point(0, 40) .Text = "表示" AddHandler .Click, AddressOf ExecButton_Click End With
' 停止ボタン Dim stopButton As Button = New Button() Me.Controls.Add(stopButton) With stopButton .Location = New Point(100, 40) .Text = "停止" AddHandler .Click, AddressOf StopButton_Click End With
With Me.m_timer .Stop() .Interval = 1000 AddHandler .Tick, AddressOf Timer_Tick End With
' ここから Nplot の設定 Dim linePlot As NPlot.LinePlot = New NPlot.LinePlot With linePlot .DataSource = Me.m_graphData .Pen.Color = Color.Green .Pen.Width = 1.5F End With
Dim plotSurface As NPlot.Windows.PlotSurface2D = New NPlot.Windows.PlotSurface2D() With plotSurface .Name = PLOT_AREA_NAME .Size = New Size(280, 200) .Location = New Point(0, 65)
.Clear() .Add(linePlot) .YAxis1.WorldMax = 1000 .YAxis1.Label = "Y" .XAxis1.WorldMax = 100 .XAxis1.Label = "X" .Refresh() End With Me.Controls.Add(plotSurface)
End Sub
Private Sub CategoryComboBox_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) ' カテゴリの ComboBox で選択された値を取得 Dim selectedCat As String = DirectCast(DirectCast(sender, ComboBox).SelectedItem, String) Dim catName As String = selectedCat Dim instanceName As String = String.Empty If selectedCat.Contains(":") Then catName = selectedCat.Split(":"c)(0) instanceName = selectedCat.Split(":"c)(1) End If Dim categories As System.Diagnostics.PerformanceCounterCategory() = _ System.Diagnostics.PerformanceCounterCategory.GetCategories() Dim category As System.Diagnostics.PerformanceCounterCategory = Nothing For Each cat As System.Diagnostics.PerformanceCounterCategory In categories If cat.CategoryName = catName Then category = cat Exit For End If Next
' カテゴリとインスタンス名からカウンタの一覧を取得して ComboBox に表示 Dim cmb As ComboBox = DirectCast(Me.Controls(COUNTER_COMBO_NAME), ComboBox) cmb.Items.Clear() If category Is Nothing Then Return
Dim counters As System.Diagnostics.PerformanceCounter() If instanceName = String.Empty Then counters = category.GetCounters() Else counters = category.GetCounters(instanceName) End If For Each counter As System.Diagnostics.PerformanceCounter In counters cmb.Items.Add(counter.CounterName) Next cmb.SelectedIndex = -1 End Sub
' 表示ボタン Private Sub ExecButton_Click(ByVal sender As Object, ByVal e As EventArgs) Me.m_timer.Stop() Me.m_graphData.Clear() Dim plotSurface As NPlot.Windows.PlotSurface2D = DirectCast(Me.Controls(PLOT_AREA_NAME), NPlot.Windows.PlotSurface2D) plotSurface.Refresh()
Dim catCombo As ComboBox = DirectCast(Me.Controls(CATEGORY_COMBO_NAME), ComboBox) Dim counterCombo As ComboBox = DirectCast(Me.Controls(COUNTER_COMBO_NAME), ComboBox)
If catCombo.SelectedIndex < 0 OrElse counterCombo.SelectedIndex < 0 Then Return
Dim selectedCat As String = DirectCast(catCombo.SelectedItem, String) Dim catName As String = selectedCat Dim instanceName As String = String.Empty If selectedCat.Contains(":") Then catName = selectedCat.Split(":"c)(0) instanceName = selectedCat.Split(":"c)(1) End If Dim counterName As String = DirectCast(counterCombo.SelectedItem, String)
' PerformanceCounter の設定 With Me.PerformanceCounter1 .MachineName = "." .CategoryName = catName .InstanceName = instanceName .CounterName = counterName End With Me.m_timer.Start() End Sub
' 停止ボタン Private Sub StopButton_Click(ByVal sender As Object, ByVal e As EventArgs) Me.m_timer.Stop() End Sub
Private Sub Timer_Tick(ByVal sender As Object, ByVal e As EventArgs) Me.m_graphData.Add(Me.PerformanceCounter1.NextValue) Dim plotSurface As NPlot.Windows.PlotSurface2D = DirectCast(Me.Controls(PLOT_AREA_NAME), NPlot.Windows.PlotSurface2D) plotSurface.Refresh() End Sub
End Class

投稿日時 : 2007年3月6日 10:36

Feedback

# jyHxkZpLaxXoqMFemuT 2014/08/05 5:50 http://crorkz.com/

U90321 Very neat blog article. Great.

# LjdOIOnRdhhwUv 2014/09/09 20:34 http://www.designingdigitally.com

This web site is mostly a stroll-by way of for the entire information you wished about this and didn't know who to ask. Glimpse right here, and also you'll positively discover it.

# oLtqbSkmKJG 2019/04/19 18:09 https://www.suba.me/

IM2D7S This blog was how do you say it? Relevant!! Finally I ave found something that helped me. Thanks!

# cOtsjCHRrEG 2019/04/26 22:10 http://www.frombusttobank.com/

So content to possess located this publish.. Seriously beneficial perspective, many thanks for giving.. Great feelings you have here.. Extremely good perception, many thanks for posting..

# NOnptizhXBRb 2019/04/27 3:00 http://all4webs.com/smellarch1/emvtaspuze600.htm

Maybe you can write subsequent articles relating to this

# wemDMfjyGMtEbjPhj 2019/04/27 5:57 https://ceti.edu.gt/members/harry28320/profile/

Is not it amazing whenever you discover a fantastic article? My personal web browsings seem full.. thanks. Respect the admission you furnished.. Extremely valuable perception, thanks for blogging..

# TyzGgTUSXsyywGcDTp 2019/04/28 2:58 http://bit.do/ePqUC

I was recommended this blog by my cousin. I am not sure whether this post is written by him as nobody else know such detailed about my problem. You are wonderful! Thanks!

# JBcXgFJxwmxBPKWwTOO 2019/04/28 5:20 http://bit.do/ePqVH

what you are stating and the way in which you say it.

# tSNAZvIBXTKSfG 2019/04/29 18:39 http://www.dumpstermarket.com

It as not that I want to replicate your internet site, but I really like the layout. Could you let me know which design are you using? Or was it tailor made?

# YYpSduvcwia 2019/04/30 20:34 https://cyber-hub.net/

Wow, great blog post.Really looking forward to read more. Keep writing.

# eEhTjXzXnEUT 2019/05/01 18:29 https://www.bintheredumpthatusa.com

This blog is really awesome and also informative. I have found a lot of useful stuff out of this blog. I ad love to come back over and over again. Cheers!

# lEBRIfKOrtENAc 2019/05/02 21:22 https://www.ljwelding.com/hubfs/tank-fit-up-bed-sy

Really appreciate you sharing this blog.Thanks Again. Want more.

# HpcqZuaoPUhwGOujDQo 2019/05/02 23:49 https://www.ljwelding.com/hubfs/welding-tripod-500

I really liked your post.Much thanks again. Want more.

# hhhnhSPPvcqXG 2019/05/03 7:41 http://engafirakyby.mihanblog.com/post/comment/new

Really enjoyed this blog post.Thanks Again. Really Great.

# NrSZdMKMnWYolc 2019/05/03 10:02 http://nifnif.info/user/Batroamimiz208/

Wow! At last I got a webpage from where I know how to in fact take valuable data regarding my study and knowledge.

# DjRroSgOPxLOeZOS 2019/05/03 11:41 https://mveit.com/escorts/united-states/san-diego-

redirected here Where can I find the best online creative writing courses? I live in NYC so which colleges offer the best online creative writing course? If not in a college than where else?.

# dimNQunfJA 2019/05/03 16:19 https://www.youtube.com/watch?v=xX4yuCZ0gg4

sharing. my web page english bulldog puppies

# yNnFkEkvymHVNayiaT 2019/05/03 16:49 https://mveit.com/escorts/netherlands/amsterdam

In my opinion you commit an error. Let as discuss. Write to me in PM, we will communicate.

# FnBrZCelnShMZsc 2019/05/03 18:42 http://bgtopsport.com/user/arerapexign642/

There is perceptibly a lot to identify about this. I consider you made some good points in features also.

# mjPcWiPZDg 2019/05/04 0:13 http://deviceventures.net/__media__/js/netsoltrade

This blog inspired me to write my own blog.

# rLbfPkPKrjQIuIfRqQ 2019/05/04 4:11 https://timesofindia.indiatimes.com/city/gurgaon/f

When considering home roofing styles, there are still roofing shovel a

# GWZAdGQoNMqiRYrhpO 2019/05/07 15:12 https://www.newz37.com

Thanks for sharing your info. I really appreciate your efforts and I will be waiting for your further post thanks once again.

# hyCrsJUSCUPJ 2019/05/09 16:06 https://reelgame.net/

Im thankful for the blog article.Really looking forward to read more. Really Great.

# lzBUVrSjFFtbYcavRe 2019/05/09 16:51 http://gail2406ul.nightsgarden.com/so-you-should-a

You are my inspiration, I possess few blogs and occasionally run out from post . Actions lie louder than words. by Carolyn Wells.

# GOECJXutHtZMoOv 2019/05/09 22:18 https://www.sftoto.com/

Some really excellent info , Gladiolus I observed this.

# PDYHVJZOaf 2019/05/10 3:32 https://totocenter77.com/

Signes astrologique ascendant comment trouver son ascendant astrologique

# BaQeaHoozgzmhrlzd 2019/05/10 3:51 https://www.navy-net.co.uk/rrpedia/User:WilliemaeB

Thanks for helping out, superb info. а?а?а? Hope is the denial of reality.а? а?а? by Margaret Weis.

# xIvvnbQPpyy 2019/05/10 7:58 https://www.dajaba88.com/

Spot on with this write-up, I truly think this website needs rather more consideration. I?ll probably be again to read rather more, thanks for that info.

# TgugfjZQQlBdFCsD 2019/05/10 9:06 https://rehrealestate.com/cuanto-valor-tiene-mi-ca

style is awesome, keep doing what you are doing!

# EVTnqwmKvpBEOIFuVVq 2019/05/10 21:48 https://www.ted.com/profiles/13015199

thanks to the author for taking his time on this one.

# xdyBxoNxSiCVuytveRd 2019/05/12 19:25 https://www.ttosite.com/

Thanks a lot for sharing this with all of us you really know what you are talking about! Bookmarked. Kindly also visit my web site =). We could have a link exchange arrangement between us!

# gwRHiKxxfWHa 2019/05/12 22:29 https://www.sftoto.com/

Loving the info on this website , you have done outstanding job on the blog posts.

# jPSAtJonQZZofiUy 2019/05/12 23:11 https://www.mjtoto.com/

It as not that I want to replicate your web-site, but I really like the pattern. Could you let me know which style are you using? Or was it tailor made?

# LIVKfpAgXPjizfePbt 2019/05/13 2:18 https://reelgame.net/

I?d must test with you here. Which isn at one thing I usually do! I enjoy studying a put up that will make people think. Additionally, thanks for permitting me to remark!

# ekvkbXSjMDus 2019/05/13 18:11 https://www.ttosite.com/

Very good blog post. I certainly appreciate this site. Stick with it!

# CTbUIMzpbA 2019/05/14 3:05 http://cgibin1.com/psecure/out.php?d=psychiatry.mc

Valuable information. Lucky me I discovered your web site by chance, and I am stunned why this coincidence did not came about earlier! I bookmarked it.

# IylRbNuLaAzNa 2019/05/14 6:02 http://www.jobref.de/node/2088203

This will be priced at perusing, I like the idea a lot. I am about to take care of your unique satisfied.

# amiQEmoqVOpEurTmWa 2019/05/14 8:08 https://csgrid.org/csg/team_display.php?teamid=161

You can certainly see your skills in the work you write. The sector hopes for more passionate writers such as you who are not afraid to mention how they believe. At all times follow your heart.

# VtFXipiQqzcxSg 2019/05/14 8:54 http://all4webs.com/rootfile22/xgoibqatne890.htm

Perfect piece of work you have done, this website is really cool with great info.

# yUhTIllfXkAoNPJy 2019/05/14 11:02 https://www.idolbin.com/iprofile/74605013670612172

Visit this I was suggested this web site by my cousin. I am not sure whether this post is written by him as no one else know such detailed about my problem. You are wonderful! Thanks!

# gHaCLNnmXEdVpvQYq 2019/05/14 15:15 http://modesto2658fq.metablogs.net/we-are-here-we-

You are able to find visibly a pack to understand about this unique. I truly suppose you created specific excellent components in functions also.

# xGAlgAOKhTB 2019/05/14 17:27 https://www.dajaba88.com/

Really enjoyed this blog.Really looking forward to read more. Great.

# ryYlCsQcQtnXCAS 2019/05/14 18:45 https://trello.com/nodogciza

You ave made some really good points there. I checked on the net for more information about the issue and found most individuals will go along with your views on this web site.

# ZTEvpNjKpxZGoQBFnph 2019/05/14 23:55 http://harmon5861yk.wpfreeblogs.com/companies-dont

pretty handy material, overall I consider this is well worth a bookmark, thanks

# iVrNfcKvaoQqNtrPh 2019/05/15 2:43 http://www.jhansikirani2.com

It as remarkable to go to see this web site and reading the views of all mates concerning this article, while I am also zealous of getting experience. Look at my web page free antivirus download

# DovOEWMXzY 2019/05/15 4:47 https://teleman.in/members/cablepunch6/activity/14

It'а?s in reality a great and helpful piece of information. I am satisfied that you just shared this helpful info with us. Please keep us up to date like this. Thanks for sharing.

# pdzCTwTuJglNIfSX 2019/05/15 6:04 http://www.techytape.com/story/298452/#discuss

Really clear website , thankyou for this post.

# HhUSQoymCNnyCd 2019/05/15 8:47 http://www.hhfranklin.com/index.php?title=User:Alb

This is a excellent blog, would you be involved in doing an interview about just how you designed it? If so e-mail me!

# kkEaLZXEDdBjE 2019/05/15 22:08 https://speakerdeck.com/monsvisubdo

I think this is a real great blog.Really looking forward to read more. Much obliged.

# UvxdSRyYTgB 2019/05/15 22:14 https://telegra.ph/Near-Field-Communication-The-Te

Precisely what I was searching for, thanks for putting up.

# CeDXQsKnDfDFlo 2019/05/15 23:19 https://www.kyraclinicindia.com/

Thanks a lot for the article.Thanks Again.

# KvuOSaaMjciFUxJJS 2019/05/16 20:14 https://reelgame.net/

I truly appreciate this blog article.Really looking forward to read more. Want more.

# BobtawgRjC 2019/05/17 0:18 https://www.mjtoto.com/

Wow! This could be one particular of the most helpful blogs We have ever arrive across on this subject. Basically Great. I am also an expert in this topic so I can understand your effort.

# wGvfukjIRx 2019/05/17 4:57 https://www.youtube.com/watch?v=Q5PZWHf-Uh0

Merely wanna admit that this is very helpful , Thanks for taking your time to write this.

# VRqnHLqipzIQoXH 2019/05/17 17:55 https://www.youtube.com/watch?v=9-d7Un-d7l4

I savor, result in I found exactly what I used to be having a look for. You have ended my four day long hunt! God Bless you man. Have a great day. Bye

# BeRYQiEssc 2019/05/18 4:14 https://www.mtcheat.com/

Major thanks for the blog post.Really looking forward to read more. Keep writing.

# qnsbBNTNSq 2019/05/18 8:01 https://totocenter77.com/

Usually I do not learn article on blogs, however I wish to say that this write-up very pressured me to take a look at and do it! Your writing taste has been surprised me. Thanks, very great article.

# JpXLDnKaAmDAJjrh 2019/05/18 11:49 https://www.dajaba88.com/

Im thankful for the post.Much thanks again. Great.

# LUHiSUAqznRvqooqE 2019/05/18 12:30 https://www.ttosite.com/

This excellent website certainly has all of the information and facts I wanted concerning this subject and didn at know who to ask.

# EAzAwepLvcvtBsy 2019/05/20 16:10 https://nameaire.com

It is in reality a great and useful piece of information. I am satisfied that you simply shared this helpful info with us. Please keep us up to date like this. Thanks for sharing.

# AETuhWcTmd 2019/05/21 2:30 http://www.exclusivemuzic.com/

I value the blog post.Much thanks again. Much obliged.

タイトル  
名前  
Url
コメント