@@ -33,71 +33,80 @@ jobs:
3333
3434 input = File.read('benchmark_output.txt')
3535
36- # Split into writing and reading sections
37- sections = input.split(/^===/)
38-
39- def parse_section(section, title)
40- lines = section.lines
36+ def parse_section(text, title)
37+ lines = text.lines.map(&:chomp)
4138 results = []
39+ comparisons = []
40+ in_comparison = false
41+ in_calculating = false
4242
4343 lines.each do |line|
44- # Match lines like: "rscsv 123.456k (± 5.0%) i/s - 100.000k in 0.500000s"
45- if line =~ /^(\w[\w\s]+?)\s+(\d+\.?\d*[kM]?)\s+\([^)]+\)\s+i\/s/
44+ # Start of calculation section
45+ if line =~ /^Calculating/
46+ in_calculating = true
47+ next
48+ end
49+
50+ # Match result lines after "Calculating" section
51+ # Format: " Ruby CSV 463.779 (± 2.4%) i/s (2.16 ms/i) - ..."
52+ if in_calculating && line =~ /^\s*(.+?)\s\s+(\d+\.?\d*)\s+\(.+?\)\s+i\/s/
4653 name = $1.strip
4754 ips = $2
4855 results << { name: name, ips: ips }
56+ elsif line =~ /^Comparison:/
57+ in_comparison = true
58+ in_calculating = false
59+ elsif in_comparison && line.strip =~ /^(.+?):\s+(.+)/
60+ comparisons << "- **#{$1.strip}**: #{$2.strip}"
4961 end
5062 end
5163
5264 return nil if results.empty?
5365
5466 # Build markdown table
5567 table = "### #{title}\n\n"
56- table += "| Library | Iterations/second |\n"
57- table += "|---------|------------------ |\n"
68+ table += "| Library | Iterations/sec |\n"
69+ table += "|---------|---------------|\n"
5870
5971 results.each do |result|
6072 table += "| #{result[:name]} | #{result[:ips]} |\n"
6173 end
6274
6375 # Add comparison info
64- comparison_start = lines.index { |l| l =~ /Comparison:/ }
65- if comparison_start
76+ if !comparisons.empty?
6677 table += "\n**Comparison:**\n\n"
67- lines[(comparison_start + 1)..-1].each do |line|
68- line = line.strip
69- next if line.empty?
70- # Format comparison lines
71- if line =~ /(.+?):\s+(.+)/
72- table += "- #{$1.strip}: #{$2.strip}\n"
73- end
74- end
78+ table += comparisons.join("\n") + "\n"
7579 end
7680
7781 table
7882 end
7983
80- output = "## Benchmark Results\n\n"
81- output += "*Benchmarks run with YJIT enabled on Ruby #{RUBY_VERSION}*\n\n"
84+ output = "## 🚀 Benchmark Results\n\n"
85+ output += "_Benchmarks run with YJIT enabled on Ruby #{RUBY_VERSION}_\n\n"
86+
87+ # Split by === markers to get sections
88+ sections = input.split(/^=== /)
8289
8390 sections.each do |section|
84- if section =~ / CSV Writing/
85- result = parse_section(section, "CSV Writing Performance")
86- output += result + "\n\n " if result
87- elsif section =~ / CSV Reading/
88- result = parse_section(section, "CSV Reading Performance")
89- output += result + "\n\n " if result
91+ if section.include?(" CSV Writing Benchmark")
92+ result = parse_section(section, "📝 CSV Writing Performance")
93+ output += result + "\n" if result
94+ elsif section.include?(" CSV Reading Benchmark")
95+ result = parse_section(section, "📖 CSV Reading Performance")
96+ output += result + "\n" if result
9097 end
9198 end
9299
93100 # Write to GitHub Step Summary
94101 if ENV['GITHUB_STEP_SUMMARY']
95102 File.write(ENV['GITHUB_STEP_SUMMARY'], output)
96- puts "Results written to GitHub Actions summary"
103+ puts "✅ Results written to GitHub Actions summary"
104+ else
105+ puts "⚠️ GITHUB_STEP_SUMMARY not available, printing to stdout:"
97106 end
98107
99108 # Also print to stdout
100- puts output
109+ puts "\n" + output
101110 EOF
102111
103112 ruby parse_benchmark.rb
0 commit comments