4 Checks the execution time of repeated calls to the Scheme API from Python
6 Runs an empty Scheme command NUMBER_OF_ITERATIONS times and displays the
10 __author__ =
'Cosmo Harrigan'
12 NUMBER_OF_ITERATIONS = 50000
14 from opencog.atomspace
import AtomSpace, TruthValue, types, get_type_name
15 from opencog.scheme_wrapper
import load_scm, scheme_eval, scheme_eval_h, __init__
17 atomspace = AtomSpace()
20 data = [
"opencog/atomspace/core_types.scm",
21 "opencog/scm/utilities.scm"]
24 load_scm(atomspace, item)
28 for i
in range(NUMBER_OF_ITERATIONS):
29 scheme_eval(atomspace,
'(+ 2 2)')
32 elapsed = timeit.timeit(
"test_operation()",
33 setup=
"from __main__ import test_operation",
36 print "{0} seconds elapsed performing {1} repeated calls = {2} calls / sec".\
37 format(elapsed, NUMBER_OF_ITERATIONS, NUMBER_OF_ITERATIONS / elapsed)