bench: tx benchmark.
This commit is contained in:
parent
a6b2c23a41
commit
5468465e88
60
bench/tx.js
60
bench/tx.js
@ -17,96 +17,96 @@ const tx10 = common.readTX('tx10');
|
||||
const raw = tx5.getRaw();
|
||||
const end = bench('parse');
|
||||
|
||||
for (let i = 0; i < 1000; i++)
|
||||
for (let i = 0; i < 10000; i++)
|
||||
TX.fromRaw(raw);
|
||||
|
||||
end(1000);
|
||||
end(10000);
|
||||
}
|
||||
|
||||
{
|
||||
const [tx] = tx5.getTX();
|
||||
const end = bench('serialize');
|
||||
|
||||
for (let i = 0; i < 1000; i++) {
|
||||
for (let i = 0; i < 10000; i++) {
|
||||
tx._raw = null;
|
||||
tx.toRaw();
|
||||
}
|
||||
|
||||
end(1000);
|
||||
end(10000);
|
||||
}
|
||||
|
||||
{
|
||||
const [tx] = tx3.getTX();
|
||||
const end = bench('hash');
|
||||
|
||||
for (let i = 0; i < 3000; i++) {
|
||||
for (let i = 0; i < 30000; i++) {
|
||||
tx.hash();
|
||||
tx._hash = null;
|
||||
}
|
||||
|
||||
end(3000);
|
||||
end(30000);
|
||||
}
|
||||
|
||||
{
|
||||
const [tx] = tx5.getTX();
|
||||
const end = bench('witness hash');
|
||||
|
||||
for (let i = 0; i < 3000; i++) {
|
||||
for (let i = 0; i < 30000; i++) {
|
||||
tx.witnessHash();
|
||||
tx._whash = null;
|
||||
}
|
||||
|
||||
end(3000);
|
||||
end(30000);
|
||||
}
|
||||
|
||||
{
|
||||
const [tx] = tx5.getTX();
|
||||
const end = bench('sanity');
|
||||
|
||||
for (let i = 0; i < 1000; i++)
|
||||
for (let i = 0; i < 10000; i++)
|
||||
tx.isSane();
|
||||
|
||||
end(1000);
|
||||
end(10000);
|
||||
}
|
||||
|
||||
{
|
||||
const [tx] = tx5.getTX();
|
||||
const end = bench('input hashes');
|
||||
|
||||
for (let i = 0; i < 1000; i++)
|
||||
for (let i = 0; i < 10000; i++)
|
||||
tx.getInputHashes(null, 'hex');
|
||||
|
||||
end(1000);
|
||||
end(10000);
|
||||
}
|
||||
|
||||
{
|
||||
const [tx] = tx5.getTX();
|
||||
const end = bench('output hashes');
|
||||
|
||||
for (let i = 0; i < 1000; i++)
|
||||
for (let i = 0; i < 10000; i++)
|
||||
tx.getOutputHashes('hex');
|
||||
|
||||
end(1000);
|
||||
end(10000);
|
||||
}
|
||||
|
||||
{
|
||||
const [tx] = tx5.getTX();
|
||||
const end = bench('all hashes');
|
||||
|
||||
for (let i = 0; i < 1000; i++)
|
||||
for (let i = 0; i < 10000; i++)
|
||||
tx.getHashes(null, 'hex');
|
||||
|
||||
end(1000);
|
||||
end(10000);
|
||||
}
|
||||
|
||||
{
|
||||
const [tx, view] = tx3.getTX();
|
||||
const end = bench('verify');
|
||||
|
||||
for (let i = 0; i < 3000; i++)
|
||||
for (let i = 0; i < 30000; i++)
|
||||
tx.verify(view, Script.flags.VERIFY_P2SH);
|
||||
|
||||
end(3000 * tx.inputs.length);
|
||||
end(30000 * tx.inputs.length);
|
||||
}
|
||||
|
||||
{
|
||||
@ -114,20 +114,20 @@ const tx10 = common.readTX('tx10');
|
||||
const {script} = view.getOutputFor(tx.inputs[0]);
|
||||
const end = bench('sighash');
|
||||
|
||||
for (let i = 0; i < 100000; i++)
|
||||
for (let i = 0; i < 1000000; i++)
|
||||
tx.signatureHashV0(0, script, Script.hashType.ALL);
|
||||
|
||||
end(100000);
|
||||
end(1000000);
|
||||
}
|
||||
|
||||
{
|
||||
const [tx, view] = tx3.getTX();
|
||||
const end = bench('fee');
|
||||
|
||||
for (let i = 0; i < 1000; i++)
|
||||
for (let i = 0; i < 10000; i++)
|
||||
tx.getFee(view);
|
||||
|
||||
end(1000);
|
||||
end(10000);
|
||||
}
|
||||
|
||||
{
|
||||
@ -135,10 +135,10 @@ const tx10 = common.readTX('tx10');
|
||||
const flags = Script.flags.VERIFY_P2SH | Script.flags.VERIFY_DERSIG;
|
||||
const end = bench('verify multisig');
|
||||
|
||||
for (let i = 0; i < 3000; i++)
|
||||
for (let i = 0; i < 30000; i++)
|
||||
tx.verify(view, flags);
|
||||
|
||||
end(3000 * tx.inputs.length);
|
||||
end(30000 * tx.inputs.length);
|
||||
}
|
||||
|
||||
const mtx = new MTX();
|
||||
@ -165,26 +165,26 @@ const tx2 = mtx.toTX();
|
||||
{
|
||||
const end = bench('input hashes');
|
||||
|
||||
for (let i = 0; i < 1000; i++)
|
||||
for (let i = 0; i < 10000; i++)
|
||||
tx2.getInputHashes(null, 'hex');
|
||||
|
||||
end(1000);
|
||||
end(10000);
|
||||
}
|
||||
|
||||
{
|
||||
const end = bench('output hashes');
|
||||
|
||||
for (let i = 0; i < 1000; i++)
|
||||
for (let i = 0; i < 10000; i++)
|
||||
tx2.getOutputHashes('hex');
|
||||
|
||||
end(1000);
|
||||
end(10000);
|
||||
}
|
||||
|
||||
{
|
||||
const end = bench('all hashes');
|
||||
|
||||
for (let i = 0; i < 1000; i++)
|
||||
for (let i = 0; i < 10000; i++)
|
||||
tx2.getHashes(null, 'hex');
|
||||
|
||||
end(1000);
|
||||
end(10000);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user