Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Remove by splice vs copyWithin vs filter
(version: 0)
Deletion of an element from an array.
Comparing performance of:
Delete by Splice vs Delete by copyWithin vs Delete by Filter
Created:
9 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script> var array = ["m1c6kzws0iubt8g0zlsug14i","xalskr21dm5ke5wczew154s4i","hvbfe3uq3pmoehpilh4zpvi","ffr2btp9rihf3qce770ttke29","ymwh11qu16qwqn5vaafxhia4i","1l7rj49636ddmk3cbszitchaor","bg1njla9dvdkdlw9mbz1l9pb9","201y3ambt118dt7j7bxc6ry66r","hsgzqv2ex2j9j8znv3uzbyb9","k8tuq5ucdx1whgkdcby44pldi","2sjycnx525scxzfxfmwl7q4cxr","18q32nqyo7moqa29e5h3434n29","hmcfquq61n9kb3lww75dk7qfr","fiwykuxxbn7r17ctqjxnptlnmi","4shgyrijl6au4ts680x2bj4i","soojj6fcsyt1n5qfajbxogvi","t3q3inmpnm2bpable646g8pvi","fikqz7u91h55408mcng6jkbj4i","900ywxmkqqfcw72se6jr307ldi","utq8ilmedjq9roylc3jjug14i","b3exkwvpdowgnzuybdfdo647vi","f5gz9fbaaji1u3yvf1h9w9udi","io84h5vop7aqtflg0kvlpu8fr","tkoiwzwsrxojr5l4m70j54s4i","dhb8srcmuv4qhe06xqqnmcayvi","c56ea0p8y6u8ze901m9kd9rudi","uqe8h36xrpy153x4d6ik0ggb9","yelg88k7uyih00t9dyytlnmi","ssstgjiqsd59uz7ywfdcs1yvi","pxl3vjar0fkhiaezatie5qaor","v3n2ttux3jwrfjpau06vquxr","bmvaw0s3bwn1a4vs4uewjnhfr","85fkix619psg7cifpgrcuqsemi","bbiseiz2spsffazrzo3c70hpvi","alhuo6uqqmaympild184a38fr","kqpfumshk7i8skr3by2j1nhfr","znz5gokd2kfhkqkcq4n9daemi","czlvxh76ludjxf15bglgpbvs4i","14tf648f3yg2jb5gn3qiz1if6r","f8l0bttpqr0iqm59tp2lw61or","x1mm8gtvvefr6sk613nqrrudi","ftinvepk94t5ye4xmbmrhpvi","4im9qe55yufgsykr8lgkchaor","acb1xr5iwg3w0e3lood4y4x6r","lzii2en5grtrfax29ng5h4cxr","pag6ybpnvsbydvmqq4r6bt9","ny74ak8g0hzhi7vbjxrzlg14i","sp2boul7p27muo2cccvxi529","qsb0a0hh75359p9crtvcgnwmi","bpxmh6rnp6v5guj1xyv2oz85mi","1g0vr5fl4o3yjwy1f8qi3pu8fr","i7q1qx3euqwgs0p9wcfa2lnmi","f7zem2nt9x5n4kdht4bjk5u3di","nhow0t8u04j469prt67fx0f6r","gceprisvu6kuphio5vbihpvi","gcf1sao3dfawbl4j1sc18m2t9","h54kruubj6lyfpn2m2xirudi","nnxayo2mw7mw3sqrhccjtt9","yyz8g949bsys42p6fnd0a4i","2q32t6vhchxv6vi5xv6m45nrk9","fjgufh8xhi964dfqcs99kke29","tee5l6f4dtlizgzeupw0icnmi","wtgrkjdvg5bwq4zfih957y14i","g2zfspl3t41f7v94m4qu84cxr","hkt2d913iegx1mjdn45vlhaor","e8fdk35sup06s2j3g224yrpb9","d8tponm7e9k7z89uc0jfgeewmi","g4lgdfnv7may0l3oyyrn6d2t9","6f3vt0vh2eynb2p76vo0f6r","d94o6bh6juykc7f4gnuufecdi","gmylglyiamkvsqlhg6kmrhpvi","081567s9oh9hmvtmpunh5s714i","xl1g7h89cp9blpahqhqwipb9","sgeofgqzd8rkhpuelstdl5wmi","ae9eraciq2mgeissj1bncul3di","3zesr2jixkwaua0oab3lnb3xr","6k8lvyr1aqzl1x5ahqqyh6ko6r","uyjxmtqnrzvj7mkyqmtoqolxr","v7wyvd1me4cclu3hws1owp14i","6irsdua6uwdwqvei8qrzbh85mi","n0sbm7x5wkzzggrl0h45tgldi","k83v48gl0bviwfzq35idx6r","qkobghxh0mt4petanqfbc5wmi","60z5d0wr3w7zylgbu8gn1att9","t90u3vzqzdnjv0soi4ftotj4i","nkymc9j93zv9edvmlipy14i","dx4fdypsrbj5b3550xggwlv7vi","yv17by62xu19ghzx2a3v7vi","t55ktqd3ljov5a3i1n1li8uxr","cz9ap58m6mt37pbxlwdcdte29","pqpzfsoldmg0gzz05uexywrk9","ee712q32urczvh48idbtvs4i","38kj9wrd0ejxnpb57o5x9zr529","e36ttd9hfzthrggniy57idaemi","uq73g0anboplz5q7bpooe0zfr","xg3b4368fve377qq4f5u92j4i","b632owgx2ygb1l0mue6x0f6r","g8tpj99bfrm4md4sb6o672e29","pas0sldlke88qdstobllhm2t9","1pocow1nps1yx9p44cz9gm0a4i","f2a8ggfb90fdehr54yb5fusor","hf63zal36gws5onwnvnm6lxr","2r4ywuccxuksi09fb2rxav2t9","7d9nkqdcq9c65jhwdfp5fp3nmi","o60tlguxb6hv6h4zqh4h7iudi","zp1d2dn8g2cf0qkhzjjbxogvi","eyxy61c1evhm28zml1znz5mi","ir7kld15wji237wrxgqilik9","075eo525bm3wh09lx1myxecdi","u8g8crawcm0p7crdphmy4x6r","wjizvba0e2b3r03z40e1giudi","cixtb0daqbwt7yllxzqr6hia4i","ttdmb53kea78hy5eg1trtqpvi","ilqxzffpb8vp8mwwkl4eipb9","cdxo3s7nyijrgrzegzxk2tvs4i","e7h6jwcfjx9soptf17f3gtlnmi","qw3sgzq2nwp569oqzrzoajor","jb586comqj04xugqkbzhyqfr","gnpfqrdmelljqsfvz59v34n29","2sscocvc3uw1wjjd64o8yqfr","a9uyhq7cfdfeh6bop458tcsor","ap3yqxuwdgusmuirh6yqcwhfr","d6p7jspcvm87kiml0t7upiudi","ejowkvwaftznw6v7qym5z5mi","badq37mn685ovjb2gln3zncdi","b8l7aur2qt0sl3xui1in0o1or","ghjkodm6qjnha4zm6um3oko6r","a8kxqdkfwvfrbjik4cm04fgvi","0qgixt0vb2zm4y7fwpicedbo6r","oh41cupy63hcngoi1kiall3di","es4vdwuc7i5srepnguuy9icnmi","1re1rrgf1crnimzse4kveljtt9","5ugu8wf1d7xi305ffqh4u0udi","6x8c9kbm2tzvq9pgjyr50tqpvi","a8z5scyojyee0cxewrbsnn4s4i","6mrih10uydj1isqnaq16ob6gvi","wee254lhbqk7ho2tiust0rudi","nypmu8g2qewnzhmk0nclbx1or","qyr2drqp2dw5cvvt4duuqsemi","shti85yf9o6kdnmem9ggb9","h09afu74n04x7wgh6ans46lxr","59tjykmakwvrgd25zmp6yiizfr","vt9qincway2w1hclwphode7b9","topdh5cxkzffvru2juso1dcxr","rlgvjy8yqawtc08hczydmfgvi","ddkhesqzojhepzoee6z23s1yvi","bnatylg6gn1nqm7wluf1j1yvi","y30jytwr0fh6gg3m1fol59udi","f2w8ifwpvbu4nh45axuaw0zfr","un76200x9ld5l43nt8o94fgvi","srturyfhbpqssu98xa8twqaor","036dflbwt1c369lg39vxx39pb9","0o6pe19bgipdg59q9k3ckjfw29","e4bcy3h0hjltqrf8c5x5pzaor","f8bjhocgpmvmo9ximhra1nhfr","87w9s39ypib7djbknn1edygb9","y9w8zu5jkhjrqelnrrtb21emi","rykwcdrestde95z1wnd59izfr","q834mccmrn14hban2aqgxpqfr","sr3uf1yffe4c4avzr6r49rudi","ea8s5g5sh72onhxmdz244vaemi","shxtolxu3w59y920d8ky8ehfr","4wlivut0n1ht80rs5lyf7ds4i","nueadpm2gt2vf38a7dhsvpldi","1zc4cxwo43gxeif9im1ltmx6r","9n6ci22odczmivmgz4wijm7vi","tpc7su4u7ez0kvkblw7ncow29","zksblo1sh7dwt6vlcihrara4i","p9jotkt2y2szpo31b66jvpldi","tl2w2crc3p524s300iacbx1or","9ttyz01etc45zqppvkkwklnmi","o6nj3qxy3a7iqyy06k7zoxbt9","d8imry74j85gerwwypp1wz5mi","77vkrqqmyr9py125czkw9x80k9","c1gv40vm2us435cqszncqbbj4i","9tfdorhnwnaqzforgj2k8d7vi","2d3cuqd0p2ur5zrbajwo4dkj4i","2jgvcdh5j7wyfuqdbgn8rxjemi","kadxxllve35upugf69qhyqfr","3te9re9k2hb9xkt63okbdfgvi","mm23z47tirqhfp56ynadlhaor","y4pgcsv2jl4vkk24ijuelv7vi","zjry6isasjpxkr6wahc15rk9","awy9qof4ebaj5behfv7dcgnwmi","5yecig7hoku5h2u1dco50cnmi","ztk3ia84nzgvd5c9amnjc3di","e4u4f3l2mdnqu9i9kas2lnmi","qqe4ygai2ufcst4q7csj1yvi","pg5um4aq6p6vzez4bg37ynwmi","t5jsb7riq3o3bqyhne5klnmi","teybuhw83srwyc0t6g92otj4i","9svwvf9u5qz9wzflvowzpk3xr","skzt68jucn2pky1xo6n31h5mi","mngrrjw94j3xgewe7ka603sor","xz4p7nump5nbfp0zilik9","ooinhusm3793joewdt8wfusor","fbabrl45owrboyhcz2xy2v5cdi","ubcwnem2lpc8k6n4r59daemi","d78k39ex2e37tfww7v7erpy14i","est573afhw1cg83xlxe6ogvi"]; </script>
Script Preparation code:
/* these functions assume that only one element matches, so they do not loop! */ function deleteBySplice (array, element) { var index = array.indexOf( element ); if (index !== -1) { array.splice( index, 1 ); } } function deleteByCopyWithin (array, element) { var index = array.indexOf( element ); if (index !== -1) { array.copyWithin( index, index + 1 ); --array.length; } } function deleteByFilter (array, element) { array = array.filter( el => el !== element ); }
Tests:
Delete by Splice
deleteBySplice( array, "uyjxmtqnrzvj7mkyqmtoqolxr" ); deleteBySplice( array, "m1c6kzws0iubt8g0zlsug14i" ); deleteBySplice( array, "4wlivut0n1ht80rs5lyf7ds4i" );
Delete by copyWithin
deleteByCopyWithin( array, "uyjxmtqnrzvj7mkyqmtoqolxr" ); deleteByCopyWithin( array, "m1c6kzws0iubt8g0zlsug14i" ); deleteByCopyWithin( array, "4wlivut0n1ht80rs5lyf7ds4i" );
Delete by Filter
deleteByFilter( array, "uyjxmtqnrzvj7mkyqmtoqolxr" ); deleteByFilter( array, "m1c6kzws0iubt8g0zlsug14i" ); deleteByFilter( array, "4wlivut0n1ht80rs5lyf7ds4i" );
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Delete by Splice
Delete by copyWithin
Delete by Filter
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (iPhone; CPU iPhone OS 18_3_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.3.1 Mobile/15E148 Safari/604.1
Browser/OS:
Mobile Safari 18 on iOS 18.3.2
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Delete by Splice
1038770.0 Ops/sec
Delete by copyWithin
1011795.1 Ops/sec
Delete by Filter
357994.6 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
It seems like you're providing a large amount of text data, likely related to benchmarking results for some JavaScript array deletion methods (e.g., `deleteBySplice`, `deleteByCopyWithin`, and `deleteByFilter`). However, I'll focus on extracting relevant information from this data. Here are the main findings: 1. **Benchmark Results**: The latest benchmark result shows that Firefox 131 performs: * Best execution rate: Delete by copyWithin (~792 executions per second) * Average execution rates: + Delete by Splice (~774 executions per second) + Delete by Filter (~238 executions per second) 2. **Browser and Device**: The benchmark was conducted on a Windows desktop with Firefox 131. 3. **Testing Variations**: There are three test cases for each deletion method, indicating that the results might be slightly different depending on the specific array being tested. To answer your question directly: Firefox 131 performs best when using the `deleteByCopyWithin` method, followed by `deleteBySplice`, and then `deleteByFilter`.
Related benchmarks:
Remove by splice vs spliceIdx vs filter
remove by splice vs filter array v5
Remove by splice vs copyWithin vs filter vs set.delete
Remove by splice vs copyWithin vs filter (numeric array)
Remove by splice vs filter with a known index
Comments
Confirm delete:
Do you really want to delete benchmark?