mirror of
https://github.com/ethereum/consensus-specs.git
synced 2026-02-01 09:45:02 -05:00
Add settings.py of testgen
This commit is contained in:
@@ -11,7 +11,6 @@ import sys
|
||||
import json
|
||||
from typing import Iterable, AnyStr, Any, Callable
|
||||
import traceback
|
||||
import multiprocessing
|
||||
from collections import namedtuple
|
||||
|
||||
from ruamel.yaml import (
|
||||
@@ -28,21 +27,19 @@ from eth2spec.test import context
|
||||
from eth2spec.test.exceptions import SkippedTest
|
||||
|
||||
from .gen_typing import TestProvider
|
||||
from .settings import (
|
||||
GENERATOR_MODE,
|
||||
MODE_MULTIPROCESSING,
|
||||
MODE_SINGLE_PROCESS,
|
||||
NUM_PROCESS,
|
||||
TIME_THRESHOLD_TO_PRINT,
|
||||
)
|
||||
|
||||
|
||||
# Flag that the runner does NOT run test via pytest
|
||||
context.is_pytest = False
|
||||
|
||||
|
||||
TIME_THRESHOLD_TO_PRINT = 1.0 # seconds
|
||||
|
||||
# Generator mode setting
|
||||
MODE_SINGLE_PROCESS = 'MODE_SINGLE_PROCESS'
|
||||
MODE_MULTIPROCESSING = 'MODE_MULTIPROCESSING'
|
||||
|
||||
GENERATOR_MODE = MODE_MULTIPROCESSING
|
||||
|
||||
|
||||
@dataclass
|
||||
class Diagnostics(object):
|
||||
collected_test_count: int = 0
|
||||
@@ -243,8 +240,7 @@ def run_generator(generator_name, test_providers: Iterable[TestProvider]):
|
||||
all_test_case_params.append(item)
|
||||
|
||||
if GENERATOR_MODE == MODE_MULTIPROCESSING:
|
||||
num_process = multiprocessing.cpu_count() // 2 - 1
|
||||
with Pool(processes=num_process) as pool:
|
||||
with Pool(processes=NUM_PROCESS) as pool:
|
||||
results = pool.map(worker_function, iter(all_test_case_params))
|
||||
|
||||
for result in results:
|
||||
|
||||
13
tests/core/pyspec/eth2spec/gen_helpers/gen_base/settings.py
Normal file
13
tests/core/pyspec/eth2spec/gen_helpers/gen_base/settings.py
Normal file
@@ -0,0 +1,13 @@
|
||||
import multiprocessing
|
||||
|
||||
|
||||
# Generator mode setting
|
||||
MODE_SINGLE_PROCESS = 'MODE_SINGLE_PROCESS'
|
||||
MODE_MULTIPROCESSING = 'MODE_MULTIPROCESSING'
|
||||
# Test generator mode
|
||||
GENERATOR_MODE = MODE_MULTIPROCESSING
|
||||
# Number of subprocesses when using MODE_MULTIPROCESSING
|
||||
NUM_PROCESS = multiprocessing.cpu_count() // 2 - 1
|
||||
|
||||
# Diagnostics
|
||||
TIME_THRESHOLD_TO_PRINT = 1.0 # seconds
|
||||
Reference in New Issue
Block a user