From 71b45b96fbfbdcbbe2153812132723febc7d2924 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Tue, 6 Aug 2024 11:04:30 -0400 Subject: [PATCH] Adds event factory performance test --- .../vitorpamplona/quartz/benchmark/EventBenchmark.kt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/benchmark/src/androidTest/java/com/vitorpamplona/quartz/benchmark/EventBenchmark.kt b/benchmark/src/androidTest/java/com/vitorpamplona/quartz/benchmark/EventBenchmark.kt index cf37a1141..2e96b6ab9 100644 --- a/benchmark/src/androidTest/java/com/vitorpamplona/quartz/benchmark/EventBenchmark.kt +++ b/benchmark/src/androidTest/java/com/vitorpamplona/quartz/benchmark/EventBenchmark.kt @@ -27,6 +27,8 @@ import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper import com.vitorpamplona.quartz.crypto.CryptoUtils import com.vitorpamplona.quartz.encoders.Nip01Serializer import com.vitorpamplona.quartz.events.Event +import com.vitorpamplona.quartz.events.EventFactory +import com.vitorpamplona.quartz.utils.TimeUtils import junit.framework.TestCase.assertNotNull import junit.framework.TestCase.assertTrue import org.junit.Rule @@ -246,4 +248,13 @@ class EventBenchmark { serializer.escapeStringInto(specialEncoders, Nip01Serializer.BufferedDigestWriter(MessageDigest.getInstance("SHA-256"))) } } + + @Test + fun eventFactoryPerformanceTest() { + val now = TimeUtils.now() + val tags = arrayOf(arrayOf("")) + benchmarkRule.measureRepeated { + EventFactory.create("id", "pubkey", now, 1, tags, "content", "sig") + } + } }