Skip to content

Commit 4189b67

Browse files
author
Vyacheslav Artemyev
committed
Fix JMH test
1 parent 6c163d5 commit 4189b67

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

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

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ 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 com.viartemev.thewhiterabbit.queue.DeleteQueueSpecification
11-
import com.viartemev.thewhiterabbit.queue.QueueSpecification
12-
import com.viartemev.thewhiterabbit.queue.declareQueue
13-
import com.viartemev.thewhiterabbit.queue.deleteQueue
1410
import kotlinx.coroutines.awaitAll
1511
import kotlinx.coroutines.runBlocking
1612
import org.openjdk.jmh.annotations.Benchmark
@@ -40,39 +36,31 @@ open class ConfirmPublisherBenchmark {
4036
@Param("1", "10", "100", "1000", "10000", "100000")
4137
private var numberOfMessages: Int = 0
4238
private val testQueueName = "jmh_test_queue"
39+
private val factory = ConnectionFactory().apply { useNio() }
4340
private lateinit var connection: Connection
4441
private lateinit var channel: ConfirmChannel
4542
private lateinit var publisher: ConfirmPublisher
4643
private lateinit var messages: List<OutboundMessage>
4744

48-
@Setup
49-
fun setupConnection() {
50-
val factory = ConnectionFactory().apply { useNio() }
51-
connection = factory.newConnection()
52-
}
53-
5445
@Setup(Level.Iteration)
5546
fun setup() {
47+
connection = factory.newConnection()
5648
channel = connection.createConfirmChannel()
57-
runBlocking { channel.declareQueue(QueueSpecification(testQueueName)) }
49+
channel.queueDeclare(testQueueName, false, false, false, mapOf())
5850
publisher = channel.publisher()
5951
messages = (1..numberOfMessages).map { createMessage() }
6052
}
6153

6254
@TearDown(Level.Iteration)
6355
fun tearDownPublisher() {
64-
runBlocking { channel.deleteQueue(DeleteQueueSpecification(testQueueName)) }
56+
channel.queueDelete(testQueueName)
6557
channel.close()
66-
}
67-
68-
@TearDown
69-
fun tearDown() {
7058
connection.close()
7159
}
7260

7361
@Benchmark
7462
fun sendWithPublishConfirm(blackhole: Blackhole) = runBlocking {
75-
blackhole.consume(publisher.asyncPublishWithConfirm(messages).awaitAll())
63+
blackhole.consume(publisher.publishWithConfirmAsync(messages = messages).awaitAll())
7664
}
7765

7866
private fun createMessage(): OutboundMessage = OutboundMessage("", testQueueName, MessageProperties.MINIMAL_BASIC, "")

0 commit comments

Comments
 (0)