Unity3D 简易计时类
来源:互联网 发布:淘宝卖家蚂蚁花呗支付 编辑:程序博客网 时间:2024/05/17 05:16
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
/// <summary>
/// /// 简易的计时类
/// /// </summary>
public class YiWatch : IDisposable
{
#region 字段
private string testName;
private int testCount;
private Stopwatch watch;
#endregion
#region 构造函数
public YiWatch(string name, int count)
{
this.testName = name; this.testCount = count > 0 ? count : 1;
this.watch = Stopwatch.StartNew();
}
#endregion
#region 方法
public void Dispose()
{
this.watch.Stop();
float totalTime = this.watch.ElapsedMilliseconds;
UnityEngine.Debug.Log(string.Format("测试名称:{0} 总耗时:{1} 单次耗时:{2} 测试数量:{3}", this.testName, totalTime, totalTime / this.testCount, this.testCount));
}
#endregion
}
/*
*使用方式
*/
//int testCount = 1000000;
////定义测试的次数
//using (new YiWatch("GetComponent<>", testCount))
//{
// for(int i = 0; i < testCount; i++)
// {
// GetComponent<TestComp>();
// }
//}
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
/// <summary>
/// /// 简易的计时类
/// /// </summary>
public class YiWatch : IDisposable
{
#region 字段
private string testName;
private int testCount;
private Stopwatch watch;
#endregion
#region 构造函数
public YiWatch(string name, int count)
{
this.testName = name; this.testCount = count > 0 ? count : 1;
this.watch = Stopwatch.StartNew();
}
#endregion
#region 方法
public void Dispose()
{
this.watch.Stop();
float totalTime = this.watch.ElapsedMilliseconds;
UnityEngine.Debug.Log(string.Format("测试名称:{0} 总耗时:{1} 单次耗时:{2} 测试数量:{3}", this.testName, totalTime, totalTime / this.testCount, this.testCount));
}
#endregion
}
/*
*使用方式
*/
//int testCount = 1000000;
////定义测试的次数
//using (new YiWatch("GetComponent<>", testCount))
//{
// for(int i = 0; i < testCount; i++)
// {
// GetComponent<TestComp>();
// }
//}
阅读全文
0 0
- Unity3D 简易计时类
- Unity3D 计时/倒计时管理类
- Unity3D脚本:C#计时类脚本
- 【Unity3d】设计自己的计时类
- 简易计时窗口程序
- 计时类
- unity3d EZGUI简易教程
- Unity3d协程实现倒数计时
- 【Unity3D编程】简易时钟制作
- Unity3D Editor 编辑器简易教程
- Unity3D Editor 编辑器简易教程
- Unity3D Editor 编辑器简易教程
- 倒数计时类
- C#精确计时类
- C#中的计时类
- C++ 计时类
- as3计时工具类
- 精准的计时类
- 通过fcntl设置 非阻塞IO(Linux C)
- 利用Android的api获取经纬度的方法
- 过滤beanutils包的AbstractConverter类的DEBUG信息
- [Android]Android Studio获取开发版和发布版的MD5和SHA1
- ajax请求成功后无法在success方法里给外部变量赋值的问题
- Unity3D 简易计时类
- CloudStack到底和OpenStack区别
- 通过梦网科技平台接口实现网页验证码校验功能
- 配置 logstash 为 Windows Service
- dbus-glib应用入门
- Linux 守护进程 详解
- [1] Spring中的Bean实例化的三种方式
- CPU-bound(计算密集型) 和I/O-bound(I/O密集型)
- java中关于时间日期操作的常用函数