cosmic realms

a coder blog

Benchmark of node.js JSON Validation Modules Part 3

Below are benchmark results for several node.js JSON validation modules.

This is an update to a post I made 6 months ago.

The following modules are benchmarked:

All modules validate with the JSON schema described here: http://json-schema.org/

I used the latest schema version supported by each module. This is noted as (v2) (v3) or (v4).

20,000 valid and 20,000 invalid JSON objects were pre-generated with random data. Each validator module was tested against the same randomized objects.

Results - Valid Objects



Results - Invalid Objects



Conclusion

is-my-json-valid is the fastest validator for both valid and invalid objects.

It's so fast I had to make sure it was actually doing anything at all. Amazingly fast!

tv4 is still plenty fast validating valid objects but is a bit slow dealing with invalid ones.

Jayschema remains the slowest validator.

Lastly, a reminder, amanda only supports async validation and so that test includes some additional overhead in dealing with callbacks.

Source Code

Full source code for all the tests can be found here: https://github.com/Sembiance/cosmicrealms.com/tree/master/sandbox/benchmark-of-node-dot-js-json-validation-modules-part-3

Benchmark of node.js JSON Validation Modules Part 2

Below are benchmark results for several node.js JSON validation modules.

This is an update to a post I made 2 years ago.

The following modules are benchmarked:

All modules validate with the JSON schema described here: http://json-schema.org/ except for joi which uses a custom schema.

I used the latest schema version supported by each module. This is noted as (v2) (v3) or (v4).

Results



Conclusion

tv4 appears to be the fastest, but it only supports the very latest v4 JSON schema version. So if you have older schema documents, you'll need to go with one of the others.

Jayschema takes the 'slowest validator' crown away from JSV. I'd avoid using it if performance matters to your application.

It should be noted that joi doesn't support the JSON schema specification. Joi uses a custom schema which does not support checking for unique array items or evenly divisible numbers.

Lastly, amanda only supports async validation and so that test includes some additional overhead in dealing with callbacks.

Source Code

Full source code for all the tests can be found here: https://github.com/Sembiance/cosmicrealms.com/tree/master/sandbox/benchmark-of-node-dot-js-json-validation-modules-part-2

Hand of Cards

About 2 weeks ago I launched my new web game World of Card Games

I started working on it back in December 2011. I took a month off here and there, so it probably took about 10 months of actual full time work.

One of the toughest problems I faced was getting a hand of cards to show up nicely fanned out in an arc. You know, like you would hold them real life.

My knowledge of math is pretty limited and things like cosines and tangents are totally foreign to me.

Thus, I spent many, many days on IRC and varous websites seeking assistance and learning.

After a ton of work, I was finally able to get this demo coded correctly:

Number of Cards:13
Card Spacing:0.20
Arc Radius:400
view source code

Notice how the cards stick to the base lines, regardless of how you adjust the sliders or which direction the cards are facing (NWSE buttons at top right).

This "stay in place" concept was critical. Without that it would have been quite difficult to implement into the game.

I'd like to say I learned a lot, but that would be dishonest. I still don't really understand the mathmatical concepts in use here well enough to know when or how to apply them to future problems.

My next game will likely be WebGL based. While the game itself will be mostly 2D, I'm almost certainly going to need to learn a lot more math in order to do the things I want to do.

I am actually looking forward to it though. I've always liked math and I enjoy learning, so it should be fun.

I want to thank the folks in #math on irc.freenode.net and David Gouveia for all their help.