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

add timing information to spec test generation #2571

Merged
merged 1 commit into from
Aug 26, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions tests/core/pyspec/eth2spec/gen_helpers/gen_base/gen_runner.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import time
import shutil
import argparse
from pathlib import Path
Expand All @@ -22,6 +23,9 @@
context.is_pytest = False


TIME_THRESHOLD_TO_PRINT = 1.0 # seconds


def validate_output_dir(path_str):
path = Path(path_str)

Expand Down Expand Up @@ -98,6 +102,7 @@ def run_generator(generator_name, test_providers: Iterable[TestProvider]):

generated_test_count = 0
skipped_test_count = 0
provider_start = time.time()
for tprov in test_providers:
# runs anything that we don't want to repeat for every test case.
tprov.prepare()
Expand All @@ -122,6 +127,7 @@ def run_generator(generator_name, test_providers: Iterable[TestProvider]):
shutil.rmtree(case_dir)

print(f'Generating test: {case_dir}')
test_start = time.time()

written_part = False

Expand Down Expand Up @@ -179,9 +185,18 @@ def output_part(out_kind: str, name: str, fn: Callable[[Path, ], None]):
generated_test_count += 1
# Only remove `INCOMPLETE` tag file
os.remove(incomplete_tag_file)
test_end = time.time()
span = round(test_end - test_start, 2)
if span > TIME_THRESHOLD_TO_PRINT:
print(f' - generated in {span} seconds')

provider_end = time.time()
span = round(provider_end - provider_start, 2)

summary_message = f"completed generation of {generator_name} with {generated_test_count} tests"
summary_message += f" ({skipped_test_count} skipped tests)"
if span > TIME_THRESHOLD_TO_PRINT:
summary_message += f" in {span} seconds"
print(summary_message)


Expand Down