当前位置:网站首页>JS array copy speed test 220320
JS array copy speed test 220320
2022-07-27 23:39:00 【kfepiza】
js Array copy speed test 220320
perform 600000 Time
use srcAr.concat() when 16 millisecond
newAr=[0,1,2,3,4,5,6,7,8,9, Ten , 11、 ... and , Twelve , 13、 ... and , fourteen , 15、 ... and ]
use srcAr.slice() when 17 millisecond
newAr=[0,1,2,3,4,5,6,7,8,9, Ten , 11、 ... and , Twelve , 13、 ... and , fourteen , 15、 ... and ]
use Array.from(srcAr) when 17 millisecond
newAr=[0,1,2,3,4,5,6,7,8,9, Ten , 11、 ... and , Twelve , 13、 ... and , fourteen , 15、 ... and ]
use […srcAr] when 12 millisecond
newAr=[0,1,2,3,4,5,6,7,8,9, Ten , 11、 ... and , Twelve , 13、 ... and , fourteen , 15、 ... and ]
use Object.assign([],srcAr) when 1985 millisecond
newAr=[0,1,2,3,4,5,6,7,8,9, Ten , 11、 ... and , Twelve , 13、 ... and , fourteen , 15、 ... and ]
use JSON.parse(JSON.stringify(srcAr)) when 549 millisecond
newAr=[0,1,2,3,4,5,6,7,8,9, Ten , 11、 ... and , Twelve , 13、 ... and , fourteen , 15、 ... and ]
The second time srcAr.slice() when 16 millisecond
newAr=[0,1,2,3,4,5,6,7,8,9, Ten , 11、 ... and , Twelve , 13、 ... and , fourteen , 15、 ... and ]
The second time srcAr.concat() when 15 millisecond
newAr=[0,1,2,3,4,5,6,7,8,9, Ten , 11、 ... and , Twelve , 13、 ... and , fourteen , 15、 ... and ]
use newAr=new Array(); for(let i=0;i43 millisecond
newAr=[0,1,2,3,4,5,6,7,8,9, Ten , 11、 ... and , Twelve , 13、 ... and , fourteen , 15、 ... and ]
use newAr=new Array(); for(let i=0;i36 millisecond
newAr=[0,1,2,3,4,5,6,7,8,9, Ten , 11、 ... and , Twelve , 13、 ... and , fourteen , 15、 ... and ]
use newAr=[]; for(let i=0;i32 millisecond
newAr=[0,1,2,3,4,5,6,7,8,9, Ten , 11、 ... and , Twelve , 13、 ... and , fourteen , 15、 ... and ]
use newAr=[]; for(let i=0;i33 millisecond
newAr=[0,1,2,3,4,5,6,7,8,9, Ten , 11、 ... and , Twelve , 13、 ... and , fourteen , 15、 ... and ]
use newAr=Array(srcAr.length); for(let i=0;i17 millisecond
newAr=[0,1,2,3,4,5,6,7,8,9, Ten , 11、 ... and , Twelve , 13、 ... and , fourteen , 15、 ... and ]
use newAr=new Array(srcAr.length); for(let i=0;i23 millisecond
newAr=[0,1,2,3,4,5,6,7,8,9, Ten , 11、 ... and , Twelve , 13、 ... and , fourteen , 15、 ... and ]
Use... For the third time srcAr.concat() when 9 millisecond
newAr=[0,1,2,3,4,5,6,7,8,9, Ten , 11、 ... and , Twelve , 13、 ... and , fourteen , 15、 ... and ]
Use... For the third time srcAr.slice() when 14 millisecond
newAr=[0,1,2,3,4,5,6,7,8,9, Ten , 11、 ... and , Twelve , 13、 ... and , fourteen , 15、 ... and ]
Test code
<!DOCTYPE html><html lang="zh-CN"><head><meta charset="utf-8"/><title></title><style>
#BodyH{
display:flex; align-items:center; justify-content:center;}
</style><script>
const ge=window.dgebi=function(e,s){
if(e&&e.constructor===String){
let n=e;e=document.getElementById(e);e=e||document.querySelector(n);}if(e&&s){
e.newE=e.newChild=s;e.appendChild(s);}return e;},
dcept=(p,tn="DIV")=>{
let e=document.createElement(tn);e.idfine=(i)=>{
e.id=i;return window[i]=e;};e.htm=(h)=>{
e.innerHTML=h;return e;};dgebi(p,e);return e;} ;
if(!document.title.length)(function(){
var str=document.URL; str=str.substring( str.lastIndexOf("/")+1 , str.length-5); str=decodeURI(str); document.title=str;})();
window.dwbr=function(a0=1){
let ar=arguments,br=dwbr.br; if(Number.isFinite(a0)){
br(a0);return;} for(let a of ar)document.write(a.replace(/\n/g,"<br/>"));br();}; dwbr.br=function(n=1){
for(let c=0;c<n;c++)document.write("<br/>");};
window.childIdvar=function(q){
for(let p of document.querySelectorAll(q))for(let c of p.children)if(c.id&&c.id.length>0)window[c.id]=c;};
</script><script>
</script></head><body style="margin:0; font-size:16px; "><header id="BodyH">
<label style="font-size:3rem; "></label><script>{
let s=document.currentScript; let l=s.previousElementSibling; if(!l.innerHTML.length)l.innerHTML=document.title}</script>
</header><div id="BodyB">
<div id="d1" style="font-size:20px;"></div>
</div><footer id="BodyF"></footer><style id="LastStyleTag"></style><script>const BodyH=dgebi("BodyH") , BodyB=dgebi("BodyB") , BodyF=dgebi("BodyF") , LastStyleTag=dgebi("LastStyleTag") , LastStyleSheet=LastStyleTag.sheet;
let d1=dgebi("d1"); for(let t=0;t<60;t++)dcept(d1,"div");
{
let dc=d1.children;
let srcAr=[0,1,2,3,4,5,6,7,8,9,' Ten ',' 11、 ... and ',' Twelve ',' 13、 ... and ',' fourteen ',' 15、 ... and '] , newAr=null , ms , ci=0 , count=600 * 1000;
function showNewAr(){
dc[ci++].innerHTML="newAr=["+newAr+"]<br/>";}
dc[ci++].innerText=" perform "+count+" Time ";
ms=Date.now(); for(let t=0;t<count;t++){
newAr=srcAr.concat();} dc[ci++].innerHTML=" use srcAr.concat() when "+"<strong class='ms' >"+(Date.now()-ms)+"</strong>"+" millisecond "; showNewAr();
ms=Date.now(); for(let t=0;t<count;t++){
newAr=srcAr.slice();} dc[ci++].innerHTML=" use srcAr.slice() when "+"<strong class='ms' >"+(Date.now()-ms)+"</strong>"+" millisecond "; showNewAr();
ms=Date.now(); for(let t=0;t<count;t++){
newAr=Array.from(srcAr);} dc[ci++].innerHTML=" use Array.from(srcAr) when "+"<strong class='ms' >"+(Date.now()-ms)+"</strong>"+" millisecond "; showNewAr();
ms=Date.now(); for(let t=0;t<count;t++){
newAr=[...srcAr];} dc[ci++].innerHTML=" use [...srcAr] when "+"<strong class='ms' >"+(Date.now()-ms)+"</strong>"+" millisecond "; showNewAr();
ms=Date.now(); for(let t=0;t<count;t++){
newAr=Object.assign([],srcAr);} dc[ci++].innerHTML=" use Object.assign([],srcAr) when "+"<strong class='ms' >"+(Date.now()-ms)+"</strong>"+" millisecond "; showNewAr();
ms=Date.now(); for(let t=0;t<count;t++){
newAr=JSON.parse(JSON.stringify(srcAr));} dc[ci++].innerHTML=" use JSON.parse(JSON.stringify(srcAr)) when "+"<strong class='ms' >"+(Date.now()-ms)+"</strong>"+" millisecond "; showNewAr();
ms=Date.now(); for(let t=0;t<count;t++){
newAr=srcAr.slice();} dc[ci++].innerHTML=" The second time srcAr.slice() when "+"<strong class='ms' >"+(Date.now()-ms)+"</strong>"+" millisecond "; showNewAr();
ms=Date.now(); for(let t=0;t<count;t++){
newAr=srcAr.concat();} dc[ci++].innerHTML=" The second time srcAr.concat() when "+"<strong class='ms' >"+(Date.now()-ms)+"</strong>"+" millisecond "; showNewAr();
ms=Date.now(); for(let t=0;t<count;t++){
newAr=new Array(); for(let i=0;i<srcAr.length;i++)newAr.push(srcAr[i]); } dc[ci++].innerHTML=" use newAr=new Array(); for(let i=0;i<srcAr.length;i++)newAr.push(srcAr[i]); when "+"<strong class='ms' >"+(Date.now()-ms)+"</strong>"+" millisecond "; showNewAr();
ms=Date.now(); for(let t=0;t<count;t++){
newAr=new Array(); for(let i=0;i<srcAr.length;i++)newAr[i]=srcAr[i]; } dc[ci++].innerHTML=" use newAr=new Array(); for(let i=0;i<srcAr.length;i++)newAr[i]=srcAr[i]; } when "+"<strong class='ms' >"+(Date.now()-ms)+"</strong>"+" millisecond "; showNewAr();
ms=Date.now(); for(let t=0;t<count;t++){
newAr=[]; for(let i=0;i<srcAr.length;i++)newAr.push(srcAr[i]); } dc[ci++].innerHTML=" use newAr=[]; for(let i=0;i<srcAr.length;i++)newAr.push(srcAr[i]); when "+"<strong class='ms' >"+(Date.now()-ms)+"</strong>"+" millisecond "; showNewAr();
ms=Date.now(); for(let t=0;t<count;t++){
newAr=[]; for(let i=0;i<srcAr.length;i++)newAr[i]=srcAr[i]; } dc[ci++].innerHTML=" use newAr=[]; for(let i=0;i<srcAr.length;i++)newAr[i]=srcAr[i]; } when "+"<strong class='ms' >"+(Date.now()-ms)+"</strong>"+" millisecond "; showNewAr();
ms=Date.now(); for(let t=0;t<count;t++){
newAr=Array(srcAr.length); for(let i=0;i<srcAr.length;i++)newAr[i]=srcAr[i]; } dc[ci++].innerHTML=" use newAr=Array(srcAr.length); for(let i=0;i<srcAr.length;i++)newAr[i]=srcAr[i]; } when "+"<strong class='ms' >"+(Date.now()-ms)+"</strong>"+" millisecond "; showNewAr();
ms=Date.now(); for(let t=0;t<count;t++){
newAr=new Array(srcAr.length); for(let i=0;i<srcAr.length;i++)newAr[i]=srcAr[i]; } dc[ci++].innerHTML=" use newAr=new Array(srcAr.length); for(let i=0;i<srcAr.length;i++)newAr[i]=srcAr[i]; } when "+"<strong class='ms' >"+(Date.now()-ms)+"</strong>"+" millisecond "; showNewAr();
ms=Date.now(); for(let t=0;t<count;t++){
newAr=srcAr.concat();} dc[ci++].innerHTML=" Use... For the third time srcAr.concat() when "+"<strong class='ms' >"+(Date.now()-ms)+"</strong>"+" millisecond "; showNewAr();
ms=Date.now(); for(let t=0;t<count;t++){
newAr=srcAr.slice();} dc[ci++].innerHTML=" Use... For the third time srcAr.slice() when "+"<strong class='ms' >"+(Date.now()-ms)+"</strong>"+" millisecond "; showNewAr();
}
</script></body></html>
边栏推荐
- Spark 离线开发框架设计与实现
- Using the optical fingerprint scheme under the huiding screen, Samsung Galaxy a71 5g is listed
- Desai wisdom number - other charts (parallel coordinate chart): family's willingness to allocate assets in the future
- Socket interaction process of three handshakes
- 回Mixlab三天,“创造力团队”治好了我的精神内耗
- Xu Jinbo: AI protein prediction and design
- 并发和并行有什么区别?
- What is the difference between concurrency and parallelism?
- MapReduce(三)
- After returning to mixlab for three days, "creative team" cured my spiritual internal friction
猜你喜欢

QT with OpenGL(Shadow Mapping)(平行光篇)

用户画像在科技期刊微信公众号精准推送中的应用
![[soft test software evaluator] 2014 comprehensive knowledge over the years](/img/85/46c8fc696ae5249a9aca22b50493f0.jpg)
[soft test software evaluator] 2014 comprehensive knowledge over the years

Common Taylor expansion

Redis 哈希Hash底层数据结构

【数字识别】基于Hopfield神经网络识别0-9数字附Matlab代码

深入了解 XXE 注射

NDK series (6): let's talk about the way and time to register JNI functions
![[elm classification] classification of UCI data sets based on nuclear limit learning machine and limit learning machine, with matlab code](/img/bd/fe105f0af3a24ad6f220fa35bb5e8d.png)
[elm classification] classification of UCI data sets based on nuclear limit learning machine and limit learning machine, with matlab code

See how Gan controls the image generation style step by step? Explain the evolution process of stylegan in detail
随机推荐
Sudden, wechat important notice
进制转换方法
请求合并哪家强——接口请求合并的3种技巧,性能直接爆表
【图像检测】基于Combined Separability Filter实现鼻孔和瞳孔等圆检测matlab源码
【GNN报告】加拿大蒙特利尔唐建:Geometric Deep Learning For Drug Discovery
Socket interaction process of three handshakes
Redis的分布式锁
VIM editor tutorial
C # delegate usage -- console project, which implements events through delegation
Calling dht11/22 temperature and humidity sensor in Proteus simulation Arduino
回Mixlab三天,“创造力团队”治好了我的精神内耗
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: un
In 2019, the world's top ten semiconductor manufacturers: Intel returned to the first place, and apple rose sharply against the trend
ELK日志分析系统安装和部署
【JS 逆向百例】某公共资源交易网,公告 URL 参数逆向分析
采用汇顶屏下光学指纹方案,三星Galaxy A71 5G上市
小程序容器技术超有料,可以让移动研发效率大幅提升
[number recognition] recognize 0-9 numbers based on Hopfield neural network with matlab code
常用泰勒展开
[signal denoising] signal denoising based on Kalman filter with matlab code