-
Notifications
You must be signed in to change notification settings - Fork 252
Expand file tree
/
Copy pathscheme_timer.py
More file actions
executable file
·33 lines (24 loc) · 929 Bytes
/
scheme_timer.py
File metadata and controls
executable file
·33 lines (24 loc) · 929 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#! /usr/bin/env python3
"""
Checks the execution time of repeated calls to the Scheme API from Python
Runs an empty Scheme command NUMBER_OF_ITERATIONS times and displays the
total execution time
"""
__author__ = 'Cosmo Harrigan'
from opencog.atomspace import AtomSpace
from opencog.scheme import *
atomspace = AtomSpace()
NUMBER_OF_ITERATIONS = 50000
def test_operation():
for _ in range(NUMBER_OF_ITERATIONS):
# scheme_eval(atomspace, '(+ 2 2)')
scheme_eval_v(atomspace, '(Concept "foo")')
# scheme_eval_v(atomspace, '(Number ' + str(i) + ')')
import timeit
elapsed = timeit.timeit("test_operation()",
setup="from __main__ import test_operation",
number=1)
def report():
print ("{0} seconds elapsed performing {1} repeated calls = {2} calls / sec".\
format(elapsed, NUMBER_OF_ITERATIONS, NUMBER_OF_ITERATIONS / elapsed))
report()