-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbenchmark.py
More file actions
62 lines (43 loc) · 1.23 KB
/
benchmark.py
File metadata and controls
62 lines (43 loc) · 1.23 KB
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Nov 7 11:15:18 2017
@author: koolok
"""
import numpy as np
import pickle
from distance import distance
import time
import editdistance
def init() :
try :
data = open("data.txt", "r", encoding="utf-8")
base = []
for line in data :
digit,word = line.split("/")
base.append(word[0:-1])
data.close()
except :
base = []
return base
base = init()
distance_matrix = np.zeros((len(base),len(base)))
n = 0
starting_point_proc = time.clock()
for i in range(len(base)) :
for j in range(len(base)) :
if i != j :
n +=1
distance_matrix[i,j] = distance(base[i],base[j])
total_time = time.clock() - starting_point_proc
print("Our distance : average time execution : ", total_time / n)
#------------------------------------------
n = 0
starting_point_proc = time.clock()
for i in range(len(base)) :
for j in range(len(base)) :
if i != j :
n +=1
distance_matrix[i,j] = editdistance.eval(base[i],base[j])
total_time = time.clock() - starting_point_proc
print("Module editdistance : average time execution : ", total_time / n)