Refactors master serializer name from EventMapper to JsonMapper
This commit is contained in:
@@ -27,7 +27,7 @@ import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation
|
||||
import com.fasterxml.jackson.module.kotlin.readValue
|
||||
import com.vitorpamplona.quartz.nip01Core.core.Event
|
||||
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
||||
import com.vitorpamplona.quartz.nip01Core.jackson.EventMapper
|
||||
import com.vitorpamplona.quartz.nip01Core.jackson.JsonMapper
|
||||
import com.vitorpamplona.quartz.utils.LargeCache
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Rule
|
||||
@@ -44,7 +44,7 @@ open class BaseCacheBenchmark {
|
||||
// This file includes duplicates
|
||||
val fullDBInputStream = getInstrumentation().context.assets.open("nostr_vitor_startup_data.json")
|
||||
|
||||
return EventMapper.mapper.readValue<ArrayList<Event>>(
|
||||
return JsonMapper.mapper.readValue<ArrayList<Event>>(
|
||||
GZIPInputStream(fullDBInputStream),
|
||||
)
|
||||
}
|
||||
|
||||
+10
-10
@@ -24,7 +24,7 @@ import androidx.benchmark.junit4.BenchmarkRule
|
||||
import androidx.benchmark.junit4.measureRepeated
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import com.vitorpamplona.quartz.EventFactory
|
||||
import com.vitorpamplona.quartz.nip01Core.jackson.EventMapper
|
||||
import com.vitorpamplona.quartz.nip01Core.jackson.JsonMapper
|
||||
import com.vitorpamplona.quartz.nip01Core.verify
|
||||
import com.vitorpamplona.quartz.nip01Core.verifyId
|
||||
import com.vitorpamplona.quartz.nip01Core.verifySignature
|
||||
@@ -47,28 +47,28 @@ class EventBenchmark {
|
||||
@Test
|
||||
fun parseComplete() {
|
||||
benchmarkRule.measureRepeated {
|
||||
val tree = EventMapper.mapper.readTree(reqResponseEvent)
|
||||
val event = EventMapper.fromJson(tree[2])
|
||||
val tree = JsonMapper.mapper.readTree(reqResponseEvent)
|
||||
val event = JsonMapper.fromJson(tree[2])
|
||||
assertTrue(event.verify())
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun parseREQString() {
|
||||
benchmarkRule.measureRepeated { EventMapper.mapper.readTree(reqResponseEvent) }
|
||||
benchmarkRule.measureRepeated { JsonMapper.mapper.readTree(reqResponseEvent) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun parseEvent() {
|
||||
val msg = EventMapper.mapper.readTree(reqResponseEvent)
|
||||
val msg = JsonMapper.mapper.readTree(reqResponseEvent)
|
||||
|
||||
benchmarkRule.measureRepeated { EventMapper.fromJson(msg[2]) }
|
||||
benchmarkRule.measureRepeated { JsonMapper.fromJson(msg[2]) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun checkId() {
|
||||
val msg = EventMapper.mapper.readTree(reqResponseEvent)
|
||||
val event = EventMapper.fromJson(msg[2])
|
||||
val msg = JsonMapper.mapper.readTree(reqResponseEvent)
|
||||
val event = JsonMapper.fromJson(msg[2])
|
||||
benchmarkRule.measureRepeated {
|
||||
// Should pass
|
||||
assertTrue(event.verifyId())
|
||||
@@ -77,8 +77,8 @@ class EventBenchmark {
|
||||
|
||||
@Test
|
||||
fun checkSignature() {
|
||||
val msg = EventMapper.mapper.readTree(reqResponseEvent)
|
||||
val event = EventMapper.fromJson(msg[2])
|
||||
val msg = JsonMapper.mapper.readTree(reqResponseEvent)
|
||||
val event = JsonMapper.fromJson(msg[2])
|
||||
benchmarkRule.measureRepeated {
|
||||
// Should pass
|
||||
assertTrue(event.verifySignature())
|
||||
|
||||
+2
-2
@@ -25,7 +25,7 @@ import androidx.benchmark.junit4.measureRepeated
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import com.vitorpamplona.quartz.nip01Core.core.Event
|
||||
import com.vitorpamplona.quartz.nip01Core.generateId
|
||||
import com.vitorpamplona.quartz.nip01Core.jackson.EventMapper
|
||||
import com.vitorpamplona.quartz.nip01Core.jackson.JsonMapper
|
||||
import com.vitorpamplona.quartz.nip01Core.verifyId
|
||||
import junit.framework.TestCase.assertNotNull
|
||||
import junit.framework.TestCase.assertTrue
|
||||
@@ -45,7 +45,7 @@ class EventCmdHasherBenchmark {
|
||||
|
||||
@Test
|
||||
fun checkIDHashKind1WihtoutTags() {
|
||||
val event = EventMapper.fromJson(EventMapper.mapper.readTree(reqResponseEvent))
|
||||
val event = JsonMapper.fromJson(JsonMapper.mapper.readTree(reqResponseEvent))
|
||||
|
||||
benchmarkRule.measureRepeated {
|
||||
// Should pass
|
||||
|
||||
+2
-2
@@ -27,7 +27,7 @@ import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation
|
||||
import com.fasterxml.jackson.module.kotlin.readValue
|
||||
import com.vitorpamplona.quartz.nip01Core.core.Event
|
||||
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
||||
import com.vitorpamplona.quartz.nip01Core.jackson.EventMapper
|
||||
import com.vitorpamplona.quartz.nip01Core.jackson.JsonMapper
|
||||
import com.vitorpamplona.quartz.utils.LargeCache
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Rule
|
||||
@@ -42,7 +42,7 @@ open class BaseLargeCacheBenchmark {
|
||||
// This file includes duplicates
|
||||
val fullDBInputStream = getInstrumentation().context.assets.open("nostr_vitor_startup_data.json")
|
||||
|
||||
return EventMapper.mapper.readValue<ArrayList<Event>>(
|
||||
return JsonMapper.mapper.readValue<ArrayList<Event>>(
|
||||
GZIPInputStream(fullDBInputStream),
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user