#!/usr/bin/python

# Copyright 2011 Russell Miller & Ben Carr
# Please see included LICENSE file

# timer.py
# Run each sort and time them

import time
from sort_utils import *
from bubblesort import *
from insertionsort import *
from mergesort import *
from quicksort import *

def main():
    """Start timer, sort, stop timer. write result to file"""
    for i in range(1,1001):
        l = getlist("../size10/list" + str(i))
        start = time.time()
        bubblesort(l)
        bubble_time = time.time() - start
        start = time.time()
        insertionsort(l)
        insertion_time = time.time() - start
        start = time.time()
        mergesort(l)
        merge_time = time.time() - start
        start = time.time()
        quicksort(l)
        quick_time = time.time() - start
        f = open("bubble10", 'a')
        f.write(str(bubble_time) + '\n')
        f.close()
        f = open("insertion10", 'a')
        f.write(str(insertion_time) + '\n')
        f.close()
        f = open("merge10", 'a')
        f.write(str(merge_time) + '\n')
        f.close()
        f = open("quick10", 'a')
        f.write(str(quick_time) + '\n')
        f.close()

if __name__=="__main__":
    main()

@@ -144,17 +144,21 @@
 ort time
+,sys
 %0A
-
 from sor
@@ -358,13 +358,274 @@
     
-for i
+# fix recursion limit.. so quicksort can complete..%0A    sys.setrecursionlimit(1000000)%0A%0A    sizes = %5B10,50,100,500,1000,5000,10000,50000,100000,500000,1000000%5D%0A    b_times = %5B%5D%0A    i_times = %5B%5D%0A    m_times = %5B%5D%0A    q_times = %5B%5D%0A    for size in sizes:%0A        for num
  in 
@@ -636,15 +636,16 @@
 e(1,
-1001):%0A
+5):%0A    
     
@@ -668,14 +668,35 @@
 %22../
-size10
+lists/size%22 + str(size) + %22
 /lis
@@ -708,12 +708,18 @@
 str(
-i))%0A
+num))%0A    
     
@@ -746,24 +746,28 @@
 e()%0A        
+    
 bubblesort(l
@@ -780,22 +780,33 @@
     
+   
-bubble_time = 
+ b_times.append((size,
 time
@@ -812,33 +812,39 @@
 e.time() - start
-%0A
+))%0A    
         start = 
@@ -855,32 +855,36 @@
 .time()%0A        
+    
 insertionsort(l)
@@ -896,25 +896,33 @@
     
-insertion_time = 
+    i_times.append((size,
 time
@@ -932,33 +932,36 @@
 me() - start
-%0A
+))%0A 
         
 start = time
@@ -940,32 +940,35 @@
 tart))%0A         
+   
 start = time.tim
@@ -975,24 +975,28 @@
 e()%0A        
+   
+ 
 mergesort(l)
@@ -1008,21 +1008,33 @@
     
-merge_time = 
+    m_times.append((size,
 time
@@ -1048,25 +1048,29 @@
  - start
-%0A
+))%0A  
         
 start = 
@@ -1053,32 +1053,34 @@
 art))%0A          
+  
 start = time.tim
@@ -1075,32 +1075,36 @@
 t = time.time()%0A
+    
         quicksor
@@ -1120,21 +1120,33 @@
     
-quick_time = 
+    q_times.append((size,
 time
@@ -1164,272 +1164,270 @@
 tart
+))
 %0A    
-    f = open(%22bubble10%22, 'a')%0A        f.write(str(bubble_time) + '%5Cn')%0A        f.close()%0A        f = open(%22insertion10%22, 'a')%0A        f.write(str(insertion_time) + '%5Cn')%0A        f.close()%0A        f = open(%22merge10%22, 'a')%0A        f.write(
+csv = %22n,bubble,insertion,merge,quick%5Cn%22%0A    for size in sizes:%0A        for i in range(100):%0A            csv += str(b_times%5Bi%5D%5B0%5D) + str(b_times%5Bi%5D%5B1%5D)%0A            csv += str(i_times%5Bi%5D%5B1%5D) + str(m_times%5Bi%5D%5B1%5D)%0A            csv += 
 str(m
-erge
 _time
+s%5Bi%5D%5B1%5D
 ) + '%5Cn'
 )%0A  
@@ -1426,32 +1426,9 @@
 '%5Cn'
-)%0A        f.close()%0A    
+%0A
     
@@ -1441,39 +1441,38 @@
 en(%22
-quick10
+python.csv
 %22, '
-a
+w
 ')%0A    
- 
-   
 f.write(
 str(
@@ -1471,36 +1471,13 @@
 ite(
-str(quick_time) + '%5Cn')%0A    
+csv)%0A
     

trying to generate this csv