Skip to content

Commit 1188b4f

Browse files
author
Artemyev Vyacheslav
committed
Fix jmh
1 parent 7c97e66 commit 1188b4f

File tree

3 files changed

+11
-19
lines changed

3 files changed

+11
-19
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ CONTENT.md
1212

1313
#JMH
1414
benchmarks.jar
15+
16+
# MacOS
17+
.DS_Store

benchmarks/src/jmh/kotlin/com.viartemev.thewhiterabbit/ConfirmPublisherBenchmark.kt

+6-19
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,11 @@ import com.viartemev.thewhiterabbit.channel.ConfirmChannel
77
import com.viartemev.thewhiterabbit.channel.createConfirmChannel
88
import com.viartemev.thewhiterabbit.publisher.ConfirmPublisher
99
import com.viartemev.thewhiterabbit.publisher.OutboundMessage
10+
import kotlinx.coroutines.Dispatchers
11+
import kotlinx.coroutines.async
1012
import kotlinx.coroutines.awaitAll
1113
import kotlinx.coroutines.runBlocking
12-
import org.openjdk.jmh.annotations.Benchmark
13-
import org.openjdk.jmh.annotations.BenchmarkMode
14-
import org.openjdk.jmh.annotations.Fork
15-
import org.openjdk.jmh.annotations.Level
16-
import org.openjdk.jmh.annotations.Measurement
17-
import org.openjdk.jmh.annotations.Mode
18-
import org.openjdk.jmh.annotations.OutputTimeUnit
19-
import org.openjdk.jmh.annotations.Param
20-
import org.openjdk.jmh.annotations.Scope
21-
import org.openjdk.jmh.annotations.Setup
22-
import org.openjdk.jmh.annotations.State
23-
import org.openjdk.jmh.annotations.TearDown
24-
import org.openjdk.jmh.annotations.Warmup
14+
import org.openjdk.jmh.annotations.*
2515
import org.openjdk.jmh.infra.Blackhole
2616
import java.util.concurrent.TimeUnit
2717

@@ -46,7 +36,7 @@ open class ConfirmPublisherBenchmark {
4636
channel = connection.createConfirmChannel()
4737
channel.queueDeclare(testQueueName, false, false, false, mapOf())
4838
publisher = channel.publisher()
49-
messages = (1..numberOfMessages).map { createMessage() }
39+
messages = (1..numberOfMessages).map { OutboundMessage("", testQueueName, MessageProperties.MINIMAL_BASIC, "") }
5040
}
5141

5242
@TearDown(Level.Iteration)
@@ -60,16 +50,13 @@ open class ConfirmPublisherBenchmark {
6050
@BenchmarkMode(Mode.AverageTime)
6151
@OutputTimeUnit(TimeUnit.MICROSECONDS)
6252
fun avgTimeSendWithPublishConfirm(blackhole: Blackhole) = runBlocking {
63-
blackhole.consume(publisher.publishWithConfirmAsync(messages = messages).awaitAll())
53+
blackhole.consume(messages.map { async(Dispatchers.IO) { publisher.publishWithConfirm(it) } }.awaitAll())
6454
}
6555

6656
@Benchmark
6757
@BenchmarkMode(Mode.Throughput)
6858
@OutputTimeUnit(TimeUnit.MICROSECONDS)
6959
fun throughputSendWithPublishConfirm(blackhole: Blackhole) = runBlocking {
70-
blackhole.consume(publisher.publishWithConfirmAsync(messages = messages).awaitAll())
60+
blackhole.consume(messages.map { async(Dispatchers.IO) { publisher.publishWithConfirm(it) } }.awaitAll())
7161
}
72-
73-
74-
private fun createMessage(): OutboundMessage = OutboundMessage("", testQueueName, MessageProperties.MINIMAL_BASIC, "")
7562
}

build.gradle

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ buildscript {
2424
plugins {
2525
id("jacoco")
2626
id "com.github.johnrengelman.shadow" version "8.1.1"
27+
id "org.jetbrains.dokka" version "1.9.10"
28+
id "java-library"
2729
}
2830

2931
configure(allprojects) { project ->

0 commit comments

Comments
 (0)