improved benchmark accuracy

This commit is contained in:
2025-02-05 19:10:25 +08:00
parent 7d0f24fa58
commit 53b24e3d54

View File

@@ -81,6 +81,8 @@ class BenchmarkCommand : GbcsCommand() {
semaphore.release() semaphore.release()
completionCounter.incrementAndGet() completionCounter.incrementAndGet()
} }
} else {
Thread.sleep(0)
} }
} }
@@ -103,9 +105,10 @@ class BenchmarkCommand : GbcsCommand() {
val completionCounter = AtomicLong(0) val completionCounter = AtomicLong(0)
val semaphore = Semaphore(profile.maxConnections * 3) val semaphore = Semaphore(profile.maxConnections * 3)
val start = Instant.now() val start = Instant.now()
entries.forEach { entry -> val it = entries.iterator()
semaphore.acquire() while (completionCounter.get() < entries.size) {
if (it.hasNext()) {
val entry = it.next()
val future = client.get(entry.first).thenApply { val future = client.get(entry.first).thenApply {
if (it == null) { if (it == null) {
log.error { log.error {
@@ -121,6 +124,9 @@ class BenchmarkCommand : GbcsCommand() {
completionCounter.incrementAndGet() completionCounter.incrementAndGet()
semaphore.release() semaphore.release()
} }
} else {
Thread.sleep(0)
}
} }
val end = Instant.now() val end = Instant.now()
log.info { log.info {