Skip to content

Commit

Permalink
Fix awscurl --delay option (#2446)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidthomas426 authored Oct 15, 2024
1 parent d303682 commit 57b4f2f
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions awscurl/src/main/java/ai/djl/awscurl/AwsCurl.java
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,12 @@ static Result run(String[] args) {
}
for (int i = 0; i < clients; ++i) {
final int clientId = i;
final int clientDelay = config.getDelay();
logger.debug("Client {} delay: {}", clientId, clientDelay);
tasks.add(
() -> {
int delay = config.getDelay();
if (delay > 0) {
Thread.sleep(delay);
if (clientDelay > 0) {
Thread.sleep(clientDelay);
}
OutputStream os = config.getOutput(clientId);
long[] requestTime = {0L, -1L};
Expand Down Expand Up @@ -445,6 +446,7 @@ private static final class Config {
private JsonObject extraParameters;
private String jq;
private int delay;
private int delayMin;
private int duration;
private boolean random;
private String error;
Expand Down Expand Up @@ -535,10 +537,11 @@ public Config(CommandLine cmd) throws IOException {
delay = Integer.parseInt(d);
} else {
random = true;
delayMin = Integer.parseInt(min);
if (max != null) {
delay = Integer.parseInt(max) - Integer.parseInt(min);
delay = Integer.parseInt(max) - delayMin;
} else {
delay = Integer.parseInt(min);
delay = delayMin;
}
}
if (delay < 0) {
Expand Down Expand Up @@ -1016,7 +1019,7 @@ public String[] getJsonExpression() {

public int getDelay() {
if (random) {
RandomUtils.nextInt(delay);
return delayMin + RandomUtils.nextInt(delay);
}
return delay;
}
Expand Down

0 comments on commit 57b4f2f

Please sign in to comment.