From 506bae27a5894f3a216e3f75d5df327b08abbcf0 Mon Sep 17 00:00:00 2001 From: zhouzj Date: Fri, 12 Mar 2021 15:05:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B5=8B=E8=AF=95=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Yitter.IdGenTest/Program.cs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/Yitter.IdGenTest/Program.cs b/src/Yitter.IdGenTest/Program.cs index 727fa54..d0b9a5c 100644 --- a/src/Yitter.IdGenTest/Program.cs +++ b/src/Yitter.IdGenTest/Program.cs @@ -8,15 +8,19 @@ namespace Yitter.OrgSystem.TestA { class Program { - static int workerCount = 1; - static int genIdCount = 10000; // 计算ID数量 + + // 测试参数 + static int genIdCount = 500000; // 计算ID数量(如果要验证50W效率,请将TopOverCostCount设置为20000或适当增加SeqBitLength) static short method = 1; // 1-漂移算法,2-传统算法 + + static bool single = true; static bool outputLog = true; static IIdGenerator IdGen = null; static IList testList = new List(); static bool checkResult = false; public static int Count = 0; + static int workerCount = 1; static void Main(string[] args) @@ -24,7 +28,7 @@ namespace Yitter.OrgSystem.TestA while (true) { Go(); - Thread.Sleep(5000); + Thread.Sleep(3000); // 每隔3秒执行一次Go Console.WriteLine("Hello World!"); } } @@ -37,20 +41,21 @@ namespace Yitter.OrgSystem.TestA var newConfig = new IdGeneratorOptions() { Method = method, - StartTime = DateTime.Now.AddYears(-1), + WorkerId = 1, - //TopOverCostCount = 1000, - WorkerIdBitLength = 6, - SeqBitLength = 6, + TopOverCostCount = 20000, + //WorkerIdBitLength = 6, + //SeqBitLength = 6, //MinSeqNumber = 11, //MaxSeqNumber = 200, + + //StartTime = DateTime.Now.AddYears(-1), }; // ++++++++++++++++++++++++++++++++ if (single) { - newConfig.WorkerId = 1; IdGeneratorOptions options1 = (newConfig); if (IdGen == null) {