Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: migrate logger tests to vitest #6220

Merged
merged 3 commits into from
Dec 26, 2023
Merged

Conversation

nazarhussain
Copy link
Contributor

Motivation

Consolidate the testing frameworks and migrate to vitest.

Description

Migrate logger tests to vitest.

Steps to test or reproduce

  • Run all tests

@nazarhussain nazarhussain self-assigned this Dec 21, 2023
@nazarhussain nazarhussain requested a review from a team as a code owner December 21, 2023 10:07
import {expose} from "@chainsafe/threads/worker";

const parentPort = worker.parentPort;
const workerData = worker.workerData as {logFilepath: string};
const workerData = worker.workerData;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Have to convert this TS file to JS as Worker can only load the JS files. Earlier this was handled by runtime compilation with global node loader.

logger.restoreStubs();
expect(logger.getLogs()).deep.equals([output[format]]);

expect((console as TestConsole)._stdout.write).toHaveBeenNthCalledWith(1, `${output[format]}\n`);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The last \n added in expectation, which was earlier removed by stubLoggerForProcessStd.

Copy link

codecov bot commented Dec 21, 2023

Codecov Report

Merging #6220 (57183de) into unstable (2530fae) will not change coverage.
The diff coverage is n/a.

Additional details and impacted files
@@            Coverage Diff            @@
##           unstable    #6220   +/-   ##
=========================================
  Coverage     84.46%   84.46%           
=========================================
  Files           177      177           
  Lines         14913    14913           
  Branches        909      909           
=========================================
  Hits          12596    12596           
  Misses         2294     2294           
  Partials         23       23           

Copy link
Contributor

github-actions bot commented Dec 21, 2023

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: 802169d Previous: 2530fae Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 729.96 us/op 391.97 us/op 1.86
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 86.531 us/op 56.089 us/op 1.54
BLS verify - blst-native 1.3085 ms/op 1.1020 ms/op 1.19
BLS verifyMultipleSignatures 3 - blst-native 2.7407 ms/op 2.2812 ms/op 1.20
BLS verifyMultipleSignatures 8 - blst-native 6.0680 ms/op 5.0032 ms/op 1.21
BLS verifyMultipleSignatures 32 - blst-native 22.254 ms/op 18.692 ms/op 1.19
BLS verifyMultipleSignatures 64 - blst-native 43.851 ms/op 36.461 ms/op 1.20
BLS verifyMultipleSignatures 128 - blst-native 87.490 ms/op 75.582 ms/op 1.16
BLS deserializing 10000 signatures 950.07 ms/op 790.63 ms/op 1.20
BLS deserializing 100000 signatures 9.7090 s/op 8.0558 s/op 1.21
BLS verifyMultipleSignatures - same message - 3 - blst-native 1.4439 ms/op 1.1746 ms/op 1.23
BLS verifyMultipleSignatures - same message - 8 - blst-native 1.5665 ms/op 1.3177 ms/op 1.19
BLS verifyMultipleSignatures - same message - 32 - blst-native 2.4157 ms/op 2.1175 ms/op 1.14
BLS verifyMultipleSignatures - same message - 64 - blst-native 3.5424 ms/op 3.2463 ms/op 1.09
BLS verifyMultipleSignatures - same message - 128 - blst-native 5.8108 ms/op 6.8566 ms/op 0.85
BLS aggregatePubkeys 32 - blst-native 26.946 us/op 23.949 us/op 1.13
BLS aggregatePubkeys 128 - blst-native 106.39 us/op 85.627 us/op 1.24
getAttestationsForBlock 58.474 ms/op 39.689 ms/op 1.47
getSlashingsAndExits - default max 230.55 us/op 94.766 us/op 2.43
getSlashingsAndExits - 2k 454.93 us/op 402.02 us/op 1.13
proposeBlockBody type=full, size=empty 6.2108 ms/op 4.0703 ms/op 1.53
isKnown best case - 1 super set check 337.00 ns/op 331.00 ns/op 1.02
isKnown normal case - 2 super set checks 321.00 ns/op 321.00 ns/op 1.00
isKnown worse case - 16 super set checks 321.00 ns/op 331.00 ns/op 0.97
CheckpointStateCache - add get delete 5.7980 us/op 3.6920 us/op 1.57
validate api signedAggregateAndProof - struct 2.9228 ms/op 2.5660 ms/op 1.14
validate gossip signedAggregateAndProof - struct 2.9252 ms/op 2.5464 ms/op 1.15
validate gossip attestation - vc 640000 1.4103 ms/op 1.1868 ms/op 1.19
batch validate gossip attestation - vc 640000 - chunk 32 170.77 us/op 146.65 us/op 1.16
batch validate gossip attestation - vc 640000 - chunk 64 150.71 us/op 124.32 us/op 1.21
batch validate gossip attestation - vc 640000 - chunk 128 150.43 us/op 118.70 us/op 1.27
batch validate gossip attestation - vc 640000 - chunk 256 137.60 us/op 113.37 us/op 1.21
pickEth1Vote - no votes 1.2417 ms/op 924.25 us/op 1.34
pickEth1Vote - max votes 8.3145 ms/op 13.091 ms/op 0.64
pickEth1Vote - Eth1Data hashTreeRoot value x2048 16.077 ms/op 23.765 ms/op 0.68
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 27.326 ms/op 23.761 ms/op 1.15
pickEth1Vote - Eth1Data fastSerialize value x2048 632.95 us/op 513.03 us/op 1.23
pickEth1Vote - Eth1Data fastSerialize tree x2048 5.3551 ms/op 4.4490 ms/op 1.20
bytes32 toHexString 558.00 ns/op 670.00 ns/op 0.83
bytes32 Buffer.toString(hex) 297.00 ns/op 354.00 ns/op 0.84
bytes32 Buffer.toString(hex) from Uint8Array 464.00 ns/op 520.00 ns/op 0.89
bytes32 Buffer.toString(hex) + 0x 300.00 ns/op 321.00 ns/op 0.93
Object access 1 prop 0.16900 ns/op 0.21000 ns/op 0.80
Map access 1 prop 0.14400 ns/op 0.20100 ns/op 0.72
Object get x1000 7.9060 ns/op 5.8160 ns/op 1.36
Map get x1000 0.78600 ns/op 0.73300 ns/op 1.07
Object set x1000 53.409 ns/op 28.161 ns/op 1.90
Map set x1000 39.626 ns/op 17.542 ns/op 2.26
Return object 10000 times 0.24740 ns/op 0.22640 ns/op 1.09
Throw Error 10000 times 4.0056 us/op 2.7868 us/op 1.44
fastMsgIdFn sha256 / 200 bytes 3.4110 us/op 1.9390 us/op 1.76
fastMsgIdFn h32 xxhash / 200 bytes 290.00 ns/op 299.00 ns/op 0.97
fastMsgIdFn h64 xxhash / 200 bytes 371.00 ns/op 344.00 ns/op 1.08
fastMsgIdFn sha256 / 1000 bytes 11.808 us/op 6.2100 us/op 1.90
fastMsgIdFn h32 xxhash / 1000 bytes 458.00 ns/op 405.00 ns/op 1.13
fastMsgIdFn h64 xxhash / 1000 bytes 453.00 ns/op 405.00 ns/op 1.12
fastMsgIdFn sha256 / 10000 bytes 106.55 us/op 52.287 us/op 2.04
fastMsgIdFn h32 xxhash / 10000 bytes 2.0440 us/op 1.7810 us/op 1.15
fastMsgIdFn h64 xxhash / 10000 bytes 1.4010 us/op 1.2210 us/op 1.15
send data - 1000 256B messages 20.634 ms/op 11.508 ms/op 1.79
send data - 1000 512B messages 27.093 ms/op 14.913 ms/op 1.82
send data - 1000 1024B messages 41.790 ms/op 23.158 ms/op 1.80
send data - 1000 1200B messages 40.191 ms/op 28.532 ms/op 1.41
send data - 1000 2048B messages 42.354 ms/op 36.292 ms/op 1.17
send data - 1000 4096B messages 45.306 ms/op 31.335 ms/op 1.45
send data - 1000 16384B messages 123.16 ms/op 92.439 ms/op 1.33
send data - 1000 65536B messages 477.47 ms/op 422.93 ms/op 1.13
enrSubnets - fastDeserialize 64 bits 1.7950 us/op 976.00 ns/op 1.84
enrSubnets - ssz BitVector 64 bits 538.00 ns/op 411.00 ns/op 1.31
enrSubnets - fastDeserialize 4 bits 225.00 ns/op 201.00 ns/op 1.12
enrSubnets - ssz BitVector 4 bits 547.00 ns/op 416.00 ns/op 1.31
prioritizePeers score -10:0 att 32-0.1 sync 2-0 122.87 us/op 69.770 us/op 1.76
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 158.92 us/op 77.468 us/op 2.05
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 189.42 us/op 102.49 us/op 1.85
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 345.50 us/op 179.67 us/op 1.92
prioritizePeers score 0:0 att 64-1 sync 4-1 375.42 us/op 203.80 us/op 1.84
array of 16000 items push then shift 1.7580 us/op 1.2761 us/op 1.38
LinkedList of 16000 items push then shift 9.3550 ns/op 5.9540 ns/op 1.57
array of 16000 items push then pop 107.62 ns/op 57.390 ns/op 1.88
LinkedList of 16000 items push then pop 9.0140 ns/op 5.6330 ns/op 1.60
array of 24000 items push then shift 2.4798 us/op 1.8935 us/op 1.31
LinkedList of 24000 items push then shift 9.0700 ns/op 5.7590 ns/op 1.57
array of 24000 items push then pop 152.29 ns/op 76.674 ns/op 1.99
LinkedList of 24000 items push then pop 8.7340 ns/op 5.6860 ns/op 1.54
intersect bitArray bitLen 8 6.5240 ns/op 5.0550 ns/op 1.29
intersect array and set length 8 70.929 ns/op 49.177 ns/op 1.44
intersect bitArray bitLen 128 34.427 ns/op 27.571 ns/op 1.25
intersect array and set length 128 988.13 ns/op 686.06 ns/op 1.44
bitArray.getTrueBitIndexes() bitLen 128 1.5530 us/op 1.1500 us/op 1.35
bitArray.getTrueBitIndexes() bitLen 248 2.7770 us/op 1.8300 us/op 1.52
bitArray.getTrueBitIndexes() bitLen 512 5.2510 us/op 3.4360 us/op 1.53
Buffer.concat 32 items 992.00 ns/op 838.00 ns/op 1.18
Uint8Array.set 32 items 2.1490 us/op 1.5860 us/op 1.35
Set add up to 64 items then delete first 5.1913 us/op 1.7346 us/op 2.99
OrderedSet add up to 64 items then delete first 6.8499 us/op 2.6479 us/op 2.59
Set add up to 64 items then delete last 5.4807 us/op 1.9891 us/op 2.76
OrderedSet add up to 64 items then delete last 7.1599 us/op 2.9662 us/op 2.41
Set add up to 64 items then delete middle 5.3514 us/op 1.9838 us/op 2.70
OrderedSet add up to 64 items then delete middle 8.3141 us/op 4.1603 us/op 2.00
Set add up to 128 items then delete first 10.872 us/op 3.9154 us/op 2.78
OrderedSet add up to 128 items then delete first 14.563 us/op 6.1481 us/op 2.37
Set add up to 128 items then delete last 10.864 us/op 3.7722 us/op 2.88
OrderedSet add up to 128 items then delete last 14.443 us/op 5.7034 us/op 2.53
Set add up to 128 items then delete middle 10.879 us/op 3.7910 us/op 2.87
OrderedSet add up to 128 items then delete middle 20.144 us/op 10.672 us/op 1.89
Set add up to 256 items then delete first 22.162 us/op 7.6162 us/op 2.91
OrderedSet add up to 256 items then delete first 30.231 us/op 12.176 us/op 2.48
Set add up to 256 items then delete last 21.289 us/op 7.4153 us/op 2.87
OrderedSet add up to 256 items then delete last 26.290 us/op 11.342 us/op 2.32
Set add up to 256 items then delete middle 21.011 us/op 7.3950 us/op 2.84
OrderedSet add up to 256 items then delete middle 50.927 us/op 30.140 us/op 1.69
transfer serialized Status (84 B) 1.8130 us/op 1.3580 us/op 1.34
copy serialized Status (84 B) 1.6440 us/op 1.1650 us/op 1.41
transfer serialized SignedVoluntaryExit (112 B) 1.9670 us/op 1.3710 us/op 1.43
copy serialized SignedVoluntaryExit (112 B) 1.7260 us/op 1.1720 us/op 1.47
transfer serialized ProposerSlashing (416 B) 2.3530 us/op 1.5180 us/op 1.55
copy serialized ProposerSlashing (416 B) 2.2200 us/op 1.3720 us/op 1.62
transfer serialized Attestation (485 B) 3.0790 us/op 1.5680 us/op 1.96
copy serialized Attestation (485 B) 2.6940 us/op 1.3820 us/op 1.95
transfer serialized AttesterSlashing (33232 B) 3.1570 us/op 1.6410 us/op 1.92
copy serialized AttesterSlashing (33232 B) 12.811 us/op 3.4760 us/op 3.69
transfer serialized Small SignedBeaconBlock (128000 B) 2.8700 us/op 1.7240 us/op 1.66
copy serialized Small SignedBeaconBlock (128000 B) 20.949 us/op 8.3810 us/op 2.50
transfer serialized Avg SignedBeaconBlock (200000 B) 3.5620 us/op 1.9190 us/op 1.86
copy serialized Avg SignedBeaconBlock (200000 B) 26.637 us/op 12.711 us/op 2.10
transfer serialized BlobsSidecar (524380 B) 3.8320 us/op 2.2330 us/op 1.72
copy serialized BlobsSidecar (524380 B) 230.93 us/op 78.101 us/op 2.96
transfer serialized Big SignedBeaconBlock (1000000 B) 4.1110 us/op 2.6970 us/op 1.52
copy serialized Big SignedBeaconBlock (1000000 B) 211.38 us/op 195.67 us/op 1.08
pass gossip attestations to forkchoice per slot 3.9861 ms/op 2.7362 ms/op 1.46
forkChoice updateHead vc 100000 bc 64 eq 0 735.90 us/op 491.32 us/op 1.50
forkChoice updateHead vc 600000 bc 64 eq 0 4.6280 ms/op 2.7156 ms/op 1.70
forkChoice updateHead vc 1000000 bc 64 eq 0 8.1448 ms/op 4.4277 ms/op 1.84
forkChoice updateHead vc 600000 bc 320 eq 0 4.3992 ms/op 2.6223 ms/op 1.68
forkChoice updateHead vc 600000 bc 1200 eq 0 4.9639 ms/op 2.6921 ms/op 1.84
forkChoice updateHead vc 600000 bc 7200 eq 0 5.9982 ms/op 3.5379 ms/op 1.70
forkChoice updateHead vc 600000 bc 64 eq 1000 11.613 ms/op 10.063 ms/op 1.15
forkChoice updateHead vc 600000 bc 64 eq 10000 12.212 ms/op 9.7239 ms/op 1.26
forkChoice updateHead vc 600000 bc 64 eq 300000 21.350 ms/op 11.895 ms/op 1.79
computeDeltas 500000 validators 300 proto nodes 7.0301 ms/op 3.0617 ms/op 2.30
computeDeltas 500000 validators 1200 proto nodes 7.1235 ms/op 2.9465 ms/op 2.42
computeDeltas 500000 validators 7200 proto nodes 6.9981 ms/op 3.0148 ms/op 2.32
computeDeltas 750000 validators 300 proto nodes 10.373 ms/op 4.7349 ms/op 2.19
computeDeltas 750000 validators 1200 proto nodes 12.312 ms/op 4.7388 ms/op 2.60
computeDeltas 750000 validators 7200 proto nodes 11.444 ms/op 4.5791 ms/op 2.50
computeDeltas 1400000 validators 300 proto nodes 21.586 ms/op 9.4619 ms/op 2.28
computeDeltas 1400000 validators 1200 proto nodes 21.045 ms/op 8.9484 ms/op 2.35
computeDeltas 1400000 validators 7200 proto nodes 21.712 ms/op 9.1763 ms/op 2.37
computeDeltas 2100000 validators 300 proto nodes 30.440 ms/op 13.958 ms/op 2.18
computeDeltas 2100000 validators 1200 proto nodes 31.392 ms/op 13.560 ms/op 2.32
computeDeltas 2100000 validators 7200 proto nodes 29.698 ms/op 13.674 ms/op 2.17
computeProposerBoostScoreFromBalances 500000 validators 3.9987 ms/op 3.2580 ms/op 1.23
computeProposerBoostScoreFromBalances 750000 validators 3.9250 ms/op 3.2912 ms/op 1.19
computeProposerBoostScoreFromBalances 1400000 validators 3.9691 ms/op 3.2024 ms/op 1.24
computeProposerBoostScoreFromBalances 2100000 validators 4.0878 ms/op 3.2294 ms/op 1.27
altair processAttestation - 250000 vs - 7PWei normalcase 3.5503 ms/op 1.6979 ms/op 2.09
altair processAttestation - 250000 vs - 7PWei worstcase 4.7193 ms/op 2.8145 ms/op 1.68
altair processAttestation - setStatus - 1/6 committees join 162.80 us/op 122.77 us/op 1.33
altair processAttestation - setStatus - 1/3 committees join 343.38 us/op 210.54 us/op 1.63
altair processAttestation - setStatus - 1/2 committees join 468.67 us/op 364.88 us/op 1.28
altair processAttestation - setStatus - 2/3 committees join 563.30 us/op 404.38 us/op 1.39
altair processAttestation - setStatus - 4/5 committees join 735.26 us/op 691.76 us/op 1.06
altair processAttestation - setStatus - 100% committees join 831.36 us/op 647.73 us/op 1.28
altair processBlock - 250000 vs - 7PWei normalcase 11.294 ms/op 12.047 ms/op 0.94
altair processBlock - 250000 vs - 7PWei normalcase hashState 40.654 ms/op 40.059 ms/op 1.01
altair processBlock - 250000 vs - 7PWei worstcase 44.722 ms/op 49.499 ms/op 0.90
altair processBlock - 250000 vs - 7PWei worstcase hashState 97.269 ms/op 136.43 ms/op 0.71
phase0 processBlock - 250000 vs - 7PWei normalcase 3.6575 ms/op 4.0689 ms/op 0.90
phase0 processBlock - 250000 vs - 7PWei worstcase 34.860 ms/op 34.489 ms/op 1.01
altair processEth1Data - 250000 vs - 7PWei normalcase 705.67 us/op 750.49 us/op 0.94
getExpectedWithdrawals 250000 eb:1,eth1:1,we:0,wn:0,smpl:15 16.112 us/op 5.4010 us/op 2.98
getExpectedWithdrawals 250000 eb:0.95,eth1:0.1,we:0.05,wn:0,smpl:219 48.581 us/op 52.845 us/op 0.92
getExpectedWithdrawals 250000 eb:0.95,eth1:0.3,we:0.05,wn:0,smpl:42 21.184 us/op 14.676 us/op 1.44
getExpectedWithdrawals 250000 eb:0.95,eth1:0.7,we:0.05,wn:0,smpl:18 23.300 us/op 9.1200 us/op 2.55
getExpectedWithdrawals 250000 eb:0.1,eth1:0.1,we:0,wn:0,smpl:1020 241.32 us/op 154.45 us/op 1.56
getExpectedWithdrawals 250000 eb:0.03,eth1:0.03,we:0,wn:0,smpl:11777 1.7908 ms/op 1.5432 ms/op 1.16
getExpectedWithdrawals 250000 eb:0.01,eth1:0.01,we:0,wn:0,smpl:16384 2.2137 ms/op 1.0401 ms/op 2.13
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,smpl:16384 2.0847 ms/op 1.4502 ms/op 1.44
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,nocache,smpl:16384 4.3195 ms/op 2.2438 ms/op 1.93
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,smpl:16384 3.1845 ms/op 1.7352 ms/op 1.84
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,nocache,smpl:16384 7.3874 ms/op 3.3702 ms/op 2.19
Tree 40 250000 create 500.14 ms/op 272.28 ms/op 1.84
Tree 40 250000 get(125000) 215.46 ns/op 105.15 ns/op 2.05
Tree 40 250000 set(125000) 1.9478 us/op 732.16 ns/op 2.66
Tree 40 250000 toArray() 25.396 ms/op 14.880 ms/op 1.71
Tree 40 250000 iterate all - toArray() + loop 29.635 ms/op 14.651 ms/op 2.02
Tree 40 250000 iterate all - get(i) 79.682 ms/op 40.548 ms/op 1.97
MutableVector 250000 create 18.790 ms/op 11.686 ms/op 1.61
MutableVector 250000 get(125000) 7.4240 ns/op 5.3550 ns/op 1.39
MutableVector 250000 set(125000) 605.38 ns/op 196.76 ns/op 3.08
MutableVector 250000 toArray() 6.9330 ms/op 2.5651 ms/op 2.70
MutableVector 250000 iterate all - toArray() + loop 5.1962 ms/op 2.7324 ms/op 1.90
MutableVector 250000 iterate all - get(i) 1.6833 ms/op 1.3298 ms/op 1.27
Array 250000 create 4.3105 ms/op 2.3689 ms/op 1.82
Array 250000 clone - spread 1.4017 ms/op 9.1842 ms/op 0.15
Array 250000 get(125000) 1.3460 ns/op 1.0410 ns/op 1.29
Array 250000 set(125000) 5.2110 ns/op 1.1490 ns/op 4.54
Array 250000 iterate all - loop 174.30 us/op 147.23 us/op 1.18
effectiveBalanceIncrements clone Uint8Array 300000 47.210 us/op 18.699 us/op 2.52
effectiveBalanceIncrements clone MutableVector 300000 428.00 ns/op 352.00 ns/op 1.22
effectiveBalanceIncrements rw all Uint8Array 300000 234.81 us/op 176.45 us/op 1.33
effectiveBalanceIncrements rw all MutableVector 300000 104.94 ms/op 61.459 ms/op 1.71
phase0 afterProcessEpoch - 250000 vs - 7PWei 123.71 ms/op 77.303 ms/op 1.60
phase0 beforeProcessEpoch - 250000 vs - 7PWei 62.140 ms/op 44.584 ms/op 1.39
altair processEpoch - mainnet_e81889 555.53 ms/op 428.32 ms/op 1.30
mainnet_e81889 - altair beforeProcessEpoch 90.890 ms/op 74.221 ms/op 1.22
mainnet_e81889 - altair processJustificationAndFinalization 20.343 us/op 10.411 us/op 1.95
mainnet_e81889 - altair processInactivityUpdates 7.1933 ms/op 5.9123 ms/op 1.22
mainnet_e81889 - altair processRewardsAndPenalties 72.136 ms/op 58.935 ms/op 1.22
mainnet_e81889 - altair processRegistryUpdates 3.4590 us/op 2.5700 us/op 1.35
mainnet_e81889 - altair processSlashings 543.00 ns/op 601.00 ns/op 0.90
mainnet_e81889 - altair processEth1DataReset 714.00 ns/op 571.00 ns/op 1.25
mainnet_e81889 - altair processEffectiveBalanceUpdates 1.7574 ms/op 1.7600 ms/op 1.00
mainnet_e81889 - altair processSlashingsReset 4.4710 us/op 2.4930 us/op 1.79
mainnet_e81889 - altair processRandaoMixesReset 6.2100 us/op 2.8330 us/op 2.19
mainnet_e81889 - altair processHistoricalRootsUpdate 849.00 ns/op 649.00 ns/op 1.31
mainnet_e81889 - altair processParticipationFlagUpdates 2.0610 us/op 1.4530 us/op 1.42
mainnet_e81889 - altair processSyncCommitteeUpdates 962.00 ns/op 532.00 ns/op 1.81
mainnet_e81889 - altair afterProcessEpoch 123.74 ms/op 80.565 ms/op 1.54
capella processEpoch - mainnet_e217614 2.4579 s/op 2.2132 s/op 1.11
mainnet_e217614 - capella beforeProcessEpoch 550.48 ms/op 429.03 ms/op 1.28
mainnet_e217614 - capella processJustificationAndFinalization 16.543 us/op 11.791 us/op 1.40
mainnet_e217614 - capella processInactivityUpdates 18.023 ms/op 19.446 ms/op 0.93
mainnet_e217614 - capella processRewardsAndPenalties 451.09 ms/op 383.38 ms/op 1.18
mainnet_e217614 - capella processRegistryUpdates 32.873 us/op 13.682 us/op 2.40
mainnet_e217614 - capella processSlashings 1.0050 us/op 591.00 ns/op 1.70
mainnet_e217614 - capella processEth1DataReset 822.00 ns/op 628.00 ns/op 1.31
mainnet_e217614 - capella processEffectiveBalanceUpdates 10.939 ms/op 3.4986 ms/op 3.13
mainnet_e217614 - capella processSlashingsReset 4.4190 us/op 3.0990 us/op 1.43
mainnet_e217614 - capella processRandaoMixesReset 8.9930 us/op 8.2410 us/op 1.09
mainnet_e217614 - capella processHistoricalRootsUpdate 978.00 ns/op 793.00 ns/op 1.23
mainnet_e217614 - capella processParticipationFlagUpdates 2.3420 us/op 1.3540 us/op 1.73
mainnet_e217614 - capella afterProcessEpoch 353.07 ms/op 227.97 ms/op 1.55
phase0 processEpoch - mainnet_e58758 515.19 ms/op 415.10 ms/op 1.24
mainnet_e58758 - phase0 beforeProcessEpoch 141.91 ms/op 142.03 ms/op 1.00
mainnet_e58758 - phase0 processJustificationAndFinalization 17.664 us/op 16.703 us/op 1.06
mainnet_e58758 - phase0 processRewardsAndPenalties 45.275 ms/op 47.537 ms/op 0.95
mainnet_e58758 - phase0 processRegistryUpdates 13.588 us/op 9.0180 us/op 1.51
mainnet_e58758 - phase0 processSlashings 484.00 ns/op 978.00 ns/op 0.49
mainnet_e58758 - phase0 processEth1DataReset 784.00 ns/op 640.00 ns/op 1.23
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 1.4008 ms/op 969.53 us/op 1.44
mainnet_e58758 - phase0 processSlashingsReset 5.9260 us/op 4.1260 us/op 1.44
mainnet_e58758 - phase0 processRandaoMixesReset 5.6920 us/op 4.2310 us/op 1.35
mainnet_e58758 - phase0 processHistoricalRootsUpdate 645.00 ns/op 997.00 ns/op 0.65
mainnet_e58758 - phase0 processParticipationRecordUpdates 4.3750 us/op 5.0010 us/op 0.87
mainnet_e58758 - phase0 afterProcessEpoch 104.22 ms/op 68.392 ms/op 1.52
phase0 processEffectiveBalanceUpdates - 250000 normalcase 1.6853 ms/op 1.2471 ms/op 1.35
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 2.4365 ms/op 1.2880 ms/op 1.89
altair processInactivityUpdates - 250000 normalcase 38.229 ms/op 30.384 ms/op 1.26
altair processInactivityUpdates - 250000 worstcase 39.210 ms/op 26.847 ms/op 1.46
phase0 processRegistryUpdates - 250000 normalcase 13.983 us/op 11.336 us/op 1.23
phase0 processRegistryUpdates - 250000 badcase_full_deposits 682.96 us/op 391.91 us/op 1.74
phase0 processRegistryUpdates - 250000 worstcase 0.5 168.64 ms/op 114.00 ms/op 1.48
altair processRewardsAndPenalties - 250000 normalcase 70.694 ms/op 41.015 ms/op 1.72
altair processRewardsAndPenalties - 250000 worstcase 62.775 ms/op 54.871 ms/op 1.14
phase0 getAttestationDeltas - 250000 normalcase 10.304 ms/op 5.9943 ms/op 1.72
phase0 getAttestationDeltas - 250000 worstcase 11.237 ms/op 8.3034 ms/op 1.35
phase0 processSlashings - 250000 worstcase 98.992 us/op 84.615 us/op 1.17
altair processSyncCommitteeUpdates - 250000 162.38 ms/op 127.03 ms/op 1.28
BeaconState.hashTreeRoot - No change 295.00 ns/op 447.00 ns/op 0.66
BeaconState.hashTreeRoot - 1 full validator 192.15 us/op 130.44 us/op 1.47
BeaconState.hashTreeRoot - 32 full validator 1.8382 ms/op 1.4590 ms/op 1.26
BeaconState.hashTreeRoot - 512 full validator 19.267 ms/op 18.472 ms/op 1.04
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 165.82 us/op 150.25 us/op 1.10
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 2.4776 ms/op 2.0279 ms/op 1.22
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 36.894 ms/op 32.852 ms/op 1.12
BeaconState.hashTreeRoot - 1 balances 180.06 us/op 118.80 us/op 1.52
BeaconState.hashTreeRoot - 32 balances 1.9253 ms/op 1.1455 ms/op 1.68
BeaconState.hashTreeRoot - 512 balances 15.689 ms/op 10.696 ms/op 1.47
BeaconState.hashTreeRoot - 250000 balances 247.60 ms/op 192.93 ms/op 1.28
aggregationBits - 2048 els - zipIndexesInBitList 34.347 us/op 10.749 us/op 3.20
byteArrayEquals 32 83.784 ns/op 65.390 ns/op 1.28
Buffer.compare 32 64.042 ns/op 39.177 ns/op 1.63
byteArrayEquals 1024 2.2822 us/op 1.7661 us/op 1.29
Buffer.compare 1024 101.63 ns/op 47.677 ns/op 2.13
byteArrayEquals 16384 36.470 us/op 28.330 us/op 1.29
Buffer.compare 16384 263.96 ns/op 223.57 ns/op 1.18
byteArrayEquals 123687377 258.54 ms/op 206.09 ms/op 1.25
Buffer.compare 123687377 8.8357 ms/op 7.7511 ms/op 1.14
byteArrayEquals 32 - diff last byte 75.082 ns/op 65.340 ns/op 1.15
Buffer.compare 32 - diff last byte 69.562 ns/op 42.034 ns/op 1.65
byteArrayEquals 1024 - diff last byte 2.2143 us/op 1.9043 us/op 1.16
Buffer.compare 1024 - diff last byte 83.117 ns/op 48.633 ns/op 1.71
byteArrayEquals 16384 - diff last byte 34.197 us/op 27.886 us/op 1.23
Buffer.compare 16384 - diff last byte 290.47 ns/op 241.23 ns/op 1.20
byteArrayEquals 123687377 - diff last byte 261.85 ms/op 213.52 ms/op 1.23
Buffer.compare 123687377 - diff last byte 7.4993 ms/op 6.4727 ms/op 1.16
byteArrayEquals 32 - random bytes 5.6800 ns/op 5.3600 ns/op 1.06
Buffer.compare 32 - random bytes 63.859 ns/op 39.720 ns/op 1.61
byteArrayEquals 1024 - random bytes 6.1430 ns/op 5.0070 ns/op 1.23
Buffer.compare 1024 - random bytes 62.760 ns/op 37.014 ns/op 1.70
byteArrayEquals 16384 - random bytes 5.9750 ns/op 4.9680 ns/op 1.20
Buffer.compare 16384 - random bytes 62.781 ns/op 36.888 ns/op 1.70
byteArrayEquals 123687377 - random bytes 9.1600 ns/op 8.1300 ns/op 1.13
Buffer.compare 123687377 - random bytes 65.940 ns/op 39.220 ns/op 1.68
regular array get 100000 times 48.170 us/op 41.615 us/op 1.16
wrappedArray get 100000 times 47.770 us/op 41.354 us/op 1.16
arrayWithProxy get 100000 times 14.641 ms/op 9.2633 ms/op 1.58
ssz.Root.equals 56.206 ns/op 55.729 ns/op 1.01
byteArrayEquals 56.603 ns/op 53.145 ns/op 1.07
Buffer.compare 11.859 ns/op 9.8420 ns/op 1.20
shuffle list - 16384 els 7.2985 ms/op 4.7429 ms/op 1.54
shuffle list - 250000 els 107.28 ms/op 71.127 ms/op 1.51
processSlot - 1 slots 17.608 us/op 15.393 us/op 1.14
processSlot - 32 slots 3.0870 ms/op 2.8292 ms/op 1.09
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 64.222 ms/op 52.256 ms/op 1.23
getCommitteeAssignments - req 1 vs - 250000 vc 2.7085 ms/op 2.2709 ms/op 1.19
getCommitteeAssignments - req 100 vs - 250000 vc 3.9469 ms/op 3.2926 ms/op 1.20
getCommitteeAssignments - req 1000 vs - 250000 vc 4.3836 ms/op 3.7173 ms/op 1.18
findModifiedValidators - 10000 modified validators 625.32 ms/op 433.44 ms/op 1.44
findModifiedValidators - 1000 modified validators 674.66 ms/op 334.49 ms/op 2.02
findModifiedValidators - 100 modified validators 560.90 ms/op 298.28 ms/op 1.88
findModifiedValidators - 10 modified validators 532.41 ms/op 343.26 ms/op 1.55
findModifiedValidators - 1 modified validators 540.02 ms/op 300.73 ms/op 1.80
findModifiedValidators - no difference 548.08 ms/op 286.71 ms/op 1.91
compare ViewDUs 6.6927 s/op 3.9242 s/op 1.71
compare each validator Uint8Array 2.5291 s/op 1.9307 s/op 1.31
compare ViewDU to Uint8Array 1.7667 s/op 786.47 ms/op 2.25
migrate state 1000000 validators, 24 modified, 0 new 1.2106 s/op 748.66 ms/op 1.62
migrate state 1000000 validators, 1700 modified, 1000 new 1.4152 s/op 941.61 ms/op 1.50
migrate state 1000000 validators, 3400 modified, 2000 new 1.6113 s/op 1.1895 s/op 1.35
migrate state 1500000 validators, 24 modified, 0 new 846.33 ms/op 711.67 ms/op 1.19
migrate state 1500000 validators, 1700 modified, 1000 new 1.1260 s/op 931.91 ms/op 1.21
migrate state 1500000 validators, 3400 modified, 2000 new 1.3835 s/op 1.0465 s/op 1.32
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 4.3200 ns/op 4.3100 ns/op 1.00
state getBlockRootAtSlot - 250000 vs - 7PWei 533.99 ns/op 405.66 ns/op 1.32
computeProposers - vc 250000 9.2871 ms/op 6.1354 ms/op 1.51
computeEpochShuffling - vc 250000 106.74 ms/op 70.765 ms/op 1.51
getNextSyncCommittee - vc 250000 156.39 ms/op 113.51 ms/op 1.38
computeSigningRoot for AttestationData 26.671 us/op 26.077 us/op 1.02
hash AttestationData serialized data then Buffer.toString(base64) 2.4628 us/op 1.2731 us/op 1.93
toHexString serialized data 1.1228 us/op 794.82 ns/op 1.41
Buffer.toString(base64) 225.90 ns/op 152.03 ns/op 1.49

by benchmarkbot/action

@nazarhussain nazarhussain requested a review from nflaig December 21, 2023 14:01
@@ -27,13 +25,13 @@ describe("Json helper", () => {

// Functions
// eslint-disable-next-line @typescript-eslint/no-empty-function
{id: "function", arg: function () {}, json: "function () { }"},
{id: "function", arg: function () {}, json: "function() {\n }"},
Copy link
Member

Choose a reason for hiding this comment

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

I don't really get from where the line breaks are coming

Function toString() does not seem to add them

case "function":
return arg.toString();

See output

> (function() {}).toString()
'function() {}'

Or is this related to what you mentioned here #6220 (comment)?

Copy link
Contributor Author

@nazarhussain nazarhussain Dec 21, 2023

Choose a reason for hiding this comment

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

Yes, the stub earlier was removing the new line break from the output. As no source code is changed related to encoding, so reset assure it behaves it had been before.

Copy link
Member

Choose a reason for hiding this comment

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

But I still don't get why there would be a new line in the middle of the function, what's adding that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When vitest transpile the TS code to JS the esbuild/rollup add a new line at the function definition, that translates to new line when we do the function.string().

const arg = function () {
};
console.log(arg.toString());

I could not find the direct fix tin the Rollup config for it, and fixing the test fixture is not destructive in this case, so left it like that.

Copy link
Member

Choose a reason for hiding this comment

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

I also don't think it is worth to try and find a fix for it, just good to know why these new lines are there

@nazarhussain nazarhussain requested a review from nflaig December 21, 2023 16:25
Copy link
Member

Choose a reason for hiding this comment

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

should this file be renamed now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will remove it completely when migrate all the tests.

@nazarhussain nazarhussain merged commit 1200c59 into unstable Dec 26, 2023
15 checks passed
@nazarhussain nazarhussain deleted the nh/vitest-logger branch December 26, 2023 11:15
@wemeetagain
Copy link
Member

🎉 This PR is included in v1.14.0 🎉

ensi321 pushed a commit to ensi321/lodestar that referenced this pull request Jan 22, 2024
* Migrate logger tests to vitest

* Remove lint comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants