Skip to content

Commit

Permalink
vm: add profiler option to blockchain/state tests (#3115)
Browse files Browse the repository at this point in the history
* vm: add profiler option to blockchain/state tests

* vm: rename profiler -> profile
  • Loading branch information
jochem-brouwer committed Oct 24, 2023
1 parent eeb74e4 commit 3e674dd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions packages/vm/test/tester/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import type { Common } from '@ethereumjs/common'
* --expected-test-amount: number. If passed, check after tests are ran if at least this amount of tests have passed (inclusive)
* --verify-test-amount-alltests: number. If passed, get the expected amount from tests and verify afterwards if this is the count of tests (expects tests are ran with default settings)
* --reps: number. If passed, each test case will be run the number of times indicated
* --profile If this flag is passed, the state/blockchain tests will profile
*/

const argv = minimist(process.argv.slice(2))
Expand All @@ -60,6 +61,8 @@ async function runTests() {
process.exit(1)
}

const RUN_PROFILER: boolean = argv.profile ?? false

const FORK_CONFIG: string = argv.fork !== undefined ? argv.fork : DEFAULT_FORK_CONFIG
const FORK_CONFIG_TEST_SUITE = getRequiredForkConfigAlias(FORK_CONFIG)

Expand Down Expand Up @@ -106,6 +109,7 @@ async function runTests() {
value?: number
debug?: boolean
reps?: number
profile: boolean
} = {
forkConfigVM: FORK_CONFIG_VM,
forkConfigTestSuite: FORK_CONFIG_TEST_SUITE,
Expand All @@ -117,6 +121,7 @@ async function runTests() {
value: argv.value, // GeneralStateTests
debug: argv.debug, // BlockchainTests
reps: argv.reps, // test repetitions
profile: RUN_PROFILER,
}

/**
Expand Down
3 changes: 3 additions & 0 deletions packages/vm/test/tester/runners/BlockchainTestsRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ export async function runBlockchainTest(options: any, testData: any, t: tape.Tes
blockchain,
common,
setHardfork: true,
profilerOpts: {
reportAfterBlock: options.profile,
},
})

// set up pre-state
Expand Down
7 changes: 6 additions & 1 deletion packages/vm/test/tester/runners/GeneralStateTestsRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,12 @@ async function runTestCase(options: any, testData: any, t: tape.Test) {
common,
})

const vm = await VM.create({ stateManager, common, blockchain })
const vm = await VM.create({
stateManager,
common,
blockchain,
profilerOpts: { reportAfterTx: options.profile },
})

await setupPreConditions(vm.stateManager, testData)

Expand Down

0 comments on commit 3e674dd

Please sign in to comment.