futzing around with C and Ruby implementations

This commit is contained in:
Dan Buch
2011-08-17 23:07:18 -04:00
parent c8d657d3c1
commit 43db7108aa
8 changed files with 98 additions and 3 deletions

7
bench
View File

@@ -1,9 +1,10 @@
#!/bin/bash
SETUP="import sorting;import random;l = list(range(0, ${1-5000}));random.shuffle(l)"
SETUP="import sorting"
LIST="$(python -c "import random;l = list(range(0, ${1-5000}));random.shuffle(l);print(l)")"
echo -n "insertion sort: "
python -m timeit -s "$SETUP" 'sorting.insertion_sort(l)'
python -m timeit -s "$SETUP" "sorting.insertion_sort($LIST)"
echo -n "merge sort: "
python -m timeit -s "$SETUP" 'sorting.merge_sort(l)'
python -m timeit -s "$SETUP" "sorting.merge_sort($LIST)"