string length via Object.keys

Benchmark created on


Setup

function directNotEmpty(s) { return s.length > 0 }
function keysNotEmpty(s) { return Object.keys(s || '').length > 0 }

var bigString = "several base64-encoded PNG images".repeat(1000)

Test runner

Ready to run.

Testing in
TestOps/sec
direct (lodash minus one test)
directNotEmpty(bigString)
ready
via Object.keys length
keysNotEmpty(bigString)
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.