1
0
mirror of synced 2026-04-20 07:18:40 +08:00

auto commit

This commit is contained in:
yitter
2022-07-15 16:24:30 +08:00
parent 34cff2eab8
commit cce7a65384
6 changed files with 88 additions and 43 deletions

View File

@@ -12,7 +12,7 @@ namespace Yitter.OrgSystem.TestA
class Program
{
// 测试参数默认配置下最佳性能是10W/s
static int genIdCount = 2;//5000; // 计算ID数量如果要验证50W效率请将TopOverCostCount设置为20000或适当增加SeqBitLength
static int genIdCount = 500000;//5000; // 计算ID数量如果要验证50W效率请将TopOverCostCount设置为2000或适当增加SeqBitLength
static short method = 1; // 1-漂移算法2-传统算法
@@ -27,6 +27,9 @@ namespace Yitter.OrgSystem.TestA
static void Main(string[] args)
{
RunSingle();
return;
Console.WriteLine("Hello World! C#");
var options = new IdGeneratorOptions()
@@ -130,16 +133,42 @@ namespace Yitter.OrgSystem.TestA
private static void RunSingle()
{
DateTime start = DateTime.Now;
for (int i = 0; i < genIdCount; i++)
var options = new IdGeneratorOptions()
{
var id = IdGen.NewLong();
}
Method = 1,
WorkerId = 1,
DateTime end = DateTime.Now;
Console.WriteLine($"++++++++++++++++++++++++++++++++++++++++, total: {(end - start).TotalMilliseconds} ms");
Interlocked.Increment(ref Program.Count);
//WorkerIdBitLength = 6,
SeqBitLength = 6,
//DataCenterIdBitLength = 0,
//TopOverCostCount = 2000,
//TimestampType = 1,
// MinSeqNumber = 1,
// MaxSeqNumber = 200,
// BaseTime = DateTime.Now.AddYears(-10),
};
//IdGen = new DefaultIdGenerator(options);
YitIdHelper.SetIdGenerator(options);
while (true)
{
DateTime start = DateTime.Now;
for (int i = 0; i < genIdCount; i++)
{
//var id = IdGen.NewLong();
var id = YitIdHelper.NextId();
}
DateTime end = DateTime.Now;
Console.WriteLine($"++++++++++++++++++++++++++++++++++++++++, total: {(end - start).TotalMilliseconds} ms");
Thread.Sleep(1000);
}
//Interlocked.Increment(ref Program.Count);
}
private static void Go(IdGeneratorOptions options)