not string vs length is 0 vs not length vs string equals empty string vs string soft equals empty string vs not boolean vs length soft equals 0Fastest: string equals empty string (2.7x faster)
172,149,232 ops/sec
171,221,456 ops/sec
167,219,296 ops/sec
166,102,384 ops/sec
165,673,984 ops/sec
165,447,920 ops/sec
64,592,512 ops/sec
Results show median performance across all community submissions. Run this benchmark yourself to verify on your device.
| Test case name | Result |
|---|---|
| not string | |
| length is 0 | |
| not length | |
| string equals empty string | |
| string soft equals empty string | |
| not boolean | |
| length soft equals 0 |
| Test name | Executions per second |
|---|---|
| ✓ not string | 163,104,832 Ops/sec |
| length is 0 | 132,934,680 Ops/sec |
| length soft equals 0 | 132,346,264 Ops/sec |
| not length | 131,823,056 Ops/sec |
| not boolean | 128,294,256 Ops/sec |
| string soft equals empty string | 124,811,552 Ops/sec |
| string equals empty string | 119,874,392 Ops/sec |