Browse Source

auto commit

tags/v1.2
yitter 4 years ago
parent
commit
aa41703ff6
2 changed files with 6 additions and 11 deletions
  1. +3
    -5
      Java/source/src/main/java/com/github/yitter/test/GenTest.java
  2. +3
    -6
      Java/source/src/main/java/com/github/yitter/test/StartUp.java

+ 3
- 5
Java/source/src/main/java/com/github/yitter/test/GenTest.java View File

@@ -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();


+ 3
- 6
Java/source/src/main/java/com/github/yitter/test/StartUp.java View File

@@ -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


Loading…
Cancel
Save