From aa41703ff60fe4f455332e5f1b798d6832369485 Mon Sep 17 00:00:00 2001 From: yitter Date: Tue, 13 Apr 2021 11:31:49 +0800 Subject: [PATCH] auto commit --- Java/source/src/main/java/com/github/yitter/test/GenTest.java | 8 +++----- Java/source/src/main/java/com/github/yitter/test/StartUp.java | 9 +++------ 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/Java/source/src/main/java/com/github/yitter/test/GenTest.java b/Java/source/src/main/java/com/github/yitter/test/GenTest.java index e0589e5..09430a4 100644 --- a/Java/source/src/main/java/com/github/yitter/test/GenTest.java +++ b/Java/source/src/main/java/com/github/yitter/test/GenTest.java @@ -1,20 +1,19 @@ package com.github.yitter.test; import com.github.yitter.contract.IIdGenerator; +import com.github.yitter.idgen.YitIdHelper; import java.util.HashSet; import java.util.Set; public class GenTest { - private IIdGenerator IdGen; private int GenIdCount; private int WorkerId; private Set IdSet = new HashSet(); - public GenTest(IIdGenerator idGen, int genIdCount, int workerId) { + public GenTest(int genIdCount, int workerId) { GenIdCount = genIdCount; - IdGen = idGen; WorkerId = workerId; } @@ -23,8 +22,7 @@ public class GenTest { long id = 0; for (int i = 0; i < GenIdCount; i++) { - id = IdGen.newLong(); - // IdSet.add(id); + id = YitIdHelper.nextId(); } long end = System.currentTimeMillis(); diff --git a/Java/source/src/main/java/com/github/yitter/test/StartUp.java b/Java/source/src/main/java/com/github/yitter/test/StartUp.java index be161b0..0efe532 100644 --- a/Java/source/src/main/java/com/github/yitter/test/StartUp.java +++ b/Java/source/src/main/java/com/github/yitter/test/StartUp.java @@ -25,16 +25,12 @@ public class StartUp { // options.WorkerIdBitLength = 6; // options.SeqBitLength = 6; // options.TopOverCostCount = 2000; - // options.MinSeqNumber = 5; - // options.MaxSeqNumber = 200; - +// options.MinSeqNumber = 5; +// options.MaxSeqNumber = 200; options.Method = method; options.BaseTime = 1582206693000L; options.WorkerId = 1; - IIdGenerator idGen = new DefaultIdGenerator(options); - GenTest genTest = new GenTest(idGen, genIdCount, options.WorkerId); - // 首先测试一下 IdHelper 方法,获取单个Id YitIdHelper.setIdGenerator(options); long newId = YitIdHelper.nextId(); @@ -43,6 +39,7 @@ public class StartUp { // 然后循环测试一下,看看并发请求时的耗时情况 try { + GenTest genTest = new GenTest(genIdCount, options.WorkerId); while (true) { genTest.GenStart(); Thread.sleep(1000); // 每隔1秒执行一次GenStart