Advertisement
Konark

Untitled

Feb 2nd, 2021
596
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.92 KB | None | 0 0
  1.         while True:
  2.         start = time.time()
  3.         print(buffering)
  4.         if buffering:
  5.             with open(file=file_path, buffering=buffering, encoding=encoding) as file:
  6.                 file.read()
  7.         else:
  8.             with open(file=file_path, encoding=encoding) as file:
  9.                 file.read()
  10.             buffering = 1
  11.  
  12.         end = time.time()
  13.         result_old = result_new
  14.         result_new = end - start
  15.         print(result_old)
  16.         print(result_new)
  17.         if i:
  18.             if result_new > result_old:
  19.                 print('Минимальное время выполнения: {0:.20f} секунд.'.format(result_old))
  20.                 print('Buffer size: ' + str(buffering))
  21.                 break
  22.             else:
  23.                 if buffering == 1:
  24.                     buffering = 2
  25.                 else:
  26.                     buffering = buffering ** 2
  27.         i += 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement