Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions cases/marshal.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'reflect-metadata';
import {
f,
validatedPlainToClass
jitValidate
} from '@marcj/marshal';
import { Data } from '../data';
import { Case } from './abstract';
Expand Down Expand Up @@ -43,10 +43,18 @@ class DataType implements Data {
deeplyNested!: DeeplyNestedType;
}

const validator = jitValidate(DataType);

export class MarshalCase extends Case implements Case {
name = 'marshal';

validate() {
return validatedPlainToClass(DataType, this.data);
const errors = validator(this.data);

if (errors.length === 0) {
return this.data;
}

throw new Error('Invalid');
}
}
92 changes: 43 additions & 49 deletions results/bar-graph-10.x.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion results/bar-graph-12.x.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 13 additions & 13 deletions results/benchmarks-10.x.csv
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name,ops
class-transformer-validator-async,33391
class-transformer-validator-sync,41807
funval,759838
io-ts,2140619
json-decoder,640443
marshal,3644059
myzod,208622
purify-ts,659513
runtypes,667801
toi,406045
ts-json-validator,30320984
ts-utils,135462
zod,67298
class-transformer-validator-async,29741
class-transformer-validator-sync,35315
funval,646985
io-ts,1967082
json-decoder,661895
marshal,19848101
myzod,204666
purify-ts,687608
runtypes,677697
toi,406541
ts-json-validator,28826031
ts-utils,122970
zod,58749
78 changes: 39 additions & 39 deletions results/benchmarks-10.x.json
Original file line number Diff line number Diff line change
@@ -1,85 +1,85 @@
{
"name": "typescript-runtime-type-benchmarks",
"date": "2020-03-31T15:58:10.043Z",
"date": "2020-03-31T17:41:47.723Z",
"version": "1.0.0",
"results": [
{
"name": "class-transformer-validator-async",
"ops": 33391,
"margin": 1.96,
"percentSlower": 99.89
"ops": 29741,
"margin": 1.07,
"percentSlower": 99.9
},
{
"name": "class-transformer-validator-sync",
"ops": 41807,
"margin": 1.35,
"percentSlower": 99.86
"ops": 35315,
"margin": 1.82,
"percentSlower": 99.88
},
{
"name": "funval",
"ops": 759838,
"margin": 1.03,
"percentSlower": 97.49
"ops": 646985,
"margin": 1.46,
"percentSlower": 97.76
},
{
"name": "io-ts",
"ops": 2140619,
"margin": 1.07,
"percentSlower": 92.94
"ops": 1967082,
"margin": 1.2,
"percentSlower": 93.18
},
{
"name": "json-decoder",
"ops": 640443,
"margin": 3.74,
"percentSlower": 97.89
"ops": 661895,
"margin": 3.37,
"percentSlower": 97.7
},
{
"name": "marshal",
"ops": 3644059,
"margin": 0.9,
"percentSlower": 87.98
"ops": 19848101,
"margin": 1.1,
"percentSlower": 31.15
},
{
"name": "myzod",
"ops": 208622,
"margin": 2.56,
"percentSlower": 99.31
"ops": 204666,
"margin": 1.41,
"percentSlower": 99.29
},
{
"name": "purify-ts",
"ops": 659513,
"margin": 1.01,
"percentSlower": 97.82
"ops": 687608,
"margin": 5.32,
"percentSlower": 97.61
},
{
"name": "runtypes",
"ops": 667801,
"margin": 0.55,
"percentSlower": 97.8
"ops": 677697,
"margin": 1.05,
"percentSlower": 97.65
},
{
"name": "toi",
"ops": 406045,
"margin": 2.98,
"percentSlower": 98.66
"ops": 406541,
"margin": 0.72,
"percentSlower": 98.59
},
{
"name": "ts-json-validator",
"ops": 30320984,
"margin": 1.03,
"ops": 28826031,
"margin": 0.76,
"percentSlower": 0
},
{
"name": "ts-utils",
"ops": 135462,
"margin": 9.13,
"percentSlower": 99.55
"ops": 122970,
"margin": 3.24,
"percentSlower": 99.57
},
{
"name": "zod",
"ops": 67298,
"margin": 2.82,
"percentSlower": 99.78
"ops": 58749,
"margin": 1.5,
"percentSlower": 99.8
}
],
"fastest": {
Expand Down
26 changes: 13 additions & 13 deletions results/benchmarks-12.x.csv
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name,ops
class-transformer-validator-async,31179
class-transformer-validator-sync,41350
funval,773821
io-ts,2715768
json-decoder,678675
marshal,3850958
myzod,529370
purify-ts,691559
runtypes,491434
toi,404215
ts-json-validator,34036641
ts-utils,115788
zod,51952
class-transformer-validator-async,29168
class-transformer-validator-sync,39687
funval,754198
io-ts,2615888
json-decoder,668138
marshal,19080848
myzod,503374
purify-ts,686688
runtypes,683354
toi,409293
ts-json-validator,34326708
ts-utils,101928
zod,52002
Loading