-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
45 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,47 @@ | ||
const Numesis = require('./mod') | ||
const n = new Numesis(); | ||
let ts = Date.now(); | ||
let de = []; | ||
let dp = []; | ||
for(let i = 999999999; i < 1000001999; i++){ | ||
const e = n.e(i); | ||
if (de.includes(e)) dp.push(e); | ||
de.push(e); | ||
|
||
async function test(s) { | ||
const n = new Numesis(); | ||
return new Promise((resolve)=>{ | ||
let ts = Date.now(); | ||
let te = Date.now(); | ||
let de = []; | ||
var stop = false; | ||
for(let i = 0; !stop; i++){ | ||
de.push(n.e(i)); | ||
te = Date.now(); | ||
if (te - ts >= s * 1000) { | ||
stop = true; | ||
return resolve({ | ||
start: ts, | ||
end: te, | ||
id: de | ||
}); | ||
} | ||
} | ||
}); | ||
} | ||
let te = Date.now(); | ||
console.log(`\n===========================================`); | ||
console.log("Generated ID's \t\t\t:", de.length); | ||
console.log("Duplicated ID's \t\t:", dp.length); | ||
console.log("Elapsed time \t\t\t:", (te - ts) / 1000, "s"); | ||
async function average(s) { | ||
const id = []; | ||
const dup = []; | ||
for(let i = 0; i < s; i++){ | ||
await test(1).then(({ id: e })=>{ | ||
id.push(e.length); | ||
dup.push(e.length - new Set(e).size); | ||
}); | ||
} | ||
const avg = id.reduce((a, b)=>a + b, 0) / id.length; | ||
const avgDup = dup.reduce((a, b)=>a + b, 0) / dup.length; | ||
console.log(`\n=====================================================`); | ||
console.log("Average ID's:", ~~avg, "/s"); | ||
console.log(`Average duplicated ID's: ${~~avgDup}/s`); | ||
console.log(`Elapsed time: ${s}s`); | ||
} | ||
test(1).then((e)=>{ | ||
console.log(`\n=====================================================`); | ||
console.log("Average Generated ID's \t\t\t:", e?.id?.length); | ||
console.log("Average Duplicated ID's \t\t:", e?.id?.length - new Set(e?.id).size); | ||
console.log("Elapsed time \t\t\t\t:", (e?.end - e?.start) / 1000, "s"); | ||
return 0; | ||
}); | ||
average(10); |