static void RepeatFuc() { var i = 0; while (i < 10000) { var sid = IdBuilder.GetInstance().CreateId(); if (idSet.Contains(sid)) { Console.WriteLine("发现有重复项"); } idSet.Add(sid); Console.Write(Thread.CurrentThread.ManagedThreadId); i++; } Console.WriteLine(i); }
static void QPSTest() { Stopwatch sw = new Stopwatch(); sw.Start(); var i = 0; while (i < 1000000) { IdBuilder.GetInstance().CreateId(); i++; } sw.Stop(); var time = sw.ElapsedMilliseconds; Console.WriteLine("100万耗时" + time + "毫秒"); var qps = (1000000 * 1000) / time; Console.WriteLine("QPS=" + qps + "个/秒"); }
//static ConcurrentQueue<long> idSet = new ConcurrentQueue<long>(); static void Main(string[] args) { Logger logger = new Logger("测试"); try { File.Open("", FileMode.Open); } catch (Exception ex) { Logger.Default.Error("sdfssdf", ex); } // QPSTest();//344.8w/s //TestRepeat();//并没发现 var ss = IdBuilder.GetInstance().CreateId(); Console.ReadLine(); }