@@ -43,31 +43,35 @@ def main():
4343 proc = subprocess .Popen (["sysbench" , "fileio" , * sysbench_file_input_args , "cleanup" ], stdout = fp , stderr = fp )
4444 proc .wait ()
4545
46- 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 :
46+ 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 , save_dir . joinpath ( f" { name } _ps_log.txt" ). open ( "w+" ) as fp_ps :
4747 num_cores = os .cpu_count ()
4848 cpu_threads = int (args .percent_cpu * 10 )
4949 mem_threads = int (10 - cpu_threads )
5050
5151 print (cpu_threads , mem_threads )
5252
53- for _ in range (num_cores ):
53+ for i in range (num_cores ):
5454 print ("Starting CPU benchmark..." )
55- sysbench_cpu_args = [arg for arg in other if arg .startswith ("--cpu" )] + [f"--threads={ cpu_threads } " ]
55+ sysbench_cpu_args = [arg for arg in other if arg .startswith ("--cpu" )] + [f"--time= { args . time } " , f"-- threads={ cpu_threads } " ]
5656 proc_cpu = subprocess .Popen (
5757 [
58- "time" , "timeout" , f"{ args .time } s" , "sysbench" , "cpu" ,
58+ "sysbench" , "cpu" , "--forced-shutdown=0" , # time", "timeout", f"{args.time}s",
5959 * sysbench_cpu_args , "run"
6060 ],
6161 stdout = fp_cpu , stderr = fp_cpu
6262 )
63+ os .sched_setaffinity (proc_cpu .pid , {i })
6364
6465 print ("Starting Memory benchmark..." )
6566 sysbench_mem_args = [arg for arg in other if arg .startswith ("--memory" )] + [f"--time={ args .time } " , f"--threads={ mem_threads } " ]
6667 proc_mem = subprocess .Popen (
67- ["time" , " sysbench" , "memory" , "run" ,* sysbench_mem_args ],
68+ ["sysbench" , "memory" , "run" ,* sysbench_mem_args ], #"time",
6869 stdout = fp_mem , stderr = fp_mem
6970 )
70-
71+ os .sched_setaffinity (proc_mem .pid , {i })
72+
73+ proc = subprocess .Popen (["ps" , "-o" ,"pid,psr,comm,thcount" ], stdout = fp_ps )
74+ proc .wait ()
7175 proc_cpu .wait ()
7276 proc_mem .wait ()
7377
0 commit comments