Skip to content

Commit

Permalink
feat: Switch case dependency to internal helper (#296)
Browse files Browse the repository at this point in the history
* feat: Switch case dependency to internal helper

* Add better tests

* Fold eth2 case handling into strings object

* Update tests

* lint
  • Loading branch information
acolytec3 authored Jan 5, 2023
1 parent b783bfb commit 900811c
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 11 deletions.
3 changes: 1 addition & 2 deletions packages/ssz/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@
"types": "lib/index.d.ts",
"dependencies": {
"@chainsafe/as-sha256": "^0.3.1",
"@chainsafe/persistent-merkle-tree": "^0.4.2",
"case": "^1.6.3"
"@chainsafe/persistent-merkle-tree": "^0.4.2"
},
"devDependencies": {
"@types/js-yaml": "^4.0.5",
Expand Down
12 changes: 3 additions & 9 deletions packages/ssz/src/type/container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
concatGindices,
getNode,
} from "@chainsafe/persistent-merkle-tree";
import Case from "case";
import {maxChunksToDepth} from "../util/merkleize";
import {Require} from "../util/types";
import {namedClass} from "../util/named";
Expand All @@ -21,7 +20,7 @@ import {
ContainerTreeViewDUType,
ContainerTreeViewDUTypeConstructor,
} from "../viewDU/container";

import {Case} from "../util/strings";
/* eslint-disable @typescript-eslint/member-ordering */

type BytesRange = {start: number; end: number};
Expand All @@ -35,7 +34,7 @@ export type ContainerOptions<Fields extends Record<string, unknown>> = {
getContainerTreeViewDUClass?: typeof getContainerTreeViewDUClass;
};

type KeyCase =
export type KeyCase =
| "eth2"
| "snake"
| "constant"
Expand Down Expand Up @@ -551,12 +550,7 @@ export function precomputeJsonKey<Fields extends Record<string, Type<unknown>>>(
}
return keyFromCaseMap as string;
} else if (jsonCase) {
if (jsonCase === "eth2") {
const snake = Case.snake(fieldName as string);
return snake.replace(/(\d)$/, "_$1");
} else {
return Case[jsonCase](fieldName as string);
}
return Case[jsonCase](fieldName as string);
} else {
return fieldName as string;
}
Expand Down
31 changes: 31 additions & 0 deletions packages/ssz/src/util/strings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Convert camelCase strings to various other formats -- assumes input field is camelCase or camel1Case

export const Case = {
snake: (field: string): string =>
field
.replaceAll(/[^0-z]/g, "")
.replaceAll(/[a-z][A-Z]|[0-9][A-Z]/g, (substr) => substr[0] + "_" + substr[1].toLowerCase()),
constant: (field: string): string =>
field
.replaceAll(/[^0-z]/g, "")
.replaceAll(/[a-z][A-Z]|[0-9][A-Z]/g, (substr) => substr[0] + "_" + substr[1])
.toUpperCase(),
pascal: (field: string): string => {
const first = field[0].toUpperCase();
return (first + field.slice(1)).replaceAll(/[^0-z]/g, "");
},
camel: (field: string): string => {
return field[0].toLowerCase() + field.slice(1);
},
header: (field: string): string => {
const first = field[0].toUpperCase();
return (
first +
field
.slice(1)
.replaceAll(/[^0-z]/g, "")
.replaceAll(/[a-z][A-Z]|[0-9][A-Z]/g, (substr) => substr[0] + "-" + substr[1])
);
},
eth2: (field: string): string => Case.snake(field).replace(/(\d)$/, "_$1"),
};
25 changes: 25 additions & 0 deletions packages/ssz/test/unit/strings.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import {expect} from "chai";

import {Case} from "../../src/util/strings";
import {KeyCase} from "../../src/type/container";
const testCases = ["fooBar", "foo1Bar", "fooBarBaz", "foo1Bar2Baz", "fooBar1"];
const expectedResults: {[key in KeyCase]: string[]} = {
snake: ["foo_bar", "foo1_bar", "foo_bar_baz", "foo1_bar2_baz", "foo_bar1"],
eth2: ["foo_bar", "foo1_bar", "foo_bar_baz", "foo1_bar2_baz", "foo_bar_1"],
pascal: ["FooBar", "Foo1Bar", "FooBarBaz", "Foo1Bar2Baz", "FooBar1"],
camel: ["fooBar", "foo1Bar", "fooBarBaz", "foo1Bar2Baz", "fooBar1"],
constant: ["FOO_BAR", "FOO1_BAR", "FOO_BAR_BAZ", "FOO1_BAR2_BAZ", "FOO_BAR1"],
header: ["Foo-Bar", "Foo1-Bar", "Foo-Bar-Baz", "Foo1-Bar2-Baz", "Foo-Bar1"],
};

const keys = Object.keys(expectedResults) as KeyCase[];
for (const key of keys) {
describe(`should convert string to ${key} case`, () => {
for (let x = 0; x < 5; x++) {
const field: string = Case[key as KeyCase](testCases[x]);
it(`should convert to ${expectedResults[key as KeyCase][x]}`, () => {
expect(field).to.equal(expectedResults[key][x]);
});
}
});
}

1 comment on commit 900811c

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for some benchmarks.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold.

Benchmark suite Current: 900811c Previous: b783bfb Ratio
new LeafNode() x7812.5 709.43 us/op 146.81 us/op 4.83
Full benchmark results
Benchmark suite Current: 900811c Previous: b783bfb Ratio
digestTwoHashObjects 50023 times 78.595 ms/op 57.677 ms/op 1.36
digest64 50023 times 80.025 ms/op 60.262 ms/op 1.33
digest 50023 times 79.490 ms/op 60.197 ms/op 1.32
input length 32 1.8180 us/op 1.4760 us/op 1.23
input length 64 2.1700 us/op 1.5910 us/op 1.36
input length 128 3.6700 us/op 2.7720 us/op 1.32
input length 256 5.4280 us/op 4.1250 us/op 1.32
input length 512 9.0100 us/op 6.8490 us/op 1.32
input length 1024 17.656 us/op 13.611 us/op 1.30
digest 1000000 times 1.3005 s/op 1.0528 s/op 1.24
hashObjectToByteArray 50023 times 2.6082 ms/op 2.4547 ms/op 1.06
byteArrayToHashObject 50023 times 3.4711 ms/op 3.1114 ms/op 1.12
getGindicesAtDepth 7.0220 us/op 6.4200 us/op 1.09
iterateAtDepth 14.047 us/op 13.042 us/op 1.08
getGindexBits 759.00 ns/op 588.00 ns/op 1.29
gindexIterator 1.6310 us/op 1.3400 us/op 1.22
hash 2 Uint8Array 2250026 times 3.7065 s/op 2.8299 s/op 1.31
hashTwoObjects 2250026 times 3.5545 s/op 2.6223 s/op 1.36
getNodeH() x7812.5 avg hindex 27.680 us/op 20.800 us/op 1.33
getNodeH() x7812.5 index 0 8.3900 us/op 8.1740 us/op 1.03
getNodeH() x7812.5 index 7 8.2630 us/op 8.1170 us/op 1.02
getNodeH() x7812.5 index 7 with key array 8.4570 us/op 8.2370 us/op 1.03
new LeafNode() x7812.5 709.43 us/op 146.81 us/op 4.83
packedRootsBytesToLeafNodes bytes 4000 offset 0 6.4670 us/op 3.6450 us/op 1.77
packedRootsBytesToLeafNodes bytes 4000 offset 1 5.0820 us/op 3.6770 us/op 1.38
packedRootsBytesToLeafNodes bytes 4000 offset 2 5.0890 us/op 3.7110 us/op 1.37
packedRootsBytesToLeafNodes bytes 4000 offset 3 5.4810 us/op 3.8720 us/op 1.42
subtreeFillToContents depth 40 count 250000 96.884 ms/op 56.985 ms/op 1.70
setRoot - gindexBitstring 20.260 ms/op 17.470 ms/op 1.16
setRoot - gindex 21.235 ms/op 20.080 ms/op 1.06
getRoot - gindexBitstring 3.4340 ms/op 3.1235 ms/op 1.10
getRoot - gindex 4.6077 ms/op 3.9357 ms/op 1.17
getHashObject then setHashObject 23.106 ms/op 18.303 ms/op 1.26
setNodeWithFn 21.563 ms/op 16.478 ms/op 1.31
getNodeAtDepth depth 0 x100000 1.8832 ms/op 2.1312 ms/op 0.88
setNodeAtDepth depth 0 x100000 5.6717 ms/op 4.9510 ms/op 1.15
getNodesAtDepth depth 0 x100000 1.7187 ms/op 1.8135 ms/op 0.95
setNodesAtDepth depth 0 x100000 2.4425 ms/op 2.4506 ms/op 1.00
getNodeAtDepth depth 1 x100000 2.0077 ms/op 2.2958 ms/op 0.87
setNodeAtDepth depth 1 x100000 12.834 ms/op 11.145 ms/op 1.15
getNodesAtDepth depth 1 x100000 1.8986 ms/op 1.9754 ms/op 0.96
setNodesAtDepth depth 1 x100000 8.6113 ms/op 8.6315 ms/op 1.00
getNodeAtDepth depth 2 x100000 2.5145 ms/op 2.8216 ms/op 0.89
setNodeAtDepth depth 2 x100000 21.173 ms/op 18.174 ms/op 1.17
getNodesAtDepth depth 2 x100000 33.996 ms/op 28.973 ms/op 1.17
setNodesAtDepth depth 2 x100000 26.999 ms/op 23.321 ms/op 1.16
tree.getNodesAtDepth - gindexes 9.2872 ms/op 10.565 ms/op 0.88
tree.getNodesAtDepth - push all nodes 2.9094 ms/op 2.8740 ms/op 1.01
tree.getNodesAtDepth - navigation 192.15 us/op 168.09 us/op 1.14
tree.setNodesAtDepth - indexes 622.34 us/op 611.52 us/op 1.02
set at depth 8 959.00 ns/op 798.00 ns/op 1.20
set at depth 16 1.3200 us/op 1.0750 us/op 1.23
set at depth 32 2.2290 us/op 1.7620 us/op 1.27
iterateNodesAtDepth 8 256 24.906 us/op 23.074 us/op 1.08
getNodesAtDepth 8 256 5.5450 us/op 5.9130 us/op 0.94
iterateNodesAtDepth 16 65536 7.2572 ms/op 6.6833 ms/op 1.09
getNodesAtDepth 16 65536 2.6643 ms/op 2.5488 ms/op 1.05
iterateNodesAtDepth 32 250000 25.825 ms/op 24.844 ms/op 1.04
getNodesAtDepth 32 250000 6.7057 ms/op 7.7905 ms/op 0.86
iterateNodesAtDepth 40 250000 26.549 ms/op 24.845 ms/op 1.07
getNodesAtDepth 40 250000 6.9509 ms/op 8.0861 ms/op 0.86
250k validators 4.0330 s/op 3.1213 s/op 1.29
bitlist bytes to struct (120,90) 1.4550 us/op 1.2070 us/op 1.21
bitlist bytes to tree (120,90) 5.8040 us/op 5.1940 us/op 1.12
bitlist bytes to struct (2048,2048) 2.3360 us/op 2.4230 us/op 0.96
bitlist bytes to tree (2048,2048) 9.0690 us/op 6.7890 us/op 1.34
ByteListType - deserialize 18.802 ms/op 20.114 ms/op 0.93
BasicListType - deserialize 29.351 ms/op 18.813 ms/op 1.56
ByteListType - serialize 18.554 ms/op 19.863 ms/op 0.93
BasicListType - serialize 22.892 ms/op 24.606 ms/op 0.93
BasicListType - tree_convertToStruct 50.691 ms/op 49.074 ms/op 1.03
List[uint8, 68719476736] len 300000 ViewDU.getAll() + iterate 6.9613 ms/op 6.9221 ms/op 1.01
List[uint8, 68719476736] len 300000 ViewDU.get(i) 6.7948 ms/op 6.4323 ms/op 1.06
Array.push len 300000 empty Array - number 9.0576 ms/op 9.1928 ms/op 0.99
Array.set len 300000 from new Array - number 2.5770 ms/op 2.6899 ms/op 0.96
Array.set len 300000 - number 9.3616 ms/op 8.2337 ms/op 1.14
Uint8Array.set len 300000 298.82 us/op 265.80 us/op 1.12
Uint32Array.set len 300000 452.57 us/op 438.49 us/op 1.03
Container({a: uint8, b: uint8}) getViewDU x300000 47.996 ms/op 38.144 ms/op 1.26
ContainerNodeStruct({a: uint8, b: uint8}) getViewDU x300000 15.930 ms/op 13.326 ms/op 1.20
List(Container) len 300000 ViewDU.getAllReadonly() + iterate 437.99 ms/op 398.87 ms/op 1.10
List(Container) len 300000 ViewDU.getAllReadonlyValues() + iterate 498.82 ms/op 516.25 ms/op 0.97
List(Container) len 300000 ViewDU.get(i) 11.681 ms/op 14.541 ms/op 0.80
List(Container) len 300000 ViewDU.getReadonly(i) 11.742 ms/op 13.527 ms/op 0.87
List(ContainerNodeStruct) len 300000 ViewDU.getAllReadonly() + iterate 63.619 ms/op 59.193 ms/op 1.07
List(ContainerNodeStruct) len 300000 ViewDU.getAllReadonlyValues() + iterate 8.0651 ms/op 9.7774 ms/op 0.82
List(ContainerNodeStruct) len 300000 ViewDU.get(i) 10.116 ms/op 12.248 ms/op 0.83
List(ContainerNodeStruct) len 300000 ViewDU.getReadonly(i) 10.241 ms/op 12.544 ms/op 0.82
Array.push len 300000 empty Array - object 8.9598 ms/op 8.9104 ms/op 1.01
Array.set len 300000 from new Array - object 3.0042 ms/op 3.7525 ms/op 0.80
Array.set len 300000 - object 8.8555 ms/op 9.1758 ms/op 0.97
cachePermanentRootStruct no cache 15.547 us/op 12.619 us/op 1.23
cachePermanentRootStruct with cache 383.00 ns/op 323.00 ns/op 1.19
epochParticipation len 250000 rws 7813 3.8897 ms/op 3.3536 ms/op 1.16
deserialize Attestation - tree 5.7390 us/op 5.0000 us/op 1.15
deserialize Attestation - struct 3.7830 us/op 3.2890 us/op 1.15
deserialize SignedAggregateAndProof - tree 7.8520 us/op 6.6420 us/op 1.18
deserialize SignedAggregateAndProof - struct 5.7810 us/op 5.2240 us/op 1.11
deserialize SyncCommitteeMessage - tree 1.8190 us/op 1.6720 us/op 1.09
deserialize SyncCommitteeMessage - struct 2.1360 us/op 1.9890 us/op 1.07
deserialize SignedContributionAndProof - tree 3.3720 us/op 3.5690 us/op 0.94
deserialize SignedContributionAndProof - struct 4.8220 us/op 4.6130 us/op 1.05
deserialize SignedBeaconBlock - tree 439.07 us/op 382.12 us/op 1.15
deserialize SignedBeaconBlock - struct 249.18 us/op 238.05 us/op 1.05
BeaconState vc 300000 - deserialize tree 1.1616 s/op 974.51 ms/op 1.19
BeaconState vc 300000 - serialize tree 297.36 ms/op 313.60 ms/op 0.95
BeaconState.historicalRoots vc 300000 - deserialize tree 1.3580 us/op 1.5590 us/op 0.87
BeaconState.historicalRoots vc 300000 - serialize tree 1.4700 us/op 1.8710 us/op 0.79
BeaconState.validators vc 300000 - deserialize tree 1.0967 s/op 987.12 ms/op 1.11
BeaconState.validators vc 300000 - serialize tree 282.55 ms/op 247.78 ms/op 1.14
BeaconState.balances vc 300000 - deserialize tree 42.105 ms/op 37.740 ms/op 1.12
BeaconState.balances vc 300000 - serialize tree 7.2134 ms/op 8.6193 ms/op 0.84
BeaconState.previousEpochParticipation vc 300000 - deserialize tree 1.1081 ms/op 938.32 us/op 1.18
BeaconState.previousEpochParticipation vc 300000 - serialize tree 426.17 us/op 460.71 us/op 0.93
BeaconState.currentEpochParticipation vc 300000 - deserialize tree 1.0874 ms/op 898.59 us/op 1.21
BeaconState.currentEpochParticipation vc 300000 - serialize tree 426.68 us/op 462.90 us/op 0.92
BeaconState.inactivityScores vc 300000 - deserialize tree 44.690 ms/op 41.761 ms/op 1.07
BeaconState.inactivityScores vc 300000 - serialize tree 7.2330 ms/op 7.6936 ms/op 0.94
hashTreeRoot Attestation - struct 59.740 us/op 60.035 us/op 1.00
hashTreeRoot Attestation - tree 32.286 us/op 29.448 us/op 1.10
hashTreeRoot SignedAggregateAndProof - struct 76.875 us/op 74.224 us/op 1.04
hashTreeRoot SignedAggregateAndProof - tree 50.196 us/op 48.736 us/op 1.03
hashTreeRoot SyncCommitteeMessage - struct 17.737 us/op 18.136 us/op 0.98
hashTreeRoot SyncCommitteeMessage - tree 11.017 us/op 10.976 us/op 1.00
hashTreeRoot SignedContributionAndProof - struct 55.652 us/op 50.480 us/op 1.10
hashTreeRoot SignedContributionAndProof - tree 38.824 us/op 24.809 us/op 1.56
hashTreeRoot SignedBeaconBlock - struct 4.2139 ms/op 3.8293 ms/op 1.10
hashTreeRoot SignedBeaconBlock - tree 2.9255 ms/op 2.1951 ms/op 1.33
hashTreeRoot Validator - struct 21.574 us/op 18.989 us/op 1.14
hashTreeRoot Validator - tree 21.050 us/op 16.271 us/op 1.29
BeaconState vc 300000 - hashTreeRoot tree 6.2873 s/op 4.9759 s/op 1.26
BeaconState.historicalRoots vc 300000 - hashTreeRoot tree 2.4710 us/op 2.0400 us/op 1.21
BeaconState.validators vc 300000 - hashTreeRoot tree 5.9927 s/op 4.5920 s/op 1.31
BeaconState.balances vc 300000 - hashTreeRoot tree 143.06 ms/op 110.37 ms/op 1.30
BeaconState.previousEpochParticipation vc 300000 - hashTreeRoot tree 15.935 ms/op 11.893 ms/op 1.34
BeaconState.currentEpochParticipation vc 300000 - hashTreeRoot tree 15.866 ms/op 11.912 ms/op 1.33
BeaconState.inactivityScores vc 300000 - hashTreeRoot tree 147.73 ms/op 109.98 ms/op 1.34
hash64 x18 32.272 us/op 24.534 us/op 1.32
hashTwoObjects x18 30.365 us/op 23.772 us/op 1.28
hash64 x1740 2.9863 ms/op 2.3110 ms/op 1.29
hashTwoObjects x1740 3.0697 ms/op 2.2469 ms/op 1.37
hash64 x2700000 4.7327 s/op 3.5944 s/op 1.32
hashTwoObjects x2700000 4.7723 s/op 3.4860 s/op 1.37
get_exitEpoch - ContainerType 600.00 ns/op 500.00 ns/op 1.20
get_exitEpoch - ContainerNodeStructType 488.00 ns/op 411.00 ns/op 1.19
set_exitEpoch - ContainerType 536.00 ns/op 445.00 ns/op 1.20
set_exitEpoch - ContainerNodeStructType 507.00 ns/op 311.00 ns/op 1.63
get_pubkey - ContainerType 1.7270 us/op 1.8410 us/op 0.94
get_pubkey - ContainerNodeStructType 372.00 ns/op 328.00 ns/op 1.13
hashTreeRoot - ContainerType 540.00 ns/op 513.00 ns/op 1.05
hashTreeRoot - ContainerNodeStructType 645.00 ns/op 620.00 ns/op 1.04
createProof - ContainerType 7.6310 us/op 6.9030 us/op 1.11
createProof - ContainerNodeStructType 41.917 us/op 36.137 us/op 1.16
serialize - ContainerType 3.2900 us/op 3.1360 us/op 1.05
serialize - ContainerNodeStructType 2.6260 us/op 2.6550 us/op 0.99
set_exitEpoch_and_hashTreeRoot - ContainerType 7.4410 us/op 6.0200 us/op 1.24
set_exitEpoch_and_hashTreeRoot - ContainerNodeStructType 19.894 us/op 17.277 us/op 1.15
Array - for of 7.4730 us/op 10.618 us/op 0.70
Array - for(;;) 7.0210 us/op 7.2750 us/op 0.97
basicListValue.readonlyValuesArray() 5.2646 ms/op 6.3135 ms/op 0.83
basicListValue.readonlyValuesArray() + loop all 5.4011 ms/op 6.2604 ms/op 0.86
compositeListValue.readonlyValuesArray() 62.093 ms/op 39.839 ms/op 1.56
compositeListValue.readonlyValuesArray() + loop all 45.552 ms/op 33.621 ms/op 1.35
Number64UintType - get balances list 7.0936 ms/op 6.4240 ms/op 1.10
Number64UintType - set balances list 15.158 ms/op 8.5152 ms/op 1.78
Number64UintType - get and increase 10 then set 69.365 ms/op 61.930 ms/op 1.12
Number64UintType - increase 10 using applyDelta 27.847 ms/op 25.122 ms/op 1.11
Number64UintType - increase 10 using applyDeltaInBatch 26.713 ms/op 24.816 ms/op 1.08
tree_newTreeFromUint64Deltas 29.876 ms/op 26.993 ms/op 1.11
unsafeUint8ArrayToTree 55.500 ms/op 48.532 ms/op 1.14
bitLength(50) 410.00 ns/op 315.00 ns/op 1.30
bitLengthStr(50) 482.00 ns/op 364.00 ns/op 1.32
bitLength(8000) 372.00 ns/op 297.00 ns/op 1.25
bitLengthStr(8000) 595.00 ns/op 495.00 ns/op 1.20
bitLength(250000) 389.00 ns/op 299.00 ns/op 1.30
bitLengthStr(250000) 724.00 ns/op 591.00 ns/op 1.23
floor - Math.floor (53) 0.66613 ns/op 0.67028 ns/op 0.99
floor - << 0 (53) 0.65421 ns/op 0.66995 ns/op 0.98
floor - Math.floor (512) 0.64051 ns/op 0.66995 ns/op 0.96
floor - << 0 (512) 0.65897 ns/op 0.67056 ns/op 0.98
fnIf(0) 2.0642 ns/op 2.6803 ns/op 0.77
fnSwitch(0) 3.1937 ns/op 5.0229 ns/op 0.64
fnObj(0) 0.67656 ns/op 0.67011 ns/op 1.01
fnArr(0) 0.66949 ns/op 0.67031 ns/op 1.00
fnIf(4) 2.9702 ns/op 4.3533 ns/op 0.68
fnSwitch(4) 3.1209 ns/op 5.0243 ns/op 0.62
fnObj(4) 0.65578 ns/op 0.67022 ns/op 0.98
fnArr(4) 0.63548 ns/op 0.67002 ns/op 0.95
fnIf(9) 4.1057 ns/op 6.6984 ns/op 0.61
fnSwitch(9) 3.1502 ns/op 5.0251 ns/op 0.63
fnObj(9) 0.66883 ns/op 0.67017 ns/op 1.00
fnArr(9) 0.65693 ns/op 0.67004 ns/op 0.98
Container {a,b,vec} - as struct x100000 66.610 us/op 67.373 us/op 0.99
Container {a,b,vec} - as tree x100000 651.16 us/op 837.35 us/op 0.78
Container {a,vec,b} - as struct x100000 104.45 us/op 100.85 us/op 1.04
Container {a,vec,b} - as tree x100000 717.87 us/op 904.52 us/op 0.79
get 2 props x1000000 - rawObject 369.17 us/op 335.34 us/op 1.10
get 2 props x1000000 - proxy 125.86 ms/op 133.30 ms/op 0.94
get 2 props x1000000 - customObj 379.00 us/op 335.42 us/op 1.13
Simple object binary -> struct 1.3800 us/op 807.00 ns/op 1.71
Simple object binary -> tree_backed 4.0770 us/op 2.3020 us/op 1.77
Simple object struct -> tree_backed 5.1060 us/op 3.1850 us/op 1.60
Simple object tree_backed -> struct 4.0410 us/op 2.7590 us/op 1.46
Simple object struct -> binary 2.0260 us/op 1.5320 us/op 1.32
Simple object tree_backed -> binary 3.6710 us/op 2.5550 us/op 1.44
aggregationBits binary -> struct 1.3300 us/op 682.00 ns/op 1.95
aggregationBits binary -> tree_backed 4.2640 us/op 3.5780 us/op 1.19
aggregationBits struct -> tree_backed 5.0560 us/op 4.3020 us/op 1.18
aggregationBits tree_backed -> struct 2.0880 us/op 1.7580 us/op 1.19
aggregationBits struct -> binary 1.4520 us/op 1.3930 us/op 1.04
aggregationBits tree_backed -> binary 1.8280 us/op 1.6410 us/op 1.11
List(uint8) 100000 binary -> struct 1.9088 ms/op 2.0065 ms/op 0.95
List(uint8) 100000 binary -> tree_backed 263.14 us/op 174.28 us/op 1.51
List(uint8) 100000 struct -> tree_backed 2.2621 ms/op 2.1842 ms/op 1.04
List(uint8) 100000 tree_backed -> struct 1.4322 ms/op 1.5128 ms/op 0.95
List(uint8) 100000 struct -> binary 2.0355 ms/op 1.9817 ms/op 1.03
List(uint8) 100000 tree_backed -> binary 140.19 us/op 145.48 us/op 0.96
List(uint64Number) 100000 binary -> struct 1.8273 ms/op 1.7804 ms/op 1.03
List(uint64Number) 100000 binary -> tree_backed 6.0089 ms/op 5.6718 ms/op 1.06
List(uint64Number) 100000 struct -> tree_backed 8.5094 ms/op 8.1853 ms/op 1.04
List(uint64Number) 100000 tree_backed -> struct 3.3770 ms/op 3.2270 ms/op 1.05
List(uint64Number) 100000 struct -> binary 2.5467 ms/op 2.3639 ms/op 1.08
List(uint64Number) 100000 tree_backed -> binary 1.5908 ms/op 1.7571 ms/op 0.91
List(Uint64Bigint) 100000 binary -> struct 5.4104 ms/op 5.3400 ms/op 1.01
List(Uint64Bigint) 100000 binary -> tree_backed 6.5867 ms/op 5.7623 ms/op 1.14
List(Uint64Bigint) 100000 struct -> tree_backed 9.4855 ms/op 7.8442 ms/op 1.21
List(Uint64Bigint) 100000 tree_backed -> struct 7.0149 ms/op 7.5143 ms/op 0.93
List(Uint64Bigint) 100000 struct -> binary 3.1858 ms/op 2.9294 ms/op 1.09
List(Uint64Bigint) 100000 tree_backed -> binary 1.3178 ms/op 1.7136 ms/op 0.77
Vector(Root) 100000 binary -> struct 54.234 ms/op 54.834 ms/op 0.99
Vector(Root) 100000 binary -> tree_backed 64.468 ms/op 53.820 ms/op 1.20
Vector(Root) 100000 struct -> tree_backed 76.326 ms/op 62.157 ms/op 1.23
Vector(Root) 100000 tree_backed -> struct 85.701 ms/op 71.775 ms/op 1.19
Vector(Root) 100000 struct -> binary 3.4081 ms/op 3.2295 ms/op 1.06
Vector(Root) 100000 tree_backed -> binary 15.587 ms/op 14.182 ms/op 1.10
List(Validator) 100000 binary -> struct 222.08 ms/op 199.24 ms/op 1.11
List(Validator) 100000 binary -> tree_backed 594.93 ms/op 501.35 ms/op 1.19
List(Validator) 100000 struct -> tree_backed 625.69 ms/op 550.27 ms/op 1.14
List(Validator) 100000 tree_backed -> struct 367.89 ms/op 301.79 ms/op 1.22
List(Validator) 100000 struct -> binary 52.536 ms/op 46.942 ms/op 1.12
List(Validator) 100000 tree_backed -> binary 157.19 ms/op 130.03 ms/op 1.21
List(Validator-NS) 100000 binary -> struct 225.64 ms/op 202.20 ms/op 1.12
List(Validator-NS) 100000 binary -> tree_backed 299.88 ms/op 271.58 ms/op 1.10
List(Validator-NS) 100000 struct -> tree_backed 377.48 ms/op 339.90 ms/op 1.11
List(Validator-NS) 100000 tree_backed -> struct 310.93 ms/op 278.98 ms/op 1.11
List(Validator-NS) 100000 struct -> binary 56.116 ms/op 46.992 ms/op 1.19
List(Validator-NS) 100000 tree_backed -> binary 63.220 ms/op 58.133 ms/op 1.09
get epochStatuses - MutableVector 160.20 us/op 121.25 us/op 1.32
get epochStatuses - ViewDU 307.88 us/op 282.86 us/op 1.09
set epochStatuses - ListTreeView 2.3427 ms/op 2.0098 ms/op 1.17
set epochStatuses - ListTreeView - set() 641.00 us/op 640.88 us/op 1.00
set epochStatuses - ListTreeView - commit() 658.62 us/op 665.75 us/op 0.99
bitstring 836.42 ns/op 747.19 ns/op 1.12
bit mask 16.730 ns/op 12.822 ns/op 1.30
struct - increase slot to 1000000 3.0325 ms/op 2.1871 ms/op 1.39
UintNumberType - increase slot to 1000000 49.001 ms/op 48.941 ms/op 1.00
UintBigintType - increase slot to 1000000 704.22 ms/op 611.71 ms/op 1.15
UintBigint8 x 100000 tree_deserialize 6.9564 ms/op 6.4522 ms/op 1.08
UintBigint8 x 100000 tree_serialize 2.0212 ms/op 2.0394 ms/op 0.99
UintBigint16 x 100000 tree_deserialize 6.7681 ms/op 6.1038 ms/op 1.11
UintBigint16 x 100000 tree_serialize 2.1190 ms/op 2.3474 ms/op 0.90
UintBigint32 x 100000 tree_deserialize 8.3604 ms/op 7.9374 ms/op 1.05
UintBigint32 x 100000 tree_serialize 2.1287 ms/op 2.1402 ms/op 0.99
UintBigint64 x 100000 tree_deserialize 9.3590 ms/op 8.7150 ms/op 1.07
UintBigint64 x 100000 tree_serialize 2.6795 ms/op 2.7988 ms/op 0.96
UintBigint8 x 100000 value_deserialize 691.37 us/op 870.98 us/op 0.79
UintBigint8 x 100000 value_serialize 1.5333 ms/op 1.3244 ms/op 1.16
UintBigint16 x 100000 value_deserialize 685.19 us/op 922.45 us/op 0.74
UintBigint16 x 100000 value_serialize 1.4743 ms/op 1.4251 ms/op 1.03
UintBigint32 x 100000 value_deserialize 675.77 us/op 839.97 us/op 0.80
UintBigint32 x 100000 value_serialize 1.5331 ms/op 1.4453 ms/op 1.06
UintBigint64 x 100000 value_deserialize 754.33 us/op 913.62 us/op 0.83
UintBigint64 x 100000 value_serialize 1.7170 ms/op 1.6269 ms/op 1.06
UintBigint8 x 100000 deserialize 7.2287 ms/op 6.8748 ms/op 1.05
UintBigint8 x 100000 serialize 2.5065 ms/op 2.5228 ms/op 0.99
UintBigint16 x 100000 deserialize 7.3944 ms/op 7.3075 ms/op 1.01
UintBigint16 x 100000 serialize 2.5576 ms/op 2.6098 ms/op 0.98
UintBigint32 x 100000 deserialize 9.2804 ms/op 8.0639 ms/op 1.15
UintBigint32 x 100000 serialize 4.6153 ms/op 4.4691 ms/op 1.03
UintBigint64 x 100000 deserialize 5.8757 ms/op 5.2168 ms/op 1.13
UintBigint64 x 100000 serialize 2.5318 ms/op 2.4943 ms/op 1.02
UintBigint128 x 100000 deserialize 9.9111 ms/op 8.1968 ms/op 1.21
UintBigint128 x 100000 serialize 31.993 ms/op 26.691 ms/op 1.20
UintBigint256 x 100000 deserialize 17.227 ms/op 15.652 ms/op 1.10
UintBigint256 x 100000 serialize 99.239 ms/op 81.861 ms/op 1.21
Slice from Uint8Array x25000 1.8468 ms/op 1.6181 ms/op 1.14
Slice from ArrayBuffer x25000 30.006 ms/op 30.074 ms/op 1.00
Slice from ArrayBuffer x25000 + new Uint8Array 34.451 ms/op 33.244 ms/op 1.04
Copy Uint8Array 100000 iterate 1.0751 ms/op 1.4879 ms/op 0.72
Copy Uint8Array 100000 slice 196.38 us/op 348.27 us/op 0.56
Copy Uint8Array 100000 Uint8Array.prototype.slice.call 194.87 us/op 352.30 us/op 0.55
Copy Buffer 100000 Uint8Array.prototype.slice.call 184.36 us/op 346.86 us/op 0.53
Copy Uint8Array 100000 slice + set 350.06 us/op 670.58 us/op 0.52
Copy Uint8Array 100000 subarray + set 189.15 us/op 359.64 us/op 0.53
Copy Uint8Array 100000 slice arrayBuffer 189.21 us/op 328.42 us/op 0.58
Uint64 deserialize 100000 - iterate Uint8Array 2.4509 ms/op 2.2743 ms/op 1.08
Uint64 deserialize 100000 - by Uint32A 2.3030 ms/op 2.1436 ms/op 1.07
Uint64 deserialize 100000 - by DataView.getUint32 x2 2.2801 ms/op 2.2140 ms/op 1.03
Uint64 deserialize 100000 - by DataView.getBigUint64 7.3229 ms/op 6.7712 ms/op 1.08
Uint64 deserialize 100000 - by byte 73.839 ms/op 69.150 ms/op 1.07

Please sign in to comment.