@@ -45,26 +45,29 @@ def main():
4545
4646 with save_dir .joinpath (f"{ name } _cpu.txt" ).open ("w+" ) as fp_cpu , save_dir .joinpath (f"{ name } _memory.txt" ).open ("w+" ) as fp_mem :
4747 num_cores = os .cpu_count ()
48- cpu_threads = int (num_cores * args .percent_cpu )
49- mem_threads = int (num_cores * (1 - args .percent_cpu ))
48+ cpu_threads = int (args .percent_cpu * 10 )
49+ mem_threads = int (10 - cpu_threads )
50+
5051 print (cpu_threads , mem_threads )
51- print ("Starting CPU benchmark..." )
52- sysbench_cpu_args = [arg for arg in other if arg .startswith ("--cpu" )] + [f"--threads={ cpu_threads } " ]
53- proc_cpu = subprocess .Popen (
54- [
55- "time" , "timeout" , f"{ args .time } s" , "sysbench" , "cpu" ,
56- * sysbench_cpu_args , "run"
57- ],
58- stdout = fp_cpu , stderr = fp_cpu
59- )
60-
61- print ("Starting Memory benchmark..." )
62- sysbench_mem_args = [arg for arg in other if arg .startswith ("--memory" )] + [f"--time={ args .time } " , f"--threads={ mem_threads } " ]
63- proc_mem = subprocess .Popen (
64- ["time" , "sysbench" , "memory" , "run" ,* sysbench_mem_args ],
65- stdout = fp_mem , stderr = fp_mem
66- )
6752
53+ for _ in range (num_cores ):
54+ print ("Starting CPU benchmark..." )
55+ sysbench_cpu_args = [arg for arg in other if arg .startswith ("--cpu" )] + [f"--threads={ cpu_threads } " ]
56+ proc_cpu = subprocess .Popen (
57+ [
58+ "time" , "timeout" , f"{ args .time } s" , "sysbench" , "cpu" ,
59+ * sysbench_cpu_args , "run"
60+ ],
61+ stdout = fp_cpu , stderr = fp_cpu
62+ )
63+
64+ print ("Starting Memory benchmark..." )
65+ sysbench_mem_args = [arg for arg in other if arg .startswith ("--memory" )] + [f"--time={ args .time } " , f"--threads={ mem_threads } " ]
66+ proc_mem = subprocess .Popen (
67+ ["time" , "sysbench" , "memory" , "run" ,* sysbench_mem_args ],
68+ stdout = fp_mem , stderr = fp_mem
69+ )
70+
6871 proc_cpu .wait ()
6972 proc_mem .wait ()
7073
0 commit comments