diff options
author | Rich Hickey <richhickey@gmail.com> | 2006-06-07 21:01:23 +0000 |
---|---|---|
committer | Rich Hickey <richhickey@gmail.com> | 2006-06-07 21:01:23 +0000 |
commit | ad4a5eca0eb942799d14037188173f6342d32a37 (patch) | |
tree | 30cbb9e1a6501a0dfd4bcc9a537b531e1dc7a428 /src/cli/runtime/PersistentTree.cs | |
parent | 3c3e47199e7aa7d8115af5a22a3035390c4e4769 (diff) |
test code changes
Diffstat (limited to 'src/cli/runtime/PersistentTree.cs')
-rw-r--r-- | src/cli/runtime/PersistentTree.cs | 74 |
1 files changed, 47 insertions, 27 deletions
diff --git a/src/cli/runtime/PersistentTree.cs b/src/cli/runtime/PersistentTree.cs index 3ed31f41..61f18157 100644 --- a/src/cli/runtime/PersistentTree.cs +++ b/src/cli/runtime/PersistentTree.cs @@ -732,8 +732,8 @@ public void Reset() /*
[STAThread] static public void Main(String[] args){ - if(args.Length != 1) - Console.Error.WriteLine("Usage: RBTree n"); + if(args.Length != 1)
+ Console.Error.WriteLine("Usage: PersistentTree n"); int n = Int32.Parse(args[0]); Object[] ints = new Object[n]; for(int i = 0; i < ints.Length; i++) @@ -742,47 +742,67 @@ static public void Main(String[] args){ } //Collections.shuffle(Arrays.asList(ints));
Array.Reverse(ints); - Console.WriteLine("Building set"); - RBTree set = new RBTree(); + Console.WriteLine("Building set");
+ //IPersistentMap set = new PersistentTree();
+ //IPersistentMap set = new PersistentArrayMap();
+ //IPersistentMap set = new PersistentListMap();
+ //IPersistentMap set = new PersistentHashtableMap(1001);
+ IPersistentMap set = new PersistentHybridMap(1001); //for(int i = 0; i < ints.Length; i++) // { // Object anInt = ints[i]; // set = set.add(anInt); - // } - for(int i = 0; i < ints.Length; i++) + // }
+ DateTime start = DateTime.Now;
+ for (int i = 0; i < ints.Length; i++) { Object anInt = ints[i]; set = set.put(anInt, anInt); }
- Console.WriteLine("Building SortedList");
- SortedList od = new SortedList();
- for (int i = 0; i < ints.Length; i++)
- {
- Object anInt = ints[i];
- od.Add(anInt, anInt);
- }
- - Console.Error.WriteLine("count = " + set.count + ", min: " + set.minKey() + ", max: " + set.maxKey() - + ", depth: " + set.depth()); - IEnumerator it = set.keys(); - while(it.MoveNext()) +
+ foreach(IMapEntry e in set) { - Object o = it.Current; - if(!set.contains(o)) - Console.Error.WriteLine("Can't find: " + o); - else if(n < 2000) - Console.Write(o.ToString() + ","); + if(!set.contains(e.key())) + Console.Error.WriteLine("Can't find: " + e.key()); + //else if(n < 2000) + // Console.Write(e.key().ToString() + ","); } for(int i = 0; i < ints.Length/2; i++) { Object anInt = ints[i]; set = set.remove(anInt); - } + }
+
+ Console.WriteLine("Time: " + (DateTime.Now - start));
+ Console.Error.WriteLine("count = " + set.count());
+
+ Console.WriteLine("Building Hashtable");
+ Hashtable od = new Hashtable(1001);
+ start = DateTime.Now;
+ for (int i = 0; i < ints.Length; i++)
+ {
+ Object anInt = ints[i];
+ od.Add(anInt, anInt);
+ }
+
+ foreach (DictionaryEntry e in od)
+ {
+ if (!od.Contains(e.Key))
+ Console.Error.WriteLine("Can't find: " + e.Key);
+ //else if (n < 2000)
+ // Console.Write(e.key().ToString() + ",");
+ }
+
+ for (int i = 0; i < ints.Length / 2; i++)
+ {
+ Object anInt = ints[i];
+ od.Remove(anInt);
+ }
+
+ Console.WriteLine("Time: " + (DateTime.Now - start));
+ Console.Error.WriteLine("count = " + od.Count);
- Console.Error.WriteLine(); - Console.Error.WriteLine("count = " + set.count + ", min: " + set.minKey() + ", max: " + set.maxKey() - + ", depth: " + set.depth()); } //*/ } |