C#性能测试垃圾回收与运行时间帮助
来源:互联网 发布:java 数据类型 赋值 编辑:程序博客网 时间:2024/04/28 05:29
internal sealed class OperationTimer : IDisposable
{
private Stopwatch m_stopwatch;
private string m_text;
private int m_collectionCount;
public OperationTimer(string text)
{
PrepareForOperation();
m_text = text;
m_collectionCount = GC.CollectionCount(0);
m_stopwatch = Stopwatch.StartNew();
}
public void Dispose()
{
Console.WriteLine("{0}详情", m_text);
int f = GC.CollectionCount(0) - m_collectionCount;
Console.WriteLine("垃圾回收次数:" + f);
Console.WriteLine("所用的时间:" + m_stopwatch.Elapsed);
}
private static void PrepareForOperation()
{
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
}
}
{
private Stopwatch m_stopwatch;
private string m_text;
private int m_collectionCount;
public OperationTimer(string text)
{
PrepareForOperation();
m_text = text;
m_collectionCount = GC.CollectionCount(0);
m_stopwatch = Stopwatch.StartNew();
}
public void Dispose()
{
Console.WriteLine("{0}详情", m_text);
int f = GC.CollectionCount(0) - m_collectionCount;
Console.WriteLine("垃圾回收次数:" + f);
Console.WriteLine("所用的时间:" + m_stopwatch.Elapsed);
}
private static void PrepareForOperation()
{
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
}
}
阅读全文
0 0
- C#性能测试垃圾回收与运行时间帮助
- jvm垃圾回收性能测试
- 垃圾回收器基础与性能提示
- JVM垃圾回收与性能调优
- JVM垃圾回收与性能调优
- JVM垃圾回收与性能调优
- Java与C#的垃圾回收机制
- Java与C#的垃圾回收机制
- Java与C#的垃圾回收机制
- Java与C#的垃圾回收机制
- C#垃圾回收与内存管理【转】
- Java与C#的垃圾回收机制
- Java与C#的垃圾回收机制
- C#内存管理与垃圾回收
- Java与C#的垃圾回收机制
- C#中测试程序运行时间的【诊断与测试】
- 测试垃圾回收次数
- C#垃圾回收
- 为什么梯度的方向与等高线切线方向垂直?
- 算法第二节:逆推法解决“银行存款"问题
- MySQL 中Blob类型数据的插入和读取
- 搭建多节点的私链的时候遇到一些困难
- jQuery五星好评界面反馈界面
- C#性能测试垃圾回收与运行时间帮助
- IOS
- oracle数据库拼接sql语句字符串问题
- Weex中Web端做SPA,Native端做多页应用以及Vuex的接入
- 阿里巴巴开源连接池详解
- android仿ios菊花LoadingView
- 掌握bandicam以及KMPlayer
- <PLOS One>Old papers
- iOS开源项目收集整理