Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. n = [10,20,50,100,250]
  2. f = ['zero_smart', 'zero_naive', 'zero_main', 'randz_smart'
  3. , 'randz_naive', 'randz_main']
  4. endtable = []
  5. for _n in n:
  6. for _f in f:
  7. for i in range(1,5):
  8. data = 0
  9. ln = 0
  10. filestr = 'result_' + _f + \
  11. '_Thread-' + str(i) + '_n_' + str(_n) + '_numit_25'
  12. try:
  13. with open(filestr, 'r') as myfile:
  14. lines = myfile.readlines()
  15. except:
  16. print('error: ' + filestr)
  17. lines = ['0']
  18. lines = lines[0]
  19. lines = lines.split(', ')
  20. lines = [int(q) for q in lines]
  21. data += sum(lines)
  22. ln += len(lines)
  23. res = data/ln
  24. norm = res/(int(_n))
  25. header = (_f, str(_n), str(res), str(norm))
  26. endtable.append(header)
  27.  
  28. for name, n, res, norm in sorted(endtable, key=lambda x:x[0]):
  29. h = name+', n='+n+', res='+res+', norm='+norm+'\n'
  30. with open('final_rep', 'a+') as finalrep:
  31. finalrep.write(h)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement