1.0.10 • Published 10 months ago
nv-random-json v1.0.10
nv-random-json
- nv-random-json
- generate a random big-json
- used in performance test-bed
install
- npm install nv-random-json
usage
const {rand,DFLT_FREQ} = require('nv-random-json')
/*
> DFLT_FREQ
{
null: 1,
true: 1,
false: 1,
string: 1,
number: 1,
array: 5,
object: 5
}
>
*/
example
> rand(5,10)
[ false, [ true, [], {}, {} ], { eQRY: false, _Cex: null } ]
> rand(5,10)
{}
> rand(5,10)
[]
> rand(5,10)
{
JTVJ: [ [], true, 'CxUKj_Qd', false ],
HYWw: 8.129179921989181e+307,
QWRJ: [ {}, 'bVYxUakD' ]
}
> rand(5,10)
{ dUnG: [ {}, true, [] ], HpUD: [], eQng: [ [], {} ], OUwu: null }
> rand(5,10)
{ SrSL: 'xYfLbLmX', BpXF: [ 'bVMdwwgn' ], 'V-SY': [] }
> rand(5,10)
[ 1.2064933143621904e+308, [ 'TKjyaYVY' ], [], null ]
> rand(5,10)
{
BJKL: { GAxi: [], QgaW: {}, PPUw: [] },
AsGh: { QAaN: false },
nayQ: { fktA: {}, NhNT: {} }
}
>
function bigj() {
let start = (new Date()).getTime();
let j = rand(50,1000000)
let end = (new Date()).getTime();
console.log(end-start)
return(j)
}
var big = bigj()
>
11856 //10s to create a big json with 1000000 nodes
>
> const {jlength} = require("nv-facutil-basic")
undefined
> jlength(big)
999999
>
APIS
- rand(max_children_count=10,max_tree_size=1000000,ratio=DFLT_FREQ,key_width=4,str_value_width=8)
LICENSE
- ISC