Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pyrtree/bench/bench_libspatial.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@
if __name__ == "__main__":
G = RectangleGen()
idx = Rtree() # this is a libspatialindex one.
start = time.clock()
interval_start = time.clock()
start = time.process_time()
interval_start = time.process_time()
for v in range(ITER):
if 0 == (v % INTERVAL):
# interval time taken, total time taken, # rects, cur max depth
t = time.clock()
t = time.process_time()

dt = t - interval_start
print("%d,%s,%f" % (v, "itime_t", dt))
print("%d,%s,%f" % (v, "avg_insert_t", (dt/float(INTERVAL))))
#print("%d,%s,%d" % (v, "max_depth", rt.node.max_depth()))
#print("%d,%s,%d" % (v, "mean_depth", rt.node.mean_depth()))

interval_start = time.clock()
interval_start = time.process_time()
rect = G.rect(0.000001)
idx.add(v,rect.coords())

8 changes: 4 additions & 4 deletions pyrtree/bench/bench_rtree.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
gc.disable() # FFFFUUUUUUUUUUU
G = RectangleGen()
rt = RTree()
start = time.clock()
interval_start = time.clock()
start = time.process_time()
interval_start = time.process_time()
for v in range(ITER):
if 0 == (v % INTERVAL):
# interval time taken, total time taken, # rects, cur max depth
t = time.clock()
t = time.process_time()

dt = t - interval_start
print("%d,%s,%f" % (v, "itime_t", dt))
Expand All @@ -44,7 +44,7 @@
#print("%d,%s,%d" % (v, "max_depth", rt.node.max_depth()))
#print("%d,%s,%d" % (v, "mean_depth", rt.node.mean_depth()))

interval_start = time.clock()
interval_start = time.process_time()
o = TstO(G.rect(0.000001))
rt.insert(v,o.rect)

Expand Down
8 changes: 4 additions & 4 deletions pyrtree/rtree.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def _balance(self):
return


t = time.clock()
t = time.process_time()

cur_score = -10

Expand All @@ -253,7 +253,7 @@ def _balance(self):

self._set_children(nodes)

dur = (time.clock() - t)
dur = (time.process_time() - t)
c = float(self.root.stats["overflow_f"])
oa = self.root.stats["avg_overflow_t_f"]
self.root.stats["avg_overflow_t_f"] = (dur / (c + 1.0)) + (c * oa / (c + 1.0))
Expand Down Expand Up @@ -370,7 +370,7 @@ def closest(centroids, node):


def k_means_cluster(root, k, nodes):
t = time.clock()
t = time.process_time()
if len(nodes) <= k: return [ [n] for n in nodes ]

ns = list(nodes)
Expand Down Expand Up @@ -409,7 +409,7 @@ def k_means_cluster(root, k, nodes):
new_cluster_centers = [ center_of_gravity(c) for c in clusters ]
if new_cluster_centers == cluster_centers :
root.stats["avg_kmeans_iter_f"] = float(root.stats["sum_kmeans_iter_f"] / root.stats["count_kmeans_iter_f"])
root.stats["longest_kmeans"] = max(root.stats["longest_kmeans"], (time.clock() - t))
root.stats["longest_kmeans"] = max(root.stats["longest_kmeans"], (time.process_time() - t))
return clusters
else: cluster_centers = new_cluster_centers

Expand Down