mirror of
https://github.com/amark/gun.git
synced 2025-03-30 15:08:33 +00:00
rindex 1M !!!
This commit is contained in:
parent
bc742aab0d
commit
d3b048085d
32
gun.js
32
gun.js
@ -1360,22 +1360,18 @@
|
||||
// #soul.has=value>state
|
||||
// ~who#where.where=what>when@was
|
||||
// TODO: BUG! Put probably cannot handle plural chains!
|
||||
var gun = this, at = (gun._), root = at.root.$, ctx = root._, tmp;
|
||||
/*if(tmp = ctx.puts){
|
||||
if(tmp > 100){ // without this, when synchronous, writes to a 'not found' pile up, when 'not found' resolves it recursively calls `put` which incrementally resolves each write. Stack overflow limits can be as low as 10K, so this limit is hardcoded to 1% of 10K.
|
||||
(ctx.stack || (ctx.stack = [])).push([gun, data, cb, as]);
|
||||
clearTimeout(ctx.puto);
|
||||
ctx.puto = setTimeout(function(){
|
||||
var stack = ctx.stack, i = 0, tmp;
|
||||
ctx.stack = ctx.puts = ctx.puto = null;
|
||||
while(tmp = stack[i++]){
|
||||
tmp[0].put(tmp[1], tmp[2], tmp[3]);
|
||||
}
|
||||
}, ctx.opt.wait || 1);
|
||||
return gun;
|
||||
}
|
||||
++ctx.puts;
|
||||
} else { ctx.puts = 1 }*/
|
||||
var gun = this, at = (gun._), root = at.root.$, ctx = root._, M = 100, tmp;
|
||||
if(!ctx.puta){ if(tmp = ctx.puts){ if(tmp > M){ // without this, when synchronous, writes to a 'not found' pile up, when 'not found' resolves it recursively calls `put` which incrementally resolves each write. Stack overflow limits can be as low as 10K, so this limit is hardcoded to 1% of 10K.
|
||||
(ctx.stack || (ctx.stack = [])).push([gun, data, cb, as]);
|
||||
if(ctx.puto){ return }
|
||||
ctx.puto = setTimeout(function drain(){
|
||||
var d = ctx.stack.splice(0,M), i = 0, at; ctx.puta = true;
|
||||
while(at = d[i++]){ at[0].put(at[1], at[2], at[3]) } delete ctx.puta;
|
||||
if(ctx.stack.length){ return ctx.puto = setTimeout(drain, 0) }
|
||||
ctx.stack = ctx.puts = ctx.puto = null;
|
||||
}, 0);
|
||||
return gun;
|
||||
} ++ctx.puts } else { ctx.puts = 1 } }
|
||||
as = as || {};
|
||||
as.data = data;
|
||||
as.via = as.$ = as.via || as.$ || gun;
|
||||
@ -1470,7 +1466,7 @@
|
||||
if(!ack.lack){ this.off() } // One response is good enough for us currently. Later we may want to adjust this.
|
||||
if(!as.ack){ return }
|
||||
as.ack(ack, this);
|
||||
// --C;
|
||||
//--C;
|
||||
}, as.opt);
|
||||
//C++;
|
||||
// NOW is a hack to get synchronous replies to correctly call.
|
||||
@ -1487,7 +1483,7 @@
|
||||
}, as);
|
||||
if(as.res){ as.res() }
|
||||
} function no(v,k){ if(v){ return true } }
|
||||
//console.debug(999,1); var C = 0; setInterval(function(){ try{ debugg.innerHTML = C }catch(e){console.log(e)} }, 500);
|
||||
//console.debug(999,1); var C = 0; setInterval(function(){ try{ debug.innerHTML = C }catch(e){console.log(e)} }, 500);
|
||||
|
||||
function map(v,k,n, at){ var as = this;
|
||||
var is = Gun.is(v);
|
||||
|
@ -13,8 +13,8 @@
|
||||
<button onclick="read()">read</button>
|
||||
<input id="wait" placeholder="wait" type="number">
|
||||
<input id="burst" placeholder="burst" type="number">
|
||||
<div id='debugs'></div>
|
||||
<div id='debug'></div>
|
||||
<div id='debugg'></div>
|
||||
|
||||
<script>
|
||||
Gun.TESTING = true;
|
||||
@ -32,7 +32,7 @@ burst.onchange = function(){ spam.burst = this.value }
|
||||
function spam(){
|
||||
//spam.max = 100000; spam.left = spam.max; spam.wait = 1; spam.burst = 250; spam.c = 0; spam.s = (+new Date);
|
||||
//spam.max = 100000; spam.left = spam.max; spam.wait = 1; spam.burst = 100; spam.c = 0; spam.s = (+new Date);
|
||||
spam.max = 1000000; spam.left = spam.max; spam.wait = 50; spam.burst = 1; spam.c = 0; spam.s = (+new Date);
|
||||
spam.max = 1000000; spam.left = spam.max; spam.wait = 1; spam.burst = 250; spam.c = 0; spam.s = (+new Date);
|
||||
//spam.max = 100; spam.left = spam.max; spam.wait = 1; spam.burst = 1; spam.c = 0; spam.s = (+new Date);
|
||||
var to = setInterval(function(){ var b = spam.burst;
|
||||
if(spam.c >= spam.max){ clearTimeout(to); return; }
|
||||
@ -56,7 +56,7 @@ function spam(){
|
||||
if(spam.end){ spam.end = true }
|
||||
var t = (+new Date) - spam.s, tmp, sec;
|
||||
var status = 'saved\n'+ (tmp = (spam.max - spam.left)) +' in '+ (sec = (t/1000)) +' seconds\n'+ Math.round(tmp / sec) +' per second';
|
||||
debug.innerText = status;
|
||||
debugs.innerText = status;
|
||||
}, 500);
|
||||
}
|
||||
</script>
|
||||
|
@ -14,8 +14,10 @@
|
||||
<input id="find" placeholder="find contacts...">
|
||||
<ul>
|
||||
</ul>
|
||||
<div id='debug'></div>
|
||||
<script>
|
||||
try{localStorage.clear()}catch(e){}
|
||||
try{localStorage.clear()}catch(e){};
|
||||
indexedDB.deleteDatabase('radata');
|
||||
//var gun = Gun('http://localhost:8765/gun');
|
||||
var gun = Gun({localStorage: false});
|
||||
|
||||
@ -40,6 +42,7 @@
|
||||
},9)
|
||||
});
|
||||
});
|
||||
console.log("end forEach:", (+new Date) - start);
|
||||
});
|
||||
|
||||
var to;
|
||||
|
Loading…
x
Reference in New Issue
Block a user