Skip to content

Instantly share code, notes, and snippets.

@acao
Last active October 28, 2017 18:41
Show Gist options
  • Select an option

  • Save acao/d9f0e78d6efc337f4c116972bdd55d82 to your computer and use it in GitHub Desktop.

Select an option

Save acao/d9f0e78d6efc337f4c116972bdd55d82 to your computer and use it in GitHub Desktop.
Get/Set Benchmark Step 2
<script>
var suite = new Benchmark.Suite();
const obj = {
stuff: {
things: {
stuff: 'things',
things: 'stuff',
other: {
stuff: 'things'
}
}
}
};
const path = 'stuff.things.other.stuff';
const valToSet = 9999;
suite
.add('lodash get', () => {
_.get(obj, path);
})
.on('cycle', event => {
console.log(String(event.target.fn));
console.log(String(event.target));
})
.on('complete', () => {
console.log('Fastest is ' + this.filter('fastest').map('name'));
})
.run();
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment