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

推荐订阅源

Recent Announcements
Recent Announcements
J
Java Code Geeks
雷峰网
雷峰网
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
腾讯CDC
博客园 - 司徒正美
B
Blog RSS Feed
博客园 - 三生石上(FineUI控件)
I
InfoQ
N
Netflix TechBlog - Medium
L
LangChain Blog
博客园_首页
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
T
Tailwind CSS Blog
MyScale Blog
MyScale Blog
美团技术团队
The Cloudflare Blog
爱范儿
爱范儿
Stack Overflow Blog
Stack Overflow Blog
博客园 - 聂微东
H
Help Net Security
Martin Fowler
Martin Fowler
V
Visual Studio 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();
        }
    }
}