Skip to content

Commit

Permalink
Speed up the generation of timestamp random increasing (#374)
Browse files Browse the repository at this point in the history
  • Loading branch information
liyuheng55555 authored Sep 25, 2023
1 parent 68d3971 commit 3d60fe0
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;

public abstract class GenerateDataWorkLoad extends DataWorkLoad {

Expand All @@ -43,7 +44,6 @@ public abstract class GenerateDataWorkLoad extends DataWorkLoad {
private static final PoissonDistribution poissonDistribution =
new PoissonDistribution(poissonRandom);
private static final Random dataRandom = new Random(config.getDATA_SEED());
private static final Random timestampRandom = new Random(config.getDATA_SEED());
private static final String CHAR_TABLE =
"1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
private static final long timeStampConst =
Expand Down Expand Up @@ -109,7 +109,7 @@ protected long getCurrentTimestamp(long stepOffset) throws WorkloadException {
timestamp += config.getPOINT_STEP();
} else {
// data is not in regular frequency, then use random
timestamp += config.getPOINT_STEP() * timestampRandom.nextDouble();
timestamp += config.getPOINT_STEP() * ThreadLocalRandom.current().nextDouble();
}
long currentTimestamp = Constants.START_TIMESTAMP * timeStampConst + offset + timestamp;
if (config.isIS_RECENT_QUERY()) {
Expand All @@ -129,7 +129,7 @@ private static long getCurrentTimestampStatic(long stepOffset) {
timestamp += config.getPOINT_STEP();
} else {
// data is not in regular frequency, then use random
timestamp += config.getPOINT_STEP() * timestampRandom.nextDouble();
timestamp += config.getPOINT_STEP() * ThreadLocalRandom.current().nextDouble();
}
return Constants.START_TIMESTAMP * timeStampConst + offset + timestamp;
}
Expand Down

0 comments on commit 3d60fe0

Please sign in to comment.