1
0
mirror of synced 2025-12-17 02:28:12 +08:00

限定TopOverCostCount范围

This commit is contained in:
yitter
2022-07-16 00:42:36 +08:00
parent 519206cdbf
commit b1b3d0cd6d
12 changed files with 165 additions and 84 deletions

View File

@@ -12,7 +12,7 @@ namespace Yitter.OrgSystem.TestA
class Program
{
// 测试参数默认配置下最佳性能是10W/s
static int genIdCount = 500000;//5000; // 计算ID数量如果要验证50W效率请将TopOverCostCount设置为2000或适当增加SeqBitLength
static int genIdCount = 50000;//5000; // 计算ID数量如果要验证50W效率请将TopOverCostCount设置为2000或适当增加SeqBitLength
static short method = 1; // 1-漂移算法2-传统算法
@@ -39,7 +39,7 @@ namespace Yitter.OrgSystem.TestA
WorkerIdBitLength = 6,
SeqBitLength = 6,
DataCenterIdBitLength = 10,
DataCenterIdBitLength = 0,
TopOverCostCount = 2000,
//TimestampType = 1,
@@ -142,8 +142,8 @@ namespace Yitter.OrgSystem.TestA
//WorkerIdBitLength = 6,
SeqBitLength = 6,
//DataCenterIdBitLength = 0,
//TopOverCostCount = 2000,
//DataCenterIdBitLength = 0,
//TimestampType = 1,
// MinSeqNumber = 1,

View File

@@ -63,7 +63,6 @@ namespace Yitter.IdGenerator
/// </summary>
public virtual int TopOverCostCount { get; set; } = 2000;
/// <summary>
/// 数据中心ID默认0
/// </summary>

View File

@@ -118,10 +118,10 @@ namespace Yitter.IdGenerator
// 7.Others
TopOverCostCount = options.TopOverCostCount;
if (TopOverCostCount == 0)
{
TopOverCostCount = 2000;
}
//if (TopOverCostCount == 0)
//{
// TopOverCostCount = 2000;
//}
_TimestampShift = (byte)(WorkerIdBitLength + SeqBitLength);
_CurrentSeqNumber = options.MinSeqNumber;

View File

@@ -92,6 +92,12 @@ namespace Yitter.IdGenerator
throw new ApplicationException("MinSeqNumber error. (range:[5, " + maxSeqNumber + "]");
}
// 7.TopOverCostCount
if (options.TopOverCostCount < 0 || options.TopOverCostCount > 10000)
{
throw new ApplicationException("TopOverCostCount error. (range:[0, 10000]");
}
switch (options.Method)
{
case 2: