Man*_*ete 1 python bash awk matplotlib
我有一个大文件,其中包含基于所用数量processes和benchmark案例的信息.所有这些信息在同一文件中一个接一个地跟随.
--
# Benchmarking Allgather
# #processes = 8
# ( 3592 additional processes waiting in MPI_Barrier)
#----------------------------------------------------------------
#bytes #repetitions t_min[usec] t_max[usec] t_avg[usec]
0 1000 0.05 0.05 0.05
1 1000 1.77 2.07 1.97
2 1000 1.79 2.08 1.97
4 1000 1.79 2.07 1.98
8 1000 1.82 2.12 2.01
--
# Benchmarking Allgather
# #processes = 16
# ( 3584 additional processes waiting in MPI_Barrier)
#----------------------------------------------------------------
#bytes #repetitions t_min[usec] t_max[usec] t_avg[usec]
0 1000 0.05 0.05 0.05
1 1000 2.34 2.85 2.73
2 1000 2.36 2.87 2.74
4 1000 2.38 2.90 2.76
8 1000 2.42 2.95 2.79
Run Code Online (Sandbox Code Playgroud)
为了快速绘制我计划为每个独立内容创建文件的信息,例如,使用上面给出的信息,我将创建两个名为"Allgather_8"和"Allgather_16"的文件,这些文件的预期内容将是:
$cat Allgather_8
#bytes #repetitions t_min[usec] t_max[usec] t_avg[usec]
0 1000 0.05 0.05 0.05
1 1000 1.77 2.07 1.97
2 1000 1.79 2.08 1.97
4 1000 1.79 2.07 1.98
8 1000 1.82 2.12 2.01
$cat Allgather_16
#bytes #repetitions t_min[usec] t_max[usec] t_avg[usec]
0 1000 0.05 0.05 0.05
1 1000 2.34 2.85 2.73
2 1000 2.36 2.87 2.74
4 1000 2.38 2.90 2.76
8 1000 2.42 2.95 2.79
Run Code Online (Sandbox Code Playgroud)
然后我可以用gnuplot或matplotlib绘制它.
到目前为止我尝试了什么:
我一直在使用grep和awk来提取内容,这适用于独立的部分,但我不知道如何自动化.
有任何想法吗?
awk '
/Benchmarking/ { close(out); out = $NF }
/#processes/ { out = out "_" $NF }
/^[[:space:]]/ { print > out }
' file
Run Code Online (Sandbox Code Playgroud)