Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Move to First New
(version: 0)
Comparing performance of:
Original Code vs New Code
Created:
2 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var wallets = [ { currency: { id: "USD" } }, { currency: { id: "IDR" } }, { currency: { id: "SGD" } }, ]
Tests:
Original Code
const moveCurrencyToFirst = (wallets, currencyId) => { const currencyIdx = wallets.findIndex( (wallet) => wallet.currency.id === currencyId ); const tempWallets = [...wallets]; if (currencyIdx !== -1) { const currWallet = wallets[currencyIdx]; tempWallets.splice(currencyIdx); tempWallets.unshift(currWallet); } return tempWallets; }; console.log(moveCurrencyToFirst(wallets, "SGD"))
New Code
const moveCurrencyToFirst = (wallets, currencyId) => { const selectedWallet = wallets.find( (wallet) => wallet.currency.id === currencyId ); let result = wallets.filter( (wallet) => wallet.currency.id !== currencyId ); if (selectedWallet) { result = [selectedWallet, ...result]; } return result; }; console.log(moveCurrencyToFirst(wallets, "SGD"))
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Original Code
New Code
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
2 years ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36
Browser/OS:
Chrome 126 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Original Code
283272.9 Ops/sec
New Code
280494.8 Ops/sec
Related benchmarks:
test reduce and foreach
111111111111111
Test_Currency
Test_Currency111
Checking fiat currencies
Comments
Confirm delete:
Do you really want to delete benchmark?