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

推荐订阅源

罗磊的独立博客
大猫的无限游戏
大猫的无限游戏
WordPress大学
WordPress大学
酷 壳 – CoolShell
酷 壳 – CoolShell
T
Tailwind CSS Blog
Engineering at Meta
Engineering at Meta
MongoDB | Blog
MongoDB | Blog
爱范儿
爱范儿
小众软件
小众软件
MyScale Blog
MyScale Blog
美团技术团队
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
S
SegmentFault 最新的问题
G
Google Developers Blog
Stack Overflow Blog
Stack Overflow Blog
V
V2EX
量子位
云风的 BLOG
云风的 BLOG
A
About on SuperTechFans
阮一峰的网络日志
阮一峰的网络日志
Last Week in AI
Last Week in AI
Martin Fowler
Martin Fowler
C
Check Point Blog
月光博客
月光博客

博客园 - 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();
        }
    }
}