def _testCombine(): from quick import quick mtd.settings['default.instrument'] = "SURF" [w1lam,w1q,th] = quick(94511,theta=0.25,trans='94504') [w2lam,w2q,th] = quick(94512,theta=0.65,trans='94504') [w3lam,w3q,th] = quick(94513,theta=1.5,trans='94504') wksp=['94511_IvsQ','94512_IvsQ','94513_IvsQ'] wcomb = combineDataMulti(wksp,'94511_13_IvsQ',0.0,0.1,0.001,0.3,binning=-0.02) plotSpectrum("94511_13_IvsQ",0)
def startalgo(): global data if not data: return timetick=speedScale.get() algo = algMenu.get() if algo == "": response=messagebox.showwarning("Warning","Please select the Algorithm") if algo == "Bubble Sort": bubble(data, drawData, timetick) if algo == "Merge Sort": mergesort(data,drawData,timetick) if algo == "Quick Sort": quick(data,0,len(data)-1,drawData,timetick) drawData(data,["#7CFC00"for x in range(len(data))]) #green
def full_backup(): global db_path folder_file = os.path.basename(READ_DB) # 截取全路径最后一个反斜杠,可以是文件夹或文件 if not os.path.exists('./backups'): os.mkdir('./backups') new_zip = archive(data_path, READ_DB) new_zip.seven_zip(folder_file) try: db_path = os.path.join(r'./backups', '{}{}'.format(folder_file, '.db')) quick(db_table, db_mode, db_data, d_path=db_path).new_db() except OperationalError: # 数据库文件重复存在错误检测,如果已存在则忽略 pass quick(db_table, db_mode, db_data, d_path=db_path).new_index(READ_DB) try: h = Hash(r'{}\{}.7z'.format(data_path, folder_file)) h.sava_hash(h.md5(), '.md5', data_path) showinfo('提示', '备份完成') except: showerror('警告', '备份失败\n可能与无读写权限有关')
end_b = time.time() print('bubble', end_b - start_b) # selection start_s = time.time() sorted_selection = selection.selection(before) print(sorted_selection) end_s = time.time() print('selection', end_s - start_s) # insertion start_i = time.time() sorted_insertion = insertion.insertion(before) print(sorted_insertion) end_i = time.time() print('insertion', end_i - start_i) # quick start_q = time.time() sorted_quick = quick.quick(before) print(sorted_quick) end_q = time.time() print('quick', end_q - start_q) # merge start_m = time.time() sorted_merge = merge_sort.devide(before) print(sorted_merge) end_m = time.time() print('merge', end_m - start_m)
print "insertionsort success!" else: print "insertionsort incorrect." except: print "insertionsort function errored or is incomplete." try: from merge import mergesort if (mergesort(list(nums)) == sortedNums): print "mergesort success!" else: print "mergesort incorrect." except: print "mergesort function errored or is incomplete." try: from quick import quick if (quick(list(nums)) == sortedNums): print "quicksort success!" else: print "quicksort incorrect." except: print "quicksort function errored or is incomplete." try: from heap import heap if (heap(list(nums)) == sortedNums): print "Heap Sort success!" else: print "Heap Sort incorrect." except: print "Heapsort function errored or is incomplete."
import random import quick import quick2 import shell import merge import sys """use this to test sort performance""" num = int(sys.argv[2]) sort = sys.argv[1] lst = [random.randint(0, num - 1) for _ in range(num)] #lst = [20 for _ in range(num)] #lst = [i for i in range(num)] #random.shuffle(lst) if sort == "quick": quick.quick(lst) elif sort == "quick2": quick2.quick(lst) elif sort == "merge": merge.merge(lst) elif sort == "shell": shell.shell(lst) #print (lst)
def time_quick(l): start = time.time() quick.quick(l) return time.time() - start
t2 = time.time() if (usu[0] == -10e100): g.write("Bubble a durat peste 5 secunda; am intrerupt sortarea\n") else: g.write("Bubble a durat: " + str(t2 - t1) + '\n') ############################################################################################## # count ###################################################################################### t1 = time.time() usu = v.copy() usu = count.count(usu) t2 = time.time() g.write("Count a durat: " + str(t2 - t1) + '\n') ############################################################################################## # quick ###################################################################################### t1 = time.time() usu = v.copy() usu = quick.quick(usu) t2 = time.time() g.write("Quick a durat: " + str(t2 - t1) + '\n') ############################################################################################## # radix ###################################################################################### t1 = time.time() usu = v.copy() usu = radix.radix(usu) t2 = time.time() g.write("Radix a durat: " + str(t2 - t1) + '\n') ##############################################################################################