Advertisement
Guest User

Untitled

a guest
Oct 16th, 2022
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.86 KB | None | 0 0
  1. import os
  2.  
  3.  
  4. tmp_filename = 'tmp_res'
  5. array_size_fixed = 10_000_000
  6. array_sizes = [10_000_000, 20_000_000, 30_000_000, 40_000_000, 50_000_000, 60_000_000, 70_000_000]
  7. queries_fixed = 1
  8. queries_count = [10_000_000, 20_000_000, 30_000_000, 40_000_000, 50_000_000, 60_000_000, 70_000_000]
  9. threads_count = [1, 2, 4, 8, 16, 32, 64]
  10. launch_count = 20
  11.  
  12.  
  13. if __name__ == '__main__':
  14.     queries_and_threads = []
  15.     for threads in threads_count:
  16.         cur_queries_times = []
  17.         for queries in queries_count:
  18.             print('array_size: {}, queries: {}, threads: {}'.format(array_size_fixed, queries, threads))
  19.             os.system('./range_tree {} {} {} {} > {}'.format(threads, array_size_fixed, queries, launch_count, tmp_filename))
  20.             with open(tmp_filename, 'r') as f:
  21.                 build_time, queries_time = map(float, f.readline().split())
  22.                 cur_queries_times.append(queries_time)
  23.         queries_and_threads.append(cur_queries_times)
  24.     print('row corresponds to queries count:', queries_count)
  25.     print('column corresponds to threads count:', threads_count)
  26.     print(queries_and_threads)
  27.  
  28.     arrays_and_threads = []
  29.     for threads in threads_count:
  30.         cur_array_times = []
  31.         for array_size in array_sizes:
  32.             print('array_size: {}, queries: {}, threads: {}'.format(array_size, queries_fixed, threads))
  33.             os.system('./range_tree {} {} {} {} > {}'.format(threads, array_size, queries_fixed, launch_count, tmp_filename))
  34.             with open(tmp_filename, 'r') as f:
  35.                 build_time, queries_time = map(float, f.readline().split())
  36.                 cur_array_times.append(build_time)
  37.         arrays_and_threads.append(cur_array_times)
  38.     print('row corresponds to array sizes:', array_sizes)
  39.     print('column corresponds to threads count:', threads_count)
  40.     print(arrays_and_threads)
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement