Mads Cordes
5 supporters
What code is faster?

What code is faster?

Apr 11, 2020

I've found myself wondering quite a bit, which of these code-bits are the fastest? So I came to the conclusion, to benchmark it.

That I did using rust and quickjs, a fun little exercise, can definitely recommend it, especially if you're into the world of performance! 🏎️

So, I've put up the a benchmark tool at https://hasty-back.madco.me/bench simply post some code to it, and it'll take care of the benching, will take ~3 seconds to get a response back, so that's not too long. 😇

If, by any chance, you have no idea, on which code to test, here's a snippet.

{

"global": "const data = [ ...new Array(1000).keys() ]",

"tasks": [

{

"idx": 0,

"code": "data.find(x => x == 800)"

},

{

"idx": 1,

"code": "data.filter(x => x == 800)"

}

]

}

It'll figure which is faster, find vs. filter! Which one do you think?

This is a screendump of how to make a request within postman

Well take a test and figure it out! Thanks!

Enjoy this post?

Buy Mads Cordes a mocha

More from Mads Cordes