daily pastebin goal
59%
SHARE
TWEET

Untitled

a guest Jan 18th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. import shlex, subprocess, re
  3. import os,re
  4. from time import sleep
  5. import pickle,argparse
  6. import math
  7. import time
  8.  
  9. dir_path = os.path.dirname(os.path.realpath(__file__))
  10. def run_test(num_bundles, bundle_size, num_instances=1, num_cores=12):
  11.     start_time = time.time()
  12.     print("\nRunning test:")
  13.     print("  Bundle count:\t{}".format(num_bundles))
  14.     print("  Bundle size:\t{}".format(bundle_size))
  15.     print("  Endpoints:\t{}".format(num_instances))
  16.     print("  Cores:\t{}".format(num_cores))
  17.     print()
  18.     counters = []
  19.     for i in range(num_instances):
  20.         corelist = "0-{}".format(num_cores-1)
  21.         command = "taskset -c {} bpcounter ipn:3.{} {}".format(corelist,i+1,num_bundles)
  22.         args = shlex.split(command)
  23.         p = subprocess.Popen(args,stdout=subprocess.PIPE, cwd=dir_path+"/3.bench.tcp")
  24.         counters.append(p)
  25.     sleep(1)
  26.     for i in range(num_instances):
  27.         command = "taskset -c {} bpdriver {} ipn:2.{} ipn:3.{} -{}".format(corelist,num_bundles,i+1,i+1,bundle_size)
  28.         args = shlex.split(command)
  29.         p = subprocess.Popen(args,stdout=subprocess.PIPE, cwd=dir_path+"/2.bench.tcp")
  30.  
  31.     s = 0
  32.     count = 0
  33.     for i,p in enumerate(counters):
  34.         while True:
  35.             l = p.stdout.readline().decode("utf-8")
  36.             if re.search('received', l):
  37.                 pass
  38.            
  39.             res = re.search('(?<=Throughput \(Mbps\)\: )[0-9]*\.[0-9]*',l)
  40.             if res:
  41.                 split = l.split(' ')
  42.                 num = float(split[2].strip())
  43.                 s+=num
  44.                 count+=1
  45.                 # print("endpoint {}: {} Mbps".format(i+1,num))
  46.                 break
  47.             if l == "":
  48.                 break
  49.     elapsed_time = time.time() - start_time
  50.     print("time: {} s".format(round(elapsed_time,2)))
  51.     print("Throughput: {} Mbps".format(s))
  52.     if count == 0:
  53.         return 0
  54.     else:
  55.         return s
  56.  
  57.  
  58. parser = argparse.ArgumentParser(description='Process some integers.')
  59. parser.add_argument('--graph', metavar='data_file',type=str, nargs=1)
  60. args = parser.parse_args()
  61.  
  62. if args.graph:
  63.     filename = args.graph[0]
  64.     data = pickle.load(open(filename,'rb'))
  65.     print(data)
  66.  
  67.     quit()
  68.  
  69. def restart_ion(num_cores):
  70.     print("running killm...\r",end="")
  71.     killm = subprocess.Popen(["killm"],stdout=subprocess.PIPE)
  72.     killm.wait()
  73.     sleep(1)
  74.     print("running killm... done")
  75.     print("starting ion nodes...\r",end="")
  76.  
  77.     corelist = "0-{}".format(num_cores-1)
  78.     command = "taskset -c {} ./ionstart".format(corelist)
  79.     args = shlex.split(command)
  80.     p1 = subprocess.Popen(args,stdout=subprocess.PIPE,stderr=subprocess.STDOUT,cwd=dir_path+"/2.bench.tcp")
  81.     p2 = subprocess.Popen(args,stdout=subprocess.PIPE,stderr=subprocess.STDOUT,cwd=dir_path+"/3.bench.tcp")
  82.     p1.wait()
  83.     p2.wait()
  84.     print("starting ion nodes... done")
  85.     sleep(3)
  86.  
  87. # args = shlex.split(command)
  88. # print("running killm...\r",end="")
  89. # killm = subprocess.Popen(["killm"],stdout=subprocess.PIPE)
  90. # killm.wait()
  91. # sleep(1)
  92. # print("running killm... done")
  93. # print("starting ion nodes...\r",end="")
  94. # p1 = subprocess.Popen(["./ionstart"],stdout=subprocess.PIPE,stderr=subprocess.STDOUT,cwd=dir_path+"/2.bench.tcp")
  95. # p2 = subprocess.Popen(["./ionstart"],stdout=subprocess.PIPE,stderr=subprocess.STDOUT,cwd=dir_path+"/3.bench.tcp")
  96. # p1.wait()
  97. # p2.wait()
  98.  
  99. # print("starting ion nodes... done")
  100. # sleep(3)
  101. # throughput = run_test(50000, 10000, 10)
  102. # print("Throughput: {} Mbps".format(throughput))
  103.  
  104. tests = {}
  105.  
  106. tests = pickle.load(open("tests.p","rb"))
  107.  
  108. bundle_sizes = [4000,8000,16000,32000,64000,128000,256000,512000]
  109. bundle_count = 50000
  110. runs = 1
  111. instances = [1,2,3,4,5,6,7,8,9,10,11,12]
  112. print(instances)
  113. for cores in range(1,13):
  114.     restart_ion(cores)
  115.     core_instances = {}
  116.     if cores in tests:
  117.         core_instances = tests[cores]
  118.     for num_instances in instances:
  119.         bundle_tests = {}
  120.         if num_instances in core_instances:
  121.             bundle_tests = core_instances[num_instances]
  122.  
  123.         scaled_bundle_count = int(bundle_count/num_instances)
  124.         for bundle_size in bundle_sizes:
  125.             if bundle_size in bundle_tests and bundle_tests[bundle_size] != 0:
  126.                 continue
  127.             s = 0
  128.             for i in range(runs):
  129.                 s += run_test(scaled_bundle_count,bundle_size,num_instances,cores)
  130.  
  131.             bundle_tests[bundle_size] = s/runs
  132.         core_instances[num_instances] = bundle_tests
  133.         tests[cores] = core_instances
  134.         pickle.dump(tests,open('tests.p','wb'))
  135.     tests[cores] = core_instances
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top