主婦と.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.

# MBzAyodqvsDCZvznmZ 2014/08/07 21:33 http://best-ppc-networks.com

I appreciate you sharing this article. Great.

# KFQtPdZGJsvYz 2014/08/08 2:18 http://www.katieknipp.com/

This is one awesome post.Thanks Again. Fantastic.

# gdlNcFTMeT 2014/08/08 15:17 http://jobcentreonline.info

Thanks again for the blog post.Thanks Again. Keep writing.

# KiXsxicNkwGF 2014/08/08 17:45 http://www.minuteflyer.com

I truly appreciate this article post.Thanks Again. Keep writing.

# PdZrnzCRcKmMnfCULA 2014/08/08 18:12 https://www.linkedin.com/company/law-offices-of-je

Really informative blog.Thanks Again. Will read on...

# UrzmeFPJYJbQGdXV 2014/08/08 21:35 http://www.deoscloset.com/blog/children-toys/build

I value the blog.Much thanks again. Want more.

# ShmFZUDAGUVKjDbA 2014/08/08 22:04 https://www.youtube.com/watch?v=JhPsdVP99cM

Very informative post.Really looking forward to read more. Will read on...

# NqLshJUJgfm 2014/08/09 1:19 http://www.etsy.com/shop/TheGlossedAndFound

This is one awesome blog post.Thanks Again. Awesome.

# uAKbEVHTfD 2014/08/09 4:17 http://www.kontakt-keramika.ru/forum/index.php?act

Thanks a lot for the article post.Thanks Again. Want more.

# ZMQrGKlMqBiGIAGrvV 2014/08/09 5:43 http://anegdotebi.mcvane.ge/user/decacyyyauygna/

Very neat blog.Really looking forward to read more. Really Great.

# tBVZReEtuhbpHpTg 2014/08/09 8:26 http://armedviolence.info/story/81536

Major thanks for the blog post.Much thanks again. Awesome.

# CUkHjbNATVynjyfMNra 2014/08/09 14:24 http://www.railfan.ne.jp/userinfo.php?uid=327650

Major thankies for the blog. Awesome.

# GqjraLgxUIFb 2014/08/11 14:33 http://www.walktc.com/

Fantastic blog article.

# kORIJmuDpP 2014/08/11 16:29 http://pr9-trusted-backlink.blogspot.in/

Im obliged for the blog post.Really looking forward to read more. Keep writing.

# xIqjptXjPzxew 2014/08/11 18:25 http://hiu-net.com/

Great article.Much thanks again. Will read on...

# rZYEKSiVWmsJOkjrJ 2014/08/11 20:22 http://bitcoininvestmentguide.info

Really appreciate you sharing this article.Thanks Again. Fantastic.

# CpHUtLYSPfYumh 2014/08/11 21:46 http://www.kutsenko.ru/forum/index.php?showuser=43

Looking forward to reading more. Great blog article.Thanks Again. Keep writing.

# hIawbURSCDnfVnsehEj 2014/08/11 22:39 http://gaigoi2014.info

I really enjoy the article post.Really looking forward to read more. Really Great.

# GyIcoAEKlTgP 2014/08/12 5:18 http://bitcoininvestmentguide.info

Appreciate you sharing, great blog.Much thanks again. Fantastic.

# sDBzbZuPFAgY 2014/08/12 17:59 http://porschelynn.info/story/72015

Awesome blog article.Really looking forward to read more. Want more.

# IWxBQhGtkewwdRWzQ 2014/08/13 3:05 http://hiu-net.com/

Im grateful for the article post.Thanks Again. Want more.

# rrxOBwOqxfhwvDWtjG 2014/08/13 18:04 http://www.myhpmini.com/forum/member.php/489680-ye

This is one awesome blog article. Really Great.

# CaldQaSTWpuBsSvmkVb 2014/08/14 1:25 https://www.youtube.com/watch?v=HGWnEX07bG0

Very good blog post.Much thanks again. Keep writing.

# bvGPdQXgvRYdNQMX 2014/08/14 6:05 http://new.pitchengine.com/pitches/9153e4ea-b94c-4

wow, awesome blog article.Thanks Again. Fantastic.

# KOpXoYRTTXf 2014/08/14 16:25 http://youtu.be/hBlM7joTXVc

I appreciate you sharing this article.Really looking forward to read more. Will read on...

# ImsmziLnbRO 2014/08/14 16:29 http://www.propertyblogshop.com

Really informative article post.Really looking forward to read more. Awesome.

# shwohlQsdxEfzcnh 2014/08/14 19:37 http://offredemploi.co/category/pole-emploie/

Major thanks for the blog.Really looking forward to read more. Great.

# vivNGicCEPQeDNvSVP 2014/08/15 14:06 http://bitcoininvestmentguide.info

Hey, thanks for the article.Much thanks again. Great.

# oAgOIJMkabBGmKed 2014/08/15 15:32 http://www.annuityratesnow.com

Looking forward to reading more. Great blog post.Much thanks again. Keep writing.

# DSvKBhAqZAhwlWMOhtv 2014/08/15 17:58 http://studylib.com/index.php?subaction=userinfo&a

Thanks-a-mundo for the post.Really looking forward to read more. Really Great.

# BDbmdcCvoHCDUpgIt 2014/08/17 0:01 http://www.cometohack.com/

Major thanks for the post.Really looking forward to read more. Awesome.

# okDqwVMNiDxRltPWPlS 2014/08/17 9:43 http://hugemo.asia

I truly appreciate this article.Thanks Again. Much obliged.

# vnZywOkTBm 2014/08/18 4:09 http://www.firstclassdallas.com/Dallas-Restaurants

I really like and appreciate your article. Fantastic.

# ntqTSwszMKIOamqLUka 2014/08/18 21:47 http://forum.pocketz.ru/index.php?s=51526c753465e7

Awesome post.Really looking forward to read more. Will read on...

# pPxNirUpleLVgWGxZDO 2014/08/19 0:32 http://scurtpedoi.info/story/75542

I really enjoy the article post.Thanks Again. Keep writing.

# ENpzGmEDUHZGNTKfP 2014/08/19 1:43 http://www.youtube.com/watch?v=0RIERFqixGM

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

# TMCqjZeTrwOqe 2014/08/19 9:07 http://www.theboatonlinestore.com/

Very informative article post. Will read on...

# vVkNmYhCDzb 2014/08/19 12:24 http://youtu.be/vUaF914XFDQ

Thanks-a-mundo for the article post.Thanks Again. Really Great.

# zsBGGUuPyNPHnsupWo 2014/08/19 17:16 http://www.alesandra.lt/drabuziai/chalatai/

Wow, great blog article.Really looking forward to read more.

# WtotHUWhHPyxRPtabBB 2014/08/19 19:36 http://maminportal.ru/user/roboerpriaogng/

Wow, great blog.Really looking forward to read more. Will read on...

# LpSJZFAVaeHYnWAda 2014/08/19 20:44 http://mynetnuggets.wordpress.com/

Very neat blog post. Great.

# ukeQHUvqIrYoxAD 2014/08/20 17:25 http://www.bsml.org/green-smoke-review

This is one awesome blog post. Keep writing.

# ZkcvgoXYduWy 2014/08/21 17:21 http://vip-statusi.ru/user/rycccouneungry/

Very neat blog.Really looking forward to read more. Really Great.

# hJHBZMSclpULHzMWhd 2014/08/21 20:08 http://mark-twain.ru/user/yreoguyoodoeau/

Major thanks for the blog.Really looking forward to read more. Awesome.

# rnqGXkIMZTwEqIqViiy 2014/08/21 21:07 http://www.irectify.co.uk/

This is one awesome blog.Thanks Again. Much obliged.

# yyKbzzICegYmGghRh 2014/08/21 23:56 http://www.optimaxruinedmylife.com/

Really appreciate you sharing this blog article.Much thanks again. Fantastic.

# wSZnOWZHlSYgyADyT 2014/08/22 4:18 http://www.villaforsale-spain.com/

I appreciate you sharing this blog.Much thanks again. Really Great.

# HVqIkhnnxIhbKSBGq 2014/08/23 1:45 http://tupaya.info/user/reydppinerbuuc/

Great article post.Thanks Again. Will read on...

# meNpxzZKYCvllFz 2014/08/23 3:07 http://infocbs.mirniy.ru/user/drpdnocageooba/

Thanks again for the post.Thanks Again. Will read on...

# CIYxrYLBuuRY 2014/08/24 17:14 http://httpicesculpt.info/story.php?id=18816

Great, thanks for sharing this blog post. Keep writing.

# tVhnXWfgpnH 2014/08/25 21:14 http://blog.filmentiergratuit.fr/

Appreciate you sharing, great article.Thanks Again. Great.

# gQMraQoSPZkKZJ 2014/08/25 22:55 http://huntinafrica.co.za

Thanks so much for the post.Really looking forward to read more. Will read on...

# bIFDxJXcYAvlA 2014/08/25 23:10 http://filmentiergratuit.fr/

Hey, thanks for the article.Really looking forward to read more. Much obliged.

# NVjKJJxjZgUsRwrxvEQ 2014/08/26 2:28 https://www.leafit.biz/pocky

Hey, thanks for the article post.Really looking forward to read more. Want more.

# FwQQYnaKlsEeJmYUzj 2014/08/26 4:15 http://mylastright.com

Im grateful for the post.Really looking forward to read more. Fantastic.

# HbqxxxROqEoxrFYXE 2014/08/26 6:04 http://youtu.be/BF04dt8vfeA

Muchos Gracias for your post.Really looking forward to read more. Awesome.

# lTlXOuEuxpG 2014/08/26 8:24 http://podle.pl/

I appreciate you sharing this article post.Thanks Again. Great.

# eEtMlDiattLyMmiQp 2014/08/26 8:51 http://ecommerce-for-business.com/

Thanks again for the article.Thanks Again. Great.

# RlzfAgjAVFx 2014/08/26 9:09 http://www.theboatonlinestore.co.uk/

I really enjoy the blog article.Really looking forward to read more. Great.

# PpAqJdMKsevrtGRXKJW 2014/08/26 10:36 http://www.theboatonlinestore.com/

Wow, great blog post.

# ZZeySqBLFASoELH 2014/08/26 13:32 http://gigaarcade.com/category/action/

I really like and appreciate your article.Really looking forward to read more. Fantastic.

# FQZtbruwlYMgEpBT 2014/08/27 1:51 http://www.kutsenko.ru/forum/index.php?showuser=43

wow, awesome blog post.Really looking forward to read more. Fantastic.

# mNJFfGtsuAbLT 2014/08/27 3:15 http://www.myfilmebi.net/user/ebddaparpribbd/

Wow, great blog article.Much thanks again. Awesome.

# SMPsdGjmQs 2014/08/27 4:45 https://www.indiegogo.com/projects/zipibyte-africa

A round of applause for your article.Thanks Again. Want more.

# tWrVggzkZVLGsO 2014/08/27 6:12 http://pravoslavie.kharkov.ua/user/cncrdburbbdgyy/

Thanks again for the blog post.Really looking forward to read more.

# fMKjfoMUGCJbmqB 2014/08/27 17:46 http://munservis.mirniy.ru/user/epearobanpraoe/

Thanks so much for the blog. Much obliged.

# xZearNWRExp 2014/08/27 19:10 http://cuyutupaarts.info/story.php?id=20471

Appreciate you sharing, great blog post.Much thanks again. Fantastic.

# PWYiZoeyhAtjd 2014/08/27 20:34 http://avto-new.info/user/oacueunungpbun/

Thanks so much for the blog post.Much thanks again.

# VJSpIPQRkvARGYFqq 2014/08/28 18:22 http://www.kutsenko.ru/forum/index.php?showuser=43

Great blog article.Thanks Again.

# LJiIbMWRmkLedNZgbp 2014/08/28 19:47 http://fondartema.com/index/8-6902

Wow, great post.

# PClHjYWRAynzdwQd 2014/08/28 21:14 http://kalinkovichi-s3.iwl.by/user/viogetaxRaigey0

Im thankful for the article post.Thanks Again. Will read on...

# LJkuDCwcnzvrUud 2014/08/29 2:48 http://www.ostaz.ru/user/uipiiydybanpeo/

wow, awesome post.Much thanks again. Awesome.

# WIagclmjpZtpKIqA 2014/08/29 17:23 http://combinedlocksmiths.info/story/29779

Looking forward to reading more. Great blog.

# HWxoBsBZTEGYEdZ 2014/08/29 18:50 http://akabunga.ru/user/KayalpFlashr4g/

I appreciate you sharing this article post.Thanks Again. Great.

# NJnDOUVvJrVWLppvg 2014/08/30 6:15 http://www.geomovie.ge/user/Pripinkpoonry866/

wow, awesome article post.Thanks Again.

# hMalKGhcDgSTHzHCgp 2014/08/30 9:08 http://apkvvc.ru/user/ogororogninndi/

Looking forward to reading more. Great post.Really looking forward to read more.

# PakzvujTaFBEUT 2014/08/30 10:33 http://baghdadee.ipbhost.com/index.php?showuser=34

I truly appreciate this article post.Much thanks again. Will read on...

# HTspRlikiWKNtT 2014/08/30 19:11 http://mir-soft.ru/user/geraebrdrbnygd/

Really appreciate you sharing this article.Thanks Again. Keep writing.

# OvwMzMxgWst 2014/08/30 20:35 http://ava-pskov.ru/index.php?subaction=userinfo&a

Im grateful for the blog.

# iiUFjpoSnjgpdtEZ 2014/08/30 20:54 http://www.freedil.com/stores

Great, thanks for sharing this post. Keep writing.

# WVZqfWYYkuCrXNtLgzd 2014/08/30 22:01 http://pravoslavie.kharkov.ua/user/ycygnbgrbbcnin/

Really appreciate you sharing this blog post.Thanks Again. Fantastic.

# gTAXdPqkXc 2014/08/31 3:48 http://217.77.49.145/index.php?subaction=userinfo&

Thanks a lot for the blog.Thanks Again. Great.

# lzphUjIzCWv 2014/09/01 22:33 http://acmilan.ge/index.php?subaction=userinfo&

I appreciate you sharing this post.Much thanks again.

# Iss online 2014/09/03 6:53 Michaeloa

crorkservice, I see you know the meaning of literate comments ... :))
for example, there is (http://mksonline.ucoz.ru/)

# PYoxDpolYBJzVT 2014/09/03 13:20 http://anycitysportsfan.com/members/aquinaseditha/

I've learn some excellent stuff here. Certainly worth bookmarking for revisiting. I wonder how a lot attempt you set to create such a magnificent informative website.

# apSGsNyCpvJC 2014/09/09 15:18 http://musiccomposingsoftware.org.

Hello my friend! I want to say that this post is amazing, great written and include almost all significant infos. I'd like to peer extra posts like this .

# 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.

# FHBGWtLaGvqjih 2014/09/09 21:01 http://www.3dseriousgames.com

Thanks again for the article.Thanks Again. Want more.

タイトル  
名前  
Url
コメント