Skip to content

Commit 2d3c866

Browse files
committed
Fix cbor and xml benchmarks
1 parent c3e66b9 commit 2d3c866

14 files changed

Lines changed: 189 additions & 18 deletions

benchmarks/serde-benchmarks/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ jmh {
158158
// are absent.
159159
warmupIterations = 5
160160
iterations = 10
161-
fork = 0
161+
fork = 1
162162
// Select the native smithy-java JSON provider (rather than the default
163163
// Jackson-backed provider, which has higher ServiceLoader priority).
164164
// The system property is read once during static initialization of

benchmarks/serde-benchmarks/model/operations/CopyObject.smithy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ structure CopyObjectRequest {
256256
ExpectedSourceBucketOwner: String
257257
}
258258

259+
@xmlName("CopyObjectResult")
259260
structure CopyObjectOutput {
260261
@httpHeader("x-amz-expiration")
261262
Expiration: String

benchmarks/serde-benchmarks/model/operations/GetItem.smithy

Lines changed: 168 additions & 3 deletions
Large diffs are not rendered by default.

benchmarks/serde-benchmarks/src/jmh/java/software/amazon/smithy/java/benchmarks/serde/AwsJson1_0DeserializeBenchmark.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
@OutputTimeUnit(TimeUnit.NANOSECONDS)
3535
@Warmup(iterations = 5, time = 2, timeUnit = TimeUnit.SECONDS)
3636
@Measurement(iterations = 10, time = 5, timeUnit = TimeUnit.SECONDS)
37-
@Fork(0)
37+
@Fork(1)
3838
public class AwsJson1_0DeserializeBenchmark {
3939

4040
private static final String GENERATED_PACKAGE =

benchmarks/serde-benchmarks/src/jmh/java/software/amazon/smithy/java/benchmarks/serde/AwsJson1_0SerializeBenchmark.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
@OutputTimeUnit(TimeUnit.NANOSECONDS)
3636
@Warmup(iterations = 5, time = 2, timeUnit = TimeUnit.SECONDS)
3737
@Measurement(iterations = 10, time = 5, timeUnit = TimeUnit.SECONDS)
38-
@Fork(0)
38+
@Fork(1)
3939
public class AwsJson1_0SerializeBenchmark {
4040

4141
private static final String GENERATED_PACKAGE =

benchmarks/serde-benchmarks/src/jmh/java/software/amazon/smithy/java/benchmarks/serde/AwsQueryDeserializeBenchmark.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
@OutputTimeUnit(TimeUnit.NANOSECONDS)
3434
@Warmup(iterations = 5, time = 2, timeUnit = TimeUnit.SECONDS)
3535
@Measurement(iterations = 10, time = 5, timeUnit = TimeUnit.SECONDS)
36-
@Fork(0)
36+
@Fork(1)
3737
public class AwsQueryDeserializeBenchmark {
3838

3939
private static final String GENERATED_PACKAGE =

benchmarks/serde-benchmarks/src/jmh/java/software/amazon/smithy/java/benchmarks/serde/AwsQuerySerializeBenchmark.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
@OutputTimeUnit(TimeUnit.NANOSECONDS)
3434
@Warmup(iterations = 5, time = 2, timeUnit = TimeUnit.SECONDS)
3535
@Measurement(iterations = 10, time = 5, timeUnit = TimeUnit.SECONDS)
36-
@Fork(0)
36+
@Fork(1)
3737
public class AwsQuerySerializeBenchmark {
3838

3939
private static final String GENERATED_PACKAGE =

benchmarks/serde-benchmarks/src/jmh/java/software/amazon/smithy/java/benchmarks/serde/DeserializeState.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import software.amazon.smithy.java.context.Context;
1313
import software.amazon.smithy.java.core.schema.ApiOperation;
1414
import software.amazon.smithy.java.core.schema.SerializableStruct;
15+
import software.amazon.smithy.java.core.schema.TraitKey;
1516
import software.amazon.smithy.java.core.serde.TypeRegistry;
1617
import software.amazon.smithy.java.http.api.HeaderName;
1718
import software.amazon.smithy.java.http.api.HttpRequest;
@@ -95,11 +96,15 @@ static DeserializeState forTestCase(
9596

9697
byte[] resolvedEmpty = emptyBody;
9798
if (resolvedEmpty == null) {
98-
// Default empty XML body uses the output shape's simple name as
99+
// Default empty XML body uses the output shape's wire name as
99100
// the root element. This matches what an XML protocol response
100-
// with header-only bindings looks like on the wire.
101-
String outputShapeName = operation.outputSchema().id().getName();
102-
resolvedEmpty = ("<" + outputShapeName + "/>").getBytes(StandardCharsets.UTF_8);
101+
// with header-only bindings looks like on the wire. The wire
102+
// name comes from @xmlName if present, otherwise the shape's
103+
// simple name.
104+
var schema = operation.outputSchema();
105+
var xmlName = schema.getTrait(TraitKey.XML_NAME_TRAIT);
106+
String rootName = xmlName != null ? xmlName.getValue() : schema.id().getName();
107+
resolvedEmpty = ("<" + rootName + "/>").getBytes(StandardCharsets.UTF_8);
103108
}
104109
byte[] body = entry.testCase.getBody()
105110
.map(s -> base64DecodeBody

benchmarks/serde-benchmarks/src/jmh/java/software/amazon/smithy/java/benchmarks/serde/RestJson1DeserializeBenchmark.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
@OutputTimeUnit(TimeUnit.NANOSECONDS)
3535
@Warmup(iterations = 5, time = 2, timeUnit = TimeUnit.SECONDS)
3636
@Measurement(iterations = 10, time = 5, timeUnit = TimeUnit.SECONDS)
37-
@Fork(0)
37+
@Fork(1)
3838
public class RestJson1DeserializeBenchmark {
3939

4040
private static final String GENERATED_PACKAGE =

benchmarks/serde-benchmarks/src/jmh/java/software/amazon/smithy/java/benchmarks/serde/RestJson1SerializeBenchmark.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
@OutputTimeUnit(TimeUnit.NANOSECONDS)
3434
@Warmup(iterations = 5, time = 2, timeUnit = TimeUnit.SECONDS)
3535
@Measurement(iterations = 10, time = 5, timeUnit = TimeUnit.SECONDS)
36-
@Fork(0)
36+
@Fork(1)
3737
public class RestJson1SerializeBenchmark {
3838

3939
private static final String GENERATED_PACKAGE =

0 commit comments

Comments
 (0)