2013年6月6日

C#中测量消耗的内存和时间的方法

摘要: 1、内存var start = GC.GetTotalMemory(true); // todo:待测量的操作GC.Collect(); GC.WaitForFullGCComplete(); var end = GC.GetTotalMemory(true); var useMemory = end - start;2、时间var watch = new Stopwatch(); watch.Start(); // todo:待测量的操作watch.Stop(); var useTime = watch.ElapsedMilliseconds; 阅读全文

posted @ 2013-06-06 08:42 yao2yao4 阅读(577) 评论(0) 推荐(0) 编辑

log4net和log2console的配置

摘要: 1、使用ILog对象记录日志var log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);log.Warn("error", new Exception("异常!"));前提:1)引用log4net.dll2)命名空间前加:[assembly: log4net.Config.XmlConfigurator(Watch = true)]3)App.config的configuration节点下的第一个节点必须为configSection,为:<configSec 阅读全文

posted @ 2013-06-06 07:30 yao2yao4 阅读(1280) 评论(0) 推荐(0) 编辑

导航