-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: 🎸 new types JsBinary and JsInstant * feat: 🎸 optics for new types binary and instant * feat: 🎸 prism from base64 encoded string to byte[] * ci: 🎡 set new version 8.2.0 * docs: ✏️ notice file update * feat: 🎸 prism from string to instant * fix: 🐛 equals for JsBinary and JsIntant * bug toJsBinary and toJsIntant * remove scala tests * fix: 🐛 added binary generators and refactor type of date gen * test: 💍 binary and instant tests for generators * fix: 🐛 bug jsinstant and jsbinary parsers * test: 💍 rename test classes * docs: ✏️ added circle badge * docs: ✏️ readme makeover * docs: ✏️ changelog 8.2.0 version * docs: ✏️ remove contributing section
- Loading branch information
1 parent
c4a7607
commit 1064ea6
Showing
160 changed files
with
20,781 additions
and
5,155 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 0 additions & 16 deletions
16
benchmarking/src/main/java/jsonvalues/benchmark/JacksonObjectMapper.java
This file was deleted.
Oops, something went wrong.
94 changes: 84 additions & 10 deletions
94
benchmarking/src/main/java/jsonvalues/benchmark/JsDeserializers.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,115 @@ | ||
package jsonvalues.benchmark; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.networknt.schema.JsonSchema; | ||
import com.networknt.schema.JsonSchemaFactory; | ||
import com.github.fge.jackson.JsonLoader; | ||
import com.github.fge.jsonschema.core.exceptions.ProcessingException; | ||
import com.github.fge.jsonschema.core.load.Dereferencing; | ||
import com.github.fge.jsonschema.core.load.configuration.LoadingConfiguration; | ||
import com.github.fge.jsonschema.main.JsonSchema; | ||
import com.github.fge.jsonschema.main.JsonSchemaFactory; | ||
import jsonvalues.JsObj; | ||
import jsonvalues.spec.JsObjParser; | ||
import org.leadpony.justify.api.JsonValidationService; | ||
import org.openjdk.jmh.annotations.*; | ||
import org.openjdk.jmh.infra.Blackhole; | ||
|
||
import javax.json.JsonObject; | ||
import javax.json.JsonReader; | ||
import javax.validation.ConstraintViolation; | ||
import javax.validation.Validation; | ||
import javax.validation.Validator; | ||
import javax.validation.ValidatorFactory; | ||
import java.io.IOException; | ||
import java.util.Map; | ||
import java.io.StringReader; | ||
import java.util.Set; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import static jsonvalues.benchmark.Conf.PERSON_JSON; | ||
import static jsonvalues.benchmark.Conf.PERSON_SPEC; | ||
import static jsonvalues.benchmark.Conf.*; | ||
|
||
@OutputTimeUnit(TimeUnit.SECONDS) | ||
@BenchmarkMode(Mode.Throughput) | ||
@State(Scope.Benchmark) | ||
public class JsDeserializers { | ||
|
||
private final static ObjectMapper objectMapper = new ObjectMapper(); | ||
// jackson mapper | ||
private static final ObjectMapper objectMapper = new ObjectMapper(); | ||
|
||
// json-values parser | ||
private static final JsObjParser jsonParser = new JsObjParser(PERSON_SPEC); | ||
|
||
// hibernate validator init | ||
private static final ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory(); | ||
private static final Validator validator = validatorFactory.getValidator(); | ||
|
||
// justify init | ||
private static final JsonValidationService serviceJustify = JsonValidationService.newInstance(); | ||
private static final org.leadpony.justify.api.JsonSchema schemaJustify = | ||
serviceJustify.readSchema(new StringReader(PERSON_jSON_SCHEMA)); | ||
|
||
// json schema validator init | ||
private static final LoadingConfiguration cfg = LoadingConfiguration.newBuilder() | ||
.dereferencing(Dereferencing.INLINE) | ||
.freeze(); | ||
private static final JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.newBuilder() | ||
.setLoadingConfiguration(cfg) | ||
.freeze(); | ||
private static final JsonSchema schema; | ||
|
||
static { | ||
try { | ||
schema = jsonSchemaFactory.getJsonSchema(JsonLoader.fromString(PERSON_jSON_SCHEMA)); | ||
} catch (Exception e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
private final static JsObjParser jsonParser = new JsObjParser(PERSON_SPEC); | ||
@Benchmark | ||
public void json_schema_validator(Blackhole bh) throws JsonProcessingException, ProcessingException { | ||
JsonNode json = objectMapper.readTree(PERSON_JSON); | ||
bh.consume(schema.validate(json)); | ||
} | ||
|
||
@Benchmark | ||
public void json_spec(Blackhole bh) { | ||
bh.consume(jsonParser.parse(PERSON_JSON)); | ||
public void justify(Blackhole bh) { | ||
JsonReader reader = serviceJustify.createReader(new StringReader(PERSON_JSON), | ||
schemaJustify, | ||
bh::consume | ||
); | ||
JsonObject json = reader.readObject(); | ||
|
||
reader.close(); | ||
|
||
bh.consume(json); | ||
} | ||
|
||
@Benchmark | ||
public void jackson(Blackhole bh) throws IOException { | ||
public void jackson_node(Blackhole bh) throws IOException { | ||
bh.consume(objectMapper.readTree(PERSON_JSON)); | ||
} | ||
|
||
@Benchmark | ||
public void jackson_pojo(Blackhole bh) throws JsonProcessingException { | ||
Person person = objectMapper.readValue(PERSON_JSON, Person.class); | ||
bh.consume(person); | ||
} | ||
|
||
@Benchmark | ||
public void jackson_pojo_bean_validation(Blackhole bh) throws JsonProcessingException { | ||
PersonWithAnnotations person = objectMapper.readValue(PERSON_JSON, PersonWithAnnotations.class); | ||
Set<ConstraintViolation<PersonWithAnnotations>> validate = validator.validate(person); | ||
bh.consume(validate.size() == 0); | ||
} | ||
|
||
@Benchmark | ||
public void json_values(Blackhole bh) { | ||
bh.consume(JsObj.parse(PERSON_JSON)); | ||
} | ||
|
||
@Benchmark | ||
public void json_spec(Blackhole bh) { | ||
bh.consume(jsonParser.parse(PERSON_JSON)); | ||
} | ||
|
||
} |
87 changes: 0 additions & 87 deletions
87
benchmarking/src/main/java/jsonvalues/benchmark/JsSchemaValidations.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.