Skip to content

Commit 0988f76

Browse files
committed
Add stack safety test
1 parent 5935805 commit 0988f76

File tree

3 files changed

+45
-5
lines changed

3 files changed

+45
-5
lines changed

.sbtopts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
-J-XX:+UseG1GC
2-
-J-Xmx2G
2+
-J-Xmx4G

modules/benchmark/src/main/scala/EncodingBench.scala

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import cats.syntax.all._
2020

2121
import org.openjdk.jmh.annotations.{Benchmark, BenchmarkMode, Mode}
2222
import cats.data.NonEmptyList
23-
23+
import scala.jdk.CollectionConverters._
2424
import schemas._
2525
import data._
2626

@@ -31,6 +31,30 @@ class EncodingBench {
3131
def encodeAnS =
3232
Schema.string.write(string)
3333

34+
@Benchmark
35+
@BenchmarkMode(Array(Mode.Throughput))
36+
def encodeRawAnM =
37+
DynamoValue.m(
38+
Map(
39+
"name" -> DynamoValue.s(allosaurus.name),
40+
"age" -> DynamoValue.n(allosaurus.age),
41+
"attacks" -> DynamoValue.n(allosaurus.attacks)
42+
)
43+
)
44+
45+
@Benchmark
46+
@BenchmarkMode(Array(Mode.Throughput))
47+
def encodeRawAnMAsAv =
48+
val map = new java.util.IdentityHashMap[String, software.amazon.awssdk.services.dynamodb.model.AttributeValue](3)
49+
map.put("name", software.amazon.awssdk.services.dynamodb.model.AttributeValue.builder().s(allosaurus.name).build())
50+
map.put("age", software.amazon.awssdk.services.dynamodb.model.AttributeValue.builder().n(allosaurus.age.toString).build())
51+
map.put("attacks", software.amazon.awssdk.services.dynamodb.model.AttributeValue.builder().n(allosaurus.attacks.toString).build())
52+
DynamoValue(software.amazon.awssdk.services.dynamodb.model.AttributeValue
53+
.builder()
54+
.m(map)
55+
.build()
56+
)
57+
3458
@Benchmark
3559
@BenchmarkMode(Array(Mode.Throughput))
3660
def encodeAnM =

modules/core/shared/src/test/scala/SchemaSuite.scala

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -615,9 +615,25 @@ class SchemaSuite extends ScalaCheckSuite {
615615
check(schema, departments, expected)
616616
}
617617

618-
test("recursive products with higly recursive") {
619-
val departments = deepDepartment(1, 3)
620-
val expected = deepDepartmentDynamoValue(1, 3);
618+
test("recursive products with very deep record") {
619+
val departments = deepDepartment(100, 1)
620+
val expected = deepDepartmentDynamoValue(100, 1);
621+
622+
val schema: Schema[Department] = Schema.recursive { rec =>
623+
Schema.record { field =>
624+
(
625+
field("name", _.name),
626+
field("subdeps", _.subdeps)(rec.asList)
627+
).mapN(Department.apply)
628+
}
629+
}
630+
631+
check(schema, departments, expected)
632+
}
633+
634+
test("recursive products with very wide record".only) {
635+
val departments = deepDepartment(1, 100)
636+
val expected = deepDepartmentDynamoValue(1, 100);
621637

622638
val schema: Schema[Department] = Schema.recursive { rec =>
623639
Schema.record { field =>

0 commit comments

Comments
 (0)