Skip to content

Instantly share code, notes, and snippets.

@martinos
Last active July 9, 2017 23:42
Show Gist options
  • Save martinos/e5d924ac602d5bc2a0d7d4371e2b2426 to your computer and use it in GitHub Desktop.
Save martinos/e5d924ac602d5bc2a0d7d4371e2b2426 to your computer and use it in GitHub Desktop.
friend = hash_of.(name: scalar,
family: hash_of.(name: scalar),
hobbies: array_of.(scalar))
user = hash_of.({ name: scalar,
emails: array_of.(scalar),
friends: array_of.(friend)})
my_hash = {name: "Martin", emails: ["[email protected]"], friends: [{name: "Bob", family: {name: "Joe"}, hobbies: ["Golf", "Ping Pong"]}]}
Benchmark.measure { 100_000.times { user.(my_hash)} }
=> #<Benchmark::Tms:0x007f894b76d500
@cstime=0.0,
@cutime=0.0,
@label="",
@real=0.828742,
@stime=0.0,
@total=0.8199999999999998,
@utime=0.8199999999999998>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment