2018-11-29 22:11:05 +00:00
|
|
|
# beacon_chain
|
2019-02-27 13:58:07 +00:00
|
|
|
# Copyright (c) 2018-2019 Status Research & Development GmbH
|
2018-11-29 22:11:05 +00:00
|
|
|
# Licensed and distributed under either of
|
2019-11-25 15:30:02 +00:00
|
|
|
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
|
|
|
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
2018-11-29 22:11:05 +00:00
|
|
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
|
|
|
|
|
|
|
import
|
2019-12-03 16:45:12 +00:00
|
|
|
stats, stew/endians2,
|
2019-03-28 12:00:21 +00:00
|
|
|
chronicles, eth/trie/[db],
|
2019-12-03 16:45:12 +00:00
|
|
|
../beacon_chain/[beacon_chain_db, block_pool, ssz, beacon_node_types],
|
|
|
|
../beacon_chain/spec/datatypes
|
2018-11-29 22:11:05 +00:00
|
|
|
|
2019-05-27 12:48:13 +00:00
|
|
|
func preset*(): string =
|
|
|
|
" [Preset: " & const_preset & ']'
|
|
|
|
|
2019-12-03 16:45:12 +00:00
|
|
|
template withTimer*(stats: var RunningStat, body: untyped) =
|
|
|
|
let start = getMonoTime()
|
2018-12-13 16:00:55 +00:00
|
|
|
|
2019-12-03 16:45:12 +00:00
|
|
|
block:
|
|
|
|
body
|
2018-12-13 16:00:55 +00:00
|
|
|
|
2019-12-03 16:45:12 +00:00
|
|
|
let stop = getMonoTime()
|
|
|
|
stats.push (stop - start).inMicroseconds.float / 1000000.0
|
2019-07-24 06:19:52 +00:00
|
|
|
|
2019-12-03 16:45:12 +00:00
|
|
|
template withTimerRet*(stats: var RunningStat, body: untyped): untyped =
|
|
|
|
let start = getMonoTime()
|
|
|
|
let tmp = block:
|
|
|
|
body
|
|
|
|
let stop = getMonoTime()
|
|
|
|
stats.push (stop - start).inMicroseconds.float / 1000000.0
|
2018-12-13 16:00:55 +00:00
|
|
|
|
2019-12-03 16:45:12 +00:00
|
|
|
tmp
|
2019-11-27 22:48:12 +00:00
|
|
|
|
2019-02-28 21:21:29 +00:00
|
|
|
proc makeTestDB*(tailState: BeaconState, tailBlock: BeaconBlock): BeaconChainDB =
|
|
|
|
result = init(BeaconChainDB, newMemoryDB())
|
2019-03-28 06:10:48 +00:00
|
|
|
BlockPool.preInit(result, tailState, tailBlock)
|