30 lines
688 B
Python
Executable File
30 lines
688 B
Python
Executable File
#! /usr/bin/env python
|
|
"""
|
|
A *very* basic performance test.
|
|
|
|
"""
|
|
|
|
from __future__ import print_function
|
|
import argparse
|
|
import timeit
|
|
|
|
from jsonschema import Draft3Validator, validate
|
|
|
|
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("-n", "--number", type=int, default=100)
|
|
arguments = parser.parse_args()
|
|
|
|
instance = schema = Draft3Validator.META_SCHEMA
|
|
|
|
results = timeit.timeit(
|
|
# Validate the Draft 3 meta-schema against itself without meta-validating
|
|
stmt="validate(instance, schema)",
|
|
setup="from __main__ import instance, schema, validate",
|
|
number=arguments.number,
|
|
)
|
|
|
|
print(
|
|
"Validated %s times. Finished in %s seconds." % (arguments.number, results)
|
|
)
|