@@ -114,9 +114,11 @@ output_file="/tmp/gh-aw/benchmarks/current_metrics.json"
114114
115115# Initialize JSON
116116echo "{" > "$output_file"
117- echo ' "timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'",' >> "$output_file"
118- echo ' "date": "'$(date -u +%Y-%m-%d)'",' >> "$output_file"
119- echo ' "benchmarks": {' >> "$output_file"
117+ {
118+ echo ' "timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'",'
119+ echo ' "date": "'$(date -u +%Y-%m-%d)'",'
120+ echo ' "benchmarks": {'
121+ } >> "$output_file"
120122
121123first=true
122124while IFS= read -r line; do
@@ -135,18 +137,22 @@ while IFS= read -r line; do
135137 fi
136138
137139 # Write benchmark entry
138- echo -n " \"$name\": {" >> "$output_file"
139- echo -n "\"ns_per_op\": $ns_per_op, " >> "$output_file"
140- echo -n "\"bytes_per_op\": $bytes_per_op, " >> "$output_file"
141- echo -n "\"allocs_per_op\": $allocs_per_op, " >> "$output_file"
142- echo -n "\"iterations\": $iterations" >> "$output_file"
143- echo -n "}" >> "$output_file"
140+ {
141+ echo -n " \"$name\": {"
142+ echo -n "\"ns_per_op\": $ns_per_op, "
143+ echo -n "\"bytes_per_op\": $bytes_per_op, "
144+ echo -n "\"allocs_per_op\": $allocs_per_op, "
145+ echo -n "\"iterations\": $iterations"
146+ echo -n "}"
147+ } >> "$output_file"
144148 fi
145149done < "$results_file"
146150
147- echo "" >> "$output_file"
148- echo " }" >> "$output_file"
149- echo "}" >> "$output_file"
151+ {
152+ echo ""
153+ echo " }"
154+ echo "}"
155+ } >> "$output_file"
150156
151157echo "Parsed benchmark results to $output_file"
152158cat "$output_file"
@@ -173,8 +179,10 @@ if [ ! -f /tmp/gh-aw/repo-memory/default/benchmark_history.jsonl ]; then
173179fi
174180
175181# Append current results to history
176- cat /tmp/gh-aw/benchmarks/current_metrics.json >> /tmp/gh-aw/repo-memory/default/benchmark_history.jsonl
177- echo " " >> /tmp/gh-aw/repo-memory/default/benchmark_history.jsonl
182+ {
183+ cat /tmp/gh-aw/benchmarks/current_metrics.json
184+ echo " "
185+ } >> /tmp/gh-aw/repo-memory/default/benchmark_history.jsonl
178186
179187echo " Historical data updated"
180188```
0 commit comments