Test (v3)

Revision 3 of this benchmark created on


Setup

let scrollback = [
]
for(let i = 0; i < 30; i++) {
 scrollback.push({id:"00f8fab2-34ef-41e7-a515-b79689dec213",author_id:"00f8fab2-34ef-41e7-a515-b79689dec213",author: "test test", timestamp: Date.now(), content: "this is a test message", is_approved: true, is_notification: false})
}
let clients = {}
for(let i = 0; i < 1000; i++) {
	clients[`${Math.random() * 100000000 | 0}`] = {id:"00f8fab2-34ef-41e7-a515-b79689dec213",authToken:{id:"00f8fab2-34ef-41e7-a515-b79689dec213"}}
}

Test runner

Ready to run.

Testing in
TestOps/sec
Test
    let clientList = Object.values(clients)
    for(const item of scrollback) {
        for(const client of clientList) {
            if(client.authToken && client.authToken.id == item.user) {
                item.sender = client.id
                break
            }
        }
    }
    scrollback.reverse()
ready
Test2
  scrollback.forEach(item => {
    Object.values(clients).forEach(client => {
      if(client.authToken && client.authToken.id == item.user)
        item.sender = client.id
    })
  })
ready

Revisions

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