mirror of
https://github.com/status-im/nim-eth.git
synced 2025-02-20 17:58:20 +00:00
add a profiling test
This commit is contained in:
parent
88e4be4dc4
commit
24a871f85d
@ -3,4 +3,5 @@ import
|
|||||||
./test_json_suite,
|
./test_json_suite,
|
||||||
./test_empty_string,
|
./test_empty_string,
|
||||||
./test_object_serialization,
|
./test_object_serialization,
|
||||||
./test_optional_fields
|
./test_optional_fields,
|
||||||
|
./test_rlp_profiler
|
||||||
|
37
tests/rlp/test_rlp_profiler.nim
Normal file
37
tests/rlp/test_rlp_profiler.nim
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
{.used.}
|
||||||
|
|
||||||
|
import
|
||||||
|
../../eth/[rlp, common],
|
||||||
|
unittest2,
|
||||||
|
times,
|
||||||
|
os,
|
||||||
|
strutils
|
||||||
|
|
||||||
|
template benchmark(benchmarkName: string, code: untyped) =
|
||||||
|
block:
|
||||||
|
let t0 = epochTime()
|
||||||
|
code
|
||||||
|
let elapsed = epochTime() - t0
|
||||||
|
let elapsedStr = elapsed.formatFloat(format = ffDecimal, precision = 9)
|
||||||
|
echo "CPU Time [", benchmarkName, "] ", elapsedStr, "s"
|
||||||
|
|
||||||
|
const
|
||||||
|
accesses = @[AccessPair(
|
||||||
|
address: address"0x0000000000000000000000000000000000000001",
|
||||||
|
storageKeys: @[default(Bytes32)]
|
||||||
|
)]
|
||||||
|
|
||||||
|
let my_tx = Transaction(
|
||||||
|
txType: TxEip1559,
|
||||||
|
chainId: 1.ChainId,
|
||||||
|
nonce: 0.AccountNonce,
|
||||||
|
gasLimit: 123457.GasInt,
|
||||||
|
maxPriorityFeePerGas: 42.GasInt,
|
||||||
|
maxFeePerGas: 10.GasInt,
|
||||||
|
accessList: accesses
|
||||||
|
)
|
||||||
|
|
||||||
|
suite "test running time of rlp serialization":
|
||||||
|
test "transaction serialization":
|
||||||
|
benchmark "Transaction":
|
||||||
|
let my_bytes = rlp.encode(my_tx)
|
Loading…
x
Reference in New Issue
Block a user