[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: test_overall_performance_2.py
File is not writable. Editing disabled.
import json from collections import Counter from typing import Callable, List from typing import Counter as CounterType from pytest import mark from cerberus import Validator from cerberus.benchmarks.schemas.overalll_schema_2 import product_schema from cerberus.benchmarks import DOCUMENTS_PATH def init_validator(): return Validator(product_schema, purge_unknown=True) def load_documents(): with (DOCUMENTS_PATH / "overall_documents_2.json").open() as f: documents = json.load(f) return documents def validate_documents(init_validator: Callable, documents: List[dict]) -> None: doc_count = failed_count = 0 error_paths: CounterType[tuple] = Counter() validator = init_validator() def count_errors(errors): if errors is None: return for error in errors: if error.is_group_error: count_errors(error.child_errors) else: error_paths[error.schema_path] += 1 for document in documents: if validator.validated(document) is None: failed_count += 1 count_errors(validator._errors) doc_count += 1 print( f"{failed_count} out of {doc_count} documents failed with " f"{len(error_paths)} different error leafs." ) print("Top 3 errors, excluding container errors:") for path, count in error_paths.most_common(3): print(f"{count}: {path}") @mark.benchmark(group="overall-2") def test_overall_performance_2(benchmark): benchmark.pedantic(validate_documents, (init_validator, load_documents()), rounds=5)
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server05.hostinghome.co.in
Server IP: 192.168.74.40
PHP Version: 7.4.33
Server Software: Apache
System: Linux server05.hostinghome.co.in 3.10.0-962.3.2.lve1.5.81.el7.x86_64 #1 SMP Wed May 31 10:36:47 UTC 2023 x86_64
HDD Total: 1.95 TB
HDD Free: 690.89 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Disabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes
gcc:
Yes
pkexec:
No
git:
Yes
User Info
Username: itsweb
User ID (UID): 1619
Group ID (GID): 1621
Script Owner UID: 1619
Current Dir Owner: N/A