This repository has been archived by the owner on Jun 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 458
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✅ Add basic decode test complete basic tests benchmark
- Loading branch information
Showing
11 changed files
with
747 additions
and
199 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
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 |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Copyright © 2020 Lisk Foundation | ||
* | ||
* See the LICENSE file at the top-level directory of this distribution | ||
* for licensing information. | ||
* | ||
* Unless otherwise agreed in a custom licensing agreement with the Lisk Foundation, | ||
* no part of this software, including this file, may be copied, modified, | ||
* propagated, or distributed except according to the terms contained in the | ||
* LICENSE file. | ||
* | ||
* Removal or modification of this copyright notice is prohibited. | ||
*/ | ||
// writeBoolean x 3,543,238 ops/sec ±1.59% (89 runs sampled) | ||
|
||
const { Suite } = require('benchmark'); | ||
const { | ||
codec, | ||
} = require('../dist-node/codec'); | ||
|
||
const suite = new Suite(); | ||
|
||
const testSchema = { | ||
$id: 'testSchema', | ||
type: 'object', | ||
properties: { | ||
b: { fieldNumber: 2, dataType: 'string' }, | ||
a: { fieldNumber: 1, dataType: 'string' }, | ||
d: { fieldNumber: 4, dataType: 'bytes' }, | ||
e: { fieldNumber: 5, dataType: 'uint32' }, | ||
c: { | ||
type: 'object', | ||
fieldNumber: 3, | ||
properties: { | ||
cc: { fieldNumber: 3, dataType: 'string' }, | ||
ca: { fieldNumber: 1, dataType: 'string' }, | ||
cb: { | ||
type: 'object', | ||
fieldNumber: 2, | ||
properties: { | ||
cbb: { fieldNumber: 2, dataType: 'string' }, | ||
cba: { fieldNumber: 1, dataType: 'string' }, | ||
cbc: { | ||
type: 'object', | ||
fieldNumber: 3, | ||
properties: { | ||
cbcb: { fieldNumber: 3, dataType: 'string' }, | ||
cbca: { fieldNumber: 2, dataType: 'string' }, | ||
}, | ||
}, | ||
cbd: { fieldNumber: 4, dataType: 'string' }, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
const message = Buffer.from('0a37313337313839333731393331333731383933373139333133373138393337313933313337313839333731393331333731383933373139331237313337313839333731393331333731383933373139333133373138393337313933313337313839333731393331333731383933373139331a720a373133373138393337313933313337313839333731393331333731383933373139333133373138393337313933313337313839333731393312ab010a37313337313839333731393331333731383933373139333133373138393337313933313337313839333731393331333731383933373139331237313337313839333731393331333731383933373139333133373138393337313933313337313839333731393331333731383933373139331a721237313337313839333731393331333731383933373139333133373138393337313933313337313839333731393331333731383933373139331a37313337313839333731393331333731383933373139333133373138393337313933313337313839333731393331333731383933373139332237313337313839333731393331333731383933373139333133373138393337313933313337313839333731393331333731383933373139331a373133373138393337313933313337313839333731393331333731383933373139333133373138393337313933313337313839333731393322373133373138393337313933313337313839333731393331333731383933373139333133373138393337313933313337313839333731393328904e', 'hex'); | ||
|
||
|
||
suite | ||
.add('decode', () => { | ||
codec.decode(testSchema, message); | ||
}) | ||
.on('cycle', function (event) { | ||
console.log(String(event.target)); | ||
}) | ||
.run({ async: true }); |
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
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
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
Oops, something went wrong.