def randomAllSmall(): """Performs a small random data test on ALL data structures under consideration.""" # Initialize data structures bst = BinarySearchTree() stromberg_treap = StrombergTreap() jenks_treap = JenksTreap() pyskiplist = PySkipList() redblacktree = RedBlackTree() # avltree = AVLTree() # Custom benchmarking parameters stop = 5200 bm_start = 200 bm_length = 20 bm_interval = 200 # Final setup, and invocation. filename = "plots/randomAllSmall.tex" functions = \ [bst.insert, stromberg_treap.insert, jenks_treap.insert, pyskiplist.insert, redblacktree.add] samples = generateRandomSamples(stop) title = "Insert: All Data Structures, Random Input (Small Data Set)" graph(filename, functions, samples, title=title, stopindex=stop, bm_startindex=bm_start, bm_interval=bm_interval, bm_length=bm_length, repeat=1)
def testGraphMixedSID(): # Options and parameters size = 20 bm_start = 0 bm_length = 3 bm_interval = 5 filename = "plots/testGraphMixedSID.tex" # Generate operation sequence ops = generateRandomOperationSequence(size) # Initialize data structures bst = BinarySearchTree() stromberg_treap = StrombergTreap() jenks_treap = JenksTreap() pyskiplist = PySkipList() redblacktree = RedBlackTree() sortedlist = SortedList() builtinlist = List() # Create functions list searches = \ [ bst.search, stromberg_treap.get_key, jenks_treap.__getitem__, pyskiplist.search, redblacktree.find_node, sortedlist.search, builtinlist.search, ] inserts = \ [ bst.insert, stromberg_treap.insert, jenks_treap.insert, pyskiplist.insert, redblacktree.add, sortedlist.add, builtinlist.add ] deletes = \ [ bst.delete, stromberg_treap.remove, jenks_treap.__delitem__, pyskiplist.remove, redblacktree.remove, sortedlist.remove, builtinlist.remove ] # Run the graph graphMixedSID(filename, searches, inserts, deletes, ops, bm_start, bm_length, bm_interval)
def insertRandom(): """Performs a small random data test on ALL data structures under consideration.""" # Initialize data structures bst = BinarySearchTree() stromberg_treap = StrombergTreap() jenks_treap = JenksTreap() pyskiplist = PySkipList() redblacktree = RedBlackTree() # avltree = AVLTree() # Final setup, and invocation. filename = "plots/insertRandom.tex" functions = \ [bst.insert, stromberg_treap.insert, jenks_treap.insert, pyskiplist.insert, redblacktree.add] samples = generateRandomSamples(SAMPLE_SIZE) title = "Insert: Random Input" graph(filename, functions, samples, title=title)
def randomSID(): """Performs a full search, insert, and delete benchmark set on randomized input data.""" (search_samples, insert_samples, delete_samples) = generateRandomSIDSampleSet() # 210, 40, 10, 40) # Initialize data structures bst = BinarySearchTree() stromberg_treap = StrombergTreap() jenks_treap = JenksTreap() pyskiplist = PySkipList() redblacktree = RedBlackTree() # avltree = AVLTree() # Final setup, and invocation. base_filename = "plots/random.tex" search_filename = base_filename[0:-4] + "_search" + base_filename[-4:] insert_filename = base_filename[0:-4] + "_insert" + base_filename[-4:] delete_filename = base_filename[0:-4] + "_delete" + base_filename[-4:] searches = \ [bst.search, stromberg_treap.get_key, jenks_treap.__getitem__, pyskiplist.search, redblacktree.find_node] inserts = \ [bst.insert, stromberg_treap.insert, jenks_treap.insert, pyskiplist.insert, redblacktree.add] deletes = \ [bst.delete, stromberg_treap.remove, jenks_treap.__delitem__, pyskiplist.remove, redblacktree.remove] title = "Random Input" graphSID( search_filename, insert_filename, delete_filename, searches, inserts, deletes, search_samples, insert_samples, delete_samples, # 210, # 40, # 10, # 40, title=title)
def worstCaseSIDNoBST(): """Performs a full search, insert, and delete benchmark set on all data structures using the worst-case inputs for binary search trees.""" # Worst-case insert: all increasing. insert_samples = list(range(STOP)) # Worst-case delete: always the leaf in our worst-case structure. delete_samples = insert_samples[:] delete_samples.reverse() # Worst-case search: search for the last bm_length elements in our worst-case structure. But this is harder # to create since it only does a search at our various intervals. search_samples = [] current = BENCHMARK_START while current < STOP: search_samples += list(range(current - BENCHMARK_LENGTH, current)) current = min(STOP, current + BENCHMARK_INTERVAL) # Initialize data structures # bst = BinarySearchTree() stromberg_treap = StrombergTreap() jenks_treap = JenksTreap() pyskiplist = PySkipList() redblacktree = RedBlackTree() # avltree = AVLTree() # Final setup, and invocation. base_filename = "plots/worstCaseNoBST.tex" search_filename = base_filename[0:-4] + "_search" + base_filename[-4:] insert_filename = base_filename[0:-4] + "_insert" + base_filename[-4:] delete_filename = base_filename[0:-4] + "_delete" + base_filename[-4:] searches = \ [ # bst.search, stromberg_treap.get_key, jenks_treap.__getitem__, pyskiplist.search, redblacktree.find_node ] inserts = \ [ # bst.insert, stromberg_treap.insert, jenks_treap.insert, pyskiplist.insert, redblacktree.add ] deletes = \ [ # bst.delete, stromberg_treap.remove, jenks_treap.__delitem__, pyskiplist.remove, redblacktree.remove ] title = "Worst-Case Input" graphSID(search_filename, insert_filename, delete_filename, searches, inserts, deletes, search_samples, insert_samples, delete_samples, title=title)
def worstCaseSID(): """Performs a full search, insert, and delete benchmark set on all data structures using the worst-case inputs for binary search trees.""" # Custom test parameters, because a million items will just take eons. stop = 10000 bm_start = 500 bm_length = 100 bm_interval = 500 # Worst-case insert: all increasing. insert_samples = list(range(stop)) # Worst-case delete: always the leaf in our worst-case structure. delete_samples = insert_samples[:] delete_samples.reverse() # Worst-case search: search for the last bm_length elements in our worst-case structure. But this is harder # to create since it only does a search at our various intervals. search_samples = [] current = bm_start while current < stop: search_samples += list(range(current - bm_length, current)) current = min(stop, current + bm_interval) # Initialize data structures bst = BinarySearchTree() stromberg_treap = StrombergTreap() jenks_treap = JenksTreap() pyskiplist = PySkipList() redblacktree = RedBlackTree() # avltree = AVLTree() # Final setup, and invocation. base_filename = "plots/worstCase.tex" search_filename = base_filename[0:-4] + "_search" + base_filename[-4:] insert_filename = base_filename[0:-4] + "_insert" + base_filename[-4:] delete_filename = base_filename[0:-4] + "_delete" + base_filename[-4:] searches = \ [ bst.search, stromberg_treap.get_key, jenks_treap.__getitem__, pyskiplist.search, redblacktree.find_node ] inserts = \ [ bst.insert, stromberg_treap.insert, jenks_treap.insert, pyskiplist.insert, redblacktree.add ] deletes = \ [ bst.delete, stromberg_treap.remove, jenks_treap.__delitem__, pyskiplist.remove, redblacktree.remove ] title = "Worst-Case Input" graphSID(search_filename, insert_filename, delete_filename, searches, inserts, deletes, search_samples, insert_samples, delete_samples, stop, bm_start, bm_length, bm_interval, title=title)