Permalink
Browse files

Added bm2, also small other changes.

  • Loading branch information...
1 parent b338343 commit 6fb814e8fb674be8471b274ef52c02458d06c950 @radarek radarek committed Jan 16, 2009
Showing with 100,048 additions and 2 deletions.
  1. +0 −1 bm1.py
  2. +27 −0 bm2.py
  3. +21 −0 bm2.rb
  4. +100,000 −0 in
  5. +0 −1 red_black_tree.py
View
1 bm1.py
@@ -3,7 +3,6 @@
import random
from red_black_tree import RedBlackTree
import sys
-#import cProfile
minor = sys.version_info[0]
if minor >= 3:
View
27 bm2.py
@@ -0,0 +1,27 @@
+import sys
+import time
+import random
+from red_black_tree import RedBlackTree
+import sys
+
+def bm(arr):
+ start = time.time()
+
+ tree = RedBlackTree()
+ for x in arr:
+ tree.add(x)
+
+ return time.time() - start
+
+if len(sys.argv) > 1:
+ n = int(sys.argv[1])
+else:
+ n = 5
+
+arr = []
+for line in sys.stdin:
+ arr.append(int(line))
+
+for i in range(0, n):
+ print("%02f" % bm(arr))
+
View
21 bm2.rb
@@ -0,0 +1,21 @@
+require 'red_black_tree'
+
+def bm(arr)
+ start = Time.now
+
+ tree = RedBlackTree.new
+ arr.each do |x|
+ tree.add(x)
+ end
+
+ return Time.now - start
+end
+
+N = (ARGV[0] || 5).to_i
+
+arr = []
+$stdin.each_line {|line| arr << line.to_i }
+
+N.times do
+ puts bm(arr)
+end
View
100,000 in
100,000 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
1 red_black_tree.py
@@ -19,7 +19,6 @@ def __str__(self, level = 0, indent = " "):
if self.right:
s = s + "\n" + self.right.__str__(level + 1, indent)
return s
- #return "<Node @key=%s, @color=%s, @left=%s, @right=%s>" % (self.key, self.color, self.left, self.right)
def is_red(self):
return self.color == RED

0 comments on commit 6fb814e

Please sign in to comment.