@@ -6,9 +6,14 @@ import com.networknt.schema.JsonSchemaFactory
6
6
import com.networknt.schema.OutputFormat
7
7
import com.networknt.schema.SchemaValidatorsConfig
8
8
import com.networknt.schema.SpecVersion.VersionFlag.V7
9
+ import com.networknt.schema.output.OutputFlag
10
+ import com.networknt.schema.output.OutputUnit
9
11
import io.github.optimumcode.json.schema.ErrorCollector
10
12
import io.github.optimumcode.json.schema.OutputCollector
11
13
import io.github.optimumcode.json.schema.ValidationError
14
+ import io.github.optimumcode.json.schema.ValidationOutput.Detailed
15
+ import io.github.optimumcode.json.schema.ValidationOutput.Flag
16
+ import io.github.optimumcode.json.schema.ValidationOutput.Verbose
12
17
import io.github.optimumcode.json.schema.fromStream
13
18
import io.openapiprocessor.jackson.JacksonConverter
14
19
import io.openapiprocessor.jsonschema.reader.UriReader
@@ -19,8 +24,8 @@ import io.openapiprocessor.jsonschema.schema.Output.FLAG
19
24
import io.openapiprocessor.jsonschema.schema.SchemaStore
20
25
import io.openapiprocessor.jsonschema.validator.Validator
21
26
import io.openapiprocessor.jsonschema.validator.ValidatorSettings
27
+ import io.openapiprocessor.jsonschema.validator.steps.ValidationStep
22
28
import kotlinx.benchmark.Benchmark
23
- import kotlinx.benchmark.Blackhole
24
29
import kotlinx.benchmark.Setup
25
30
import kotlinx.serialization.ExperimentalSerializationApi
26
31
import kotlinx.serialization.json.Json
@@ -96,49 +101,49 @@ abstract class AbstractComparisonBenchmark {
96
101
}
97
102
98
103
@Benchmark
99
- fun validateOpenApi (bh : Blackhole ) {
100
- bh.consume( openapiValidator.validate(openapiSchema, openapiDocument) )
104
+ fun validateOpenApi (): ValidationStep {
105
+ return openapiValidator.validate(openapiSchema, openapiDocument)
101
106
}
102
107
103
108
@Benchmark
104
- fun validateNetworkntFlag (bh : Blackhole ) {
105
- bh.consume( networkntSchema.validate(networkntDocument, OutputFormat .FLAG ) )
109
+ fun validateNetworkntFlag (): OutputFlag ? {
110
+ return networkntSchema.validate(networkntDocument, OutputFormat .FLAG )
106
111
}
107
112
108
113
@Benchmark
109
- fun validateNetworkntDetailed (bh : Blackhole ) {
110
- bh.consume( networkntSchema.validate(networkntDocument, OutputFormat .LIST ) )
114
+ fun validateNetworkntDetailed (): OutputUnit {
115
+ return networkntSchema.validate(networkntDocument, OutputFormat .LIST )
111
116
}
112
117
113
118
@Benchmark
114
- fun validateNetworkntVerbose (bh : Blackhole ) {
115
- bh.consume( networkntSchema.validate(networkntDocument, OutputFormat .HIERARCHICAL ) )
119
+ fun validateNetworkntVerbose (): OutputUnit {
120
+ return networkntSchema.validate(networkntDocument, OutputFormat .HIERARCHICAL )
116
121
}
117
122
118
123
@Benchmark
119
- fun validateKmpEmptyCollector (bh : Blackhole ) {
120
- bh.consume( schema.validate(document, ErrorCollector .EMPTY ) )
124
+ fun validateKmpEmptyCollector (): Boolean {
125
+ return schema.validate(document, ErrorCollector .EMPTY )
121
126
}
122
127
123
128
@Benchmark
124
- fun validateKmpCollectErrors (bh : Blackhole ) {
129
+ fun validateKmpCollectErrors (): List < ValidationError > {
125
130
val errors = arrayListOf<ValidationError >()
126
131
schema.validate(document, errors::add)
127
- bh.consume( errors)
132
+ return errors
128
133
}
129
134
130
135
@Benchmark
131
- fun validateKmpFlag (bh : Blackhole ) {
132
- bh.consume( schema.validate(document, OutputCollector .flag() ))
136
+ fun validateKmpFlag (): Flag {
137
+ return schema.validate(document, OutputCollector .flag())
133
138
}
134
139
135
140
@Benchmark
136
- fun validateKmpDetailed (bh : Blackhole ) {
137
- bh.consume( schema.validate(document, OutputCollector .detailed() ))
141
+ fun validateKmpDetailed (): Detailed {
142
+ return schema.validate(document, OutputCollector .detailed())
138
143
}
139
144
140
145
@Benchmark
141
- fun validateKmpVerbose (bh : Blackhole ) {
142
- bh.consume( schema.validate(document, OutputCollector .verbose() ))
146
+ fun validateKmpVerbose (): Verbose {
147
+ return schema.validate(document, OutputCollector .verbose())
143
148
}
144
149
}
0 commit comments