def append(filepath=open("./filepath.txt", 'r').readline().strip(), seconds=600): ''' Returns a tuple of (elapsed time, passes) This will go on for 10 minutes or 600 seconds It writes 256 Mb at a time. ''' global cat cat = filepath + "stress_by_append.txt" j = 0 start = end = time.time() choice = "A" while end - start < seconds: try: f = open(cat, 'a') f.write(choice * ((2 ** 20) * 256)) # 256 Mb f.close() except: remove(cat) end = time.time() j += 1 total_time = end - start return(total_time, stat(cat).st_size / total_time)
def writer( filepath=open("./filepath.txt", 'r').readline().strip(), seconds=600): ''' Returns a tuple of (elapsed time, passes) This will go on for 10 minutes or 600 seconds It writes 256 Mb at a time. ''' global cat cat = filepath + "stress_by_write.txt" j = 0 start = end = time.time() while end - start < seconds: choice = random.choice(string.printable) try: f = open(cat, 'w') f.write(choice * ((2**20) * 256)) # ~256 Mb f.close() except: remove(cat) end = time.time() j += 1 total_time = end - start return (total_time, j * 268435456 / total_time)
import remove_file as rf f = 'C:\\Users\\alejandro.apodaca\\Desktop\\batch\\dummy.txt' rf.remove(f) print '\nDone!'
def main(): t, j = append() remove(cat) write("d", j)
def main(): remove("readme.txt")
def main(): t, j = writer() remove(cat) write("b", j)
def main(): t, j = read_test() remove(cat) write("e", j) wrapUp()