You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
665 B
JavaScript
40 lines
665 B
JavaScript
"use strict";
|
|
|
|
const benchmark = require("benchmark");
|
|
|
|
const s = require("../src");
|
|
|
|
let PersonName = s.createType("PersonName", s.string({
|
|
matches: /^[a-z0-9 '-]+$/
|
|
}));
|
|
|
|
let Person = s.createType("Person", {
|
|
name: PersonName,
|
|
age: s.number(),
|
|
isAlive: s.boolean()
|
|
});
|
|
|
|
new benchmark.Suite()
|
|
.add("normal", () => {
|
|
let me = {
|
|
name: "somebody",
|
|
age: 42,
|
|
isAlive: true
|
|
};
|
|
|
|
let a = (me.name, me.age, me.isAlive);
|
|
})
|
|
.add("strict", () => {
|
|
let me = Person({
|
|
name: "somebody",
|
|
age: 42,
|
|
isAlive: true
|
|
});
|
|
|
|
let a = (me.name, me.age, me.isAlive);
|
|
})
|
|
.on("cycle", function (event) {
|
|
console.log(String(event.target));
|
|
})
|
|
.run();
|