Beta 7 with some repo names changed.

This commit is contained in:
Luis Fernando Molina committed 2020-11-15 13:05:19 +01:00
1 parent 0f7b40cca7
commit 963c19493a
3408 files changed
+462217 -15516

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
const rnd = require("./randomData.js");
const rlp = require("./../../src/rlp.js");
const ref = {rlp: require("rlp")};
const cps = f => {
for (var t = Date.now(), i = 0; Date.now() - t < 1000; ++i)
f();
return i;
};
let dataTrees = [];
for (let i = 0; i < 64; ++i)
dataTrees.push(rnd.dataTree());
console.log("Benchmarking Eth-Lib's RLP implementation vs the one on NPM.");
const liteCps = cps(() => dataTrees.map((dt) => rlp.decode(rlp.encode(dt))));
const npmCps = cps(() => dataTrees.map((dt) => ref.rlp.decode(ref.rlp.encode(dt))));
console.log("- Eth-Lib: " + liteCps + " calls per second.");
console.log("- Reference: " + npmCps + " calls per second.");
console.log("- Eth-Lib is: " + (liteCps / npmCps).toFixed(2) + " " + (liteCps > npmCps ? "faster" : "slower") + " than reference.");
+24
View File
@@ -0,0 +1,24 @@
// () ~> HexString
const hexString = () => {
let str = "";
while (Math.random() < 0.95)
str = str + ("00" + (Math.random() * 256 | 0).toString(16)).slice(-2);
return "0x" + str;
}
// () ~> DataTree
const dataTree = () => {
let list = [];
while (Math.random() < 0.8) {
if (Math.random() < 0.8)
list.push(hexString());
else
list.push(dataTree());
}
return list;
}
module.exports = {
hexString,
dataTree
}