From 3d60fe0e4ee9ab4d397c97f8ab48ad77cf5a1cad Mon Sep 17 00:00:00 2001 From: Li Yu Heng Date: Mon, 25 Sep 2023 15:44:44 +0800 Subject: [PATCH] Speed up the generation of timestamp random increasing (#374) --- .../iot/benchmark/workload/GenerateDataWorkLoad.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/cn/edu/tsinghua/iot/benchmark/workload/GenerateDataWorkLoad.java b/core/src/main/java/cn/edu/tsinghua/iot/benchmark/workload/GenerateDataWorkLoad.java index cf13f9d90..aa1ca9b4c 100644 --- a/core/src/main/java/cn/edu/tsinghua/iot/benchmark/workload/GenerateDataWorkLoad.java +++ b/core/src/main/java/cn/edu/tsinghua/iot/benchmark/workload/GenerateDataWorkLoad.java @@ -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 { @@ -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 = @@ -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()) { @@ -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; }