代码GC测试
来源:互联网 发布:百度云域名查询 编辑:程序博客网 时间:2024/04/30 08:30
for(int i = 0;i < 10000;i++){
enActorEnum enu = (enActorEnum)1;
}
枚举类型转换 GC 0 Time 0.1public delegate void VoidDelegateString (string str);------------------------------ 分割线 【委托】 ------------------------------ System.Action<string> callback;
void Start(){
callback += cb; // 每次添加一个回调 GC :[104B] Time : [0.03]
callback -= cb; // 每次添加一个回调 GC :[104B] Time : [0.06]
for(int i = 0;i < 10;i++){} callback += cb }callback -= cb; // 添加了10个回调后,移除其中的一个回调 GC :[1.0KB] Time :[0.4]
}
void cb(string str){
}
------------------------------ 分割线 【字典】 ------------------------------void Start(){Dictionary<string, float> dict = new Dictionary<string, float>(); string str = "tempKey"; for(int i = 0;i < 1000;i++){ dict.Add (i.ToString (), i * 1.0f); } Profiler.BeginSample ("dictContains"); dict.ContainsKey ("sdffd"); // 判断是否包含key GC :[0] Time :[0.13] Profiler.EndSample (); Profiler.BeginSample ("dictAdd"); dict.Add (str, 156.0f); // 添加 GC :[0] Time :[0] Profiler.EndSample (); Profiler.BeginSample ("dictGet"); float _value = dict [str]; // 获取值 GC :[0] Time :[0.1] Profiler.EndSample (); Profiler.BeginSample ("dictRemove"); dict.Remove (str); // 移除 GC :[0] Time :[0.18] Profiler.EndSample ();
}
------------------------------ 分割线 【集合】 ------------------------------ ------------------- 类型为枚举时 ------------------- List<enActorEnum> list = new List<enActorEnum> (); for (int i = 0; i < 100000; i++) { list.Add (enActorEnum.enOne); } Profiler.BeginSample ("listContains"); list.Contains (enActorEnum.enOne); // 是否包含key GC :[152B] Time :[0.65] Profiler.EndSample (); Profiler.BeginSample ("listAdd"); list.Add (enActorEnum.enOne); // 添加 GC :[0] Time :[0] Profiler.EndSample (); Profiler.BeginSample ("listGet"); var _value = list [0]; // 获取 GC :[0] Time :[0.04] Profiler.EndSample (); Profiler.BeginSample ("listRemove"); list.Remove (enActorEnum.enOne); // 移除 GC :[40B] Time :[0.28] Profiler.EndSample (); ------------------- 类型为Class ------------------- 不管class类中数据为多少都一样 tempClass tClass = new tempClass (); List<tempClass> list = new List<tempClass> (); for (int i = 0; i < 100000; i++) { list.Add (new tempClass ()); } Profiler.BeginSample ("listContains"); list.Contains (tClass); // 是否包含key GC :[112B] Time :[2.37] Profiler.EndSample (); Profiler.BeginSample ("listAdd"); list.Add (tClass); // 添加 GC :[0] Time :[0] Profiler.EndSample (); Profiler.BeginSample ("listGet"); var _value = list [0]; // 获取 GC :[0] Time :[0.00] Profiler.EndSample (); Profiler.BeginSample ("listRemove"); list.Remove (tClass);// 移除 GC :[40B] Time :[2.45] Profiler.EndSample (); public class tempClass { string name; string xsf; }
0 0
- 代码GC测试
- GC测试
- jvm gc 原理测试
- Java GC性能测试
- kubelet GC代码整理
- JVM TLAB与GC测试
- java中GC测试总结
- 编写GC友好的代码
- 编写GC友好代码(1)
- Serial模式下的GC测试
- javascript 闭包 变量释放GC 测试
- 从jconsole摘出来的GC代码
- 测试代码
- 测试代码
- 代码测试
- 测试代码
- 测试代码
- 测试代码
- 简单谈谈对C++设计模式的理解
- MySQL基本操作
- K8S对node添加label,并根据label筛选节点
- Binary Tree Paths
- Android中画边框线,EditText四周边框线
- 代码GC测试
- git
- [http] HTTP Request Header 请求头
- Windows8下JDK8环境变量 jdk java环境变量
- leetcode题解-380. Insert Delete GetRandom O(1)
- 17.03.01 流程控制
- 基于记忆(Memory-Based)与基于模型(Model-Based)的辨析
- OpenStack(Kilo) + Tenant-OVS-VXLAN(ml2) + Multi-Ext-Net
- tomcat8环境变量配置