jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
class StringDB {
constructor(items) {
this.db = ''
items.forEach((item, i) => {
this.db += `"${i} ${item}"`
})
}
search(query) {
const matches = this.db.match(new RegExp(`(\\d+) ([^"]*${query}[^"]*)`, 'ig'))
matches.forEach((m, i) => {
const id = parseInt(m)
matches[i] = [ id, m.replace(id + ' ', '') ]
})
return matches
}
}
class MapDB {
constructor(items) {
this.db = items.map(item => item.toLowerCase())
}
search(query) {
query = query.toLowerCase()
return this.db.filter((item, i) => {
return item.startsWith(query)
})
}
}
const items = [
"None",
"Home",
"Settings",
"Question",
"Lock",
"Unlock",
"Power",
"Arrow Right",
"Arrow Up",
"Arrow Left",
"Arrow Down",
"Login",
"Logout",
"User",
"Group",
"Forward",
"Back",
"Double Forward",
"Double Back",
"Bullet",
"Bullet Right",
"Bullet Up",
"Bullet Left",
"Bullet Down",
"Bullet Chevron Right",
"Bullet Chevron Up",
"Bullet Chevron Left",
"Bullet Chevron Down",
"Bullet Plus",
"Bullet Minus",
"Bullet Info",
"Bullet Question",
"Bullet Exclamation",
"Bullet Close",
"Bullet Play",
"Refresh",
"Undo",
"Sync",
"Swap",
"Rewind",
"Reverse",
"Step Backwards",
"Stop",
"Pause",
"Play",
"Record",
"Step Forward",
"Forward",
"Fast Forward",
"Hexagon",
"Stop Sign",
"Warning",
"Pencil",
"Trash",
"Search",
"Key",
"Link",
"Eye",
"Marker",
"Push Pin",
"Tag",
"Heart",
"Paper Clip",
"Sun",
"Moon",
"Cloud",
"Lightning Bolt",
"Umbrella",
"Drop",
"Star",
"Earth",
"Site Map",
"Camera",
"Picture",
"Music Note",
"Film",
"Ticket",
"Microphone",
"Trophy",
"Plane",
"Rocket",
"X",
"Move",
"Hand",
"Comment",
"Face Smile",
"Face Neutral",
"Face Frown",
"Circle",
"Circle Right",
"Circle Up",
"Circle Left",
"Circle Down",
"Circle Close",
"Circle Play",
"Circle Dot",
"Circle Slash",
"Circle Clock",
"Caret Right",
"Caret Up",
"Caret Left",
"Caret Down",
"Caret Horizontal",
"Caret Vertical",
"Chevron Right",
"Chevron Up",
"Chevron Left",
"Chevron Down"
]
const strDB = new StringDB(items)
const mapDB = new MapDB(items)
Ready to run.
Test | Ops/sec | |
---|---|---|
arr search |
| ready |
regex search |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.