-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathccs_timing_tests.py
71 lines (60 loc) · 2.18 KB
/
ccs_timing_tests.py
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
__author__ = 'Jarek Glowacki'
import timeit
import numpy as np
###################################################
function = 'wordnet.exists'
setup = """
import wordnet
def test():
wordnet.exists('troubadour')
"""
repetitions = 1000000
print("Average time to execute function '%s' is %.3fus" % (function, np.mean(timeit.Timer('test()', setup=setup).repeat(10, repetitions))/repetitions*1000000))
###################################################
function = 'wordnet.calcSimilarity'
setup = """
import wordnet
def test():
wordnet.calcSimilarity('troubadour', 'valkyrie')
"""
repetitions = 10000
print("Average time to execute function '%s' is %.3fms" % (function, np.mean(timeit.Timer('test()', setup=setup).repeat(repetitions, 1))*1000))
###################################################
function = 'wordnet.getSynonyms'
setup = """
import wordnet
def test():
wordnet.getSynonyms('parsnip')
"""
repetitions = 1000000
print("Average time to execute function '%s' is %.3fus" % (function, np.mean(timeit.Timer('test()', setup=setup).repeat(repetitions, 1))*1000000))
###################################################
function = 'wordnet.getAbbreviations'
setup = """
import wordnet
def test():
wordnet.getAbbreviations('tungsten')
"""
repetitions = 1000000
print("Average time to execute function '%s' is %.3fus" % (function, np.mean(timeit.Timer('test()', setup=setup).repeat(repetitions, 1))*1000000))
###################################################
function = 'wordnet.getWordsWithPattern'
setup = """
import wordnet
def test():
wordnet.getWordsWithPattern('\A[a-z][a-z][a-z]i[a-z]a\Z')
"""
repetitions = 10
print("Average time to execute function '%s' is %.3fms" % (function, np.mean(timeit.Timer('test()', setup=setup).repeat(repetitions, 1))*1000))
###################################################
function = 'wordplay.getAnagrams'
setup = """
from clue_parser import ClueParser
cp = ClueParser()
ana = cp.wordplays['anagram']
def test():
ana.getPlay('pots')
"""
repetitions = 100000
print("Average time to execute function '%s' is %.3fus" % (function, np.mean(timeit.Timer('test()', setup=setup).repeat(10, repetitions))/repetitions*1000000))
###################################################