@@ -147,6 +147,63 @@ function _resolve_server_metrics_auto()
147147 log " Auto-discovered server-metrics URLs: $metrics_urls "
148148}
149149
150+ function split_csv_sections()
151+ {
152+ # Split a CSV file into separate files based on blank-line delimiters.
153+ # Usage: split_csv_sections <input_file> <output_prefix>
154+ # Produces: <output_prefix>.1.csv, <output_prefix>.2.csv, <output_prefix>.3.csv, ...
155+ local input_file=" $1 "
156+ local output_prefix=" $2 "
157+
158+
159+ echo " $section "
160+ }
161+
162+ function process_result()
163+ {
164+ local profile_path
165+ profile_path=$( find " $result_dir " -type f -name " $aiperf_profile_csv " -print -quit)
166+ if [[ ! -f " $profile_path " ]]; then
167+ log " WARNING: aiperf profile CSV not found: $aiperf_profile_csv "
168+ return
169+ fi
170+
171+ local num_sections=1
172+ local has_content=0
173+ local output_prefix=" ${result_dir} /aiperf_section"
174+
175+ while IFS= read -r line; do
176+ # Strip carriage returns
177+ line=" ${line// $' \r ' / } "
178+ if [[ -z " $line " ]]; then
179+ # Only advance section if the current one had content
180+ if [[ " $has_content " -eq 1 ]]; then
181+ num_sections=$(( num_sections + 1 ))
182+ has_content=0
183+ fi
184+ else
185+ echo " $line " >> " ${output_prefix} .${num_sections} .csv"
186+ has_content=1
187+ fi
188+ done < " $profile_path "
189+
190+ log " Split aiperf CSV into $num_sections section(s)"
191+
192+ # Section 1: per-request percentile metrics → main report
193+ if [[ -f " ${output_prefix} .1.csv" ]]; then
194+ mv " ${output_prefix} .1.csv" " $report_file "
195+ fi
196+
197+ # Section 2: summary metrics
198+ if [[ -f " ${output_prefix} .2.csv" ]]; then
199+ mv " ${output_prefix} .2.csv" " ${result_dir} /aiperf_summary.csv"
200+ fi
201+
202+ # Section 3: server/GPU metrics
203+ if [[ -f " ${output_prefix} .3.csv" ]]; then
204+ mv " ${output_prefix} .3.csv" " ${result_dir} /aiperf_server_metrics.csv"
205+ fi
206+ }
150207
151208function main()
152209{
@@ -186,10 +243,7 @@ function main()
186243
187244 log " Done with aiperf run"
188245
189- profile_path=$( find " $result_dir " -type f -name " $aiperf_profile_csv " -print -quit)
190- if [[ -f " $profile_path " ]]; then
191- sed ' s/\r//g' " $profile_path " > " $report_file "
192- fi
246+ process_result
193247}
194248
195249main " $@ "
0 commit comments