惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
DataBreaches.Net
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
云风的 BLOG
云风的 BLOG
B
Blog
博客园 - Franky
I
InfoQ
A
About on SuperTechFans
博客园_首页
L
LangChain Blog
量子位
腾讯CDC
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
美团技术团队
V
V2EX
Apple Machine Learning Research
Apple Machine Learning Research
雷峰网
雷峰网
MongoDB | Blog
MongoDB | Blog
Microsoft Azure Blog
Microsoft Azure Blog
月光博客
月光博客
T
The Blog of Author Tim Ferriss
P
Proofpoint News Feed
G
Google Developers Blog
Last Week in AI
Last Week in AI

博客园 - N/A2011

Managing Hierarchical Data in MySQL php soapclient with wsse 转贴 MySQL Multiple Result Procs in PHP 转贴 jQuery Datepicker by Example 转贴 Using MySQL Stored Procedures with PHP mysql/mysqli/pdo php generate pdf open office (java) ant + emma + junit Copy all files recursively from one folder to another RecursiveFileFinder 转贴: 怎样找第一份工作 Trace in .net Logger in .net 转贴: 傅立叶级数(Fourier Series) 推导 CAS in .net Encrypting and Decrypting in .net Access Control List in .net User and Data Security in .net Unmanaged code in .net
PerformanceCounter in .net
N/A2011 · 2009-06-22 · via 博客园 - N/A2011

VB.NET:

Imports System.Diagnostics
Imports System.TimersModule Module1
    
Private HeapCounter As PerformanceCounter = Nothing
    
Private ExceptionCounter As PerformanceCounter = Nothing
    
Private timer As Timer = New Timer(3000)Private Sub OnTick(ByVal source As ObjectByVal e As ElapsedEventArgs)End SubSub Main()
        
AddHandler timer.Elapsed, AddressOf OnTick
        timer.Enabled 
= True
        
Dim HeapCounter As New PerformanceCounter(".NET CLR Memory""# Bytes in all Heaps")
        HeapCounter.InstanceName 
= "_Global_"
        
Dim ExceptionCounter As New PerformanceCounter(".Net CLR Exceptions""# of Exceps Thrown")
        ExceptionCounter.InstanceName 
= "_Global_"
        Console.WriteLine(
"Press [Enter] to Quit Program")
        Console.WriteLine(
"# of Bytes in all Heaps : " + HeapCounter.NextValue().ToString())
        Console.WriteLine(
"# of Exceptions Thrown: " + ExceptionCounter.NextValue().ToString())
        Console.ReadLine()
    
End SubEnd Module

C#:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Timers;namespace PerformanceCounterCS
{
    
class Program
    {
        
private static PerformanceCounter HeapCounter = null;
        
private static PerformanceCounter ExceptionCounter = null;
        
private static Timer timer = new Timer(3000);private static void OnTick(object source, ElapsedEventArgs e)
        {
        }
static void Main(string[] args)
        {
            timer.Elapsed 
+= new ElapsedEventHandler(OnTick);
            timer.Enabled 
= true;
            HeapCounter 
= new PerformanceCounter(".NET CLR Memory""# Bytes in all Heaps");
            HeapCounter.InstanceName 
= "_Global_";
            ExceptionCounter 
= new PerformanceCounter(".Net CLR Exceptions""# of Exceps Thrown");
            ExceptionCounter.InstanceName 
= "_Global_";
            Console.WriteLine(
"Press [Enter] to Quit Program");
            Console.WriteLine(
"# of Bytes in all Heaps : " + HeapCounter.NextValue().ToString());
            Console.WriteLine(
"# of Exceptions Thrown: " + ExceptionCounter.NextValue().ToString());
            Console.ReadLine();
        }
    }
}