@@ -177,16 +177,22 @@ def run_benchmark(name)
177177 height = 40 + row_height * results . size
178178 svg = +"<svg xmlns='http://www.w3.org/2000/svg' width='700' height='#{ height } '>\n "
179179 svg << " <foreignObject width='100%' height='100%'>\n "
180- svg << " <style>table{border-collapse:collapse;font-family:sans-serif;}td,th{border:1px solid #999;padding:4px;text-align:center;}</style>\n "
181- svg << " <table>\n "
182- svg << " <thead><tr><th>#{ COLUMN_NAMES [ :benchmark ] } </th><th>#{ COLUMN_NAMES [ :ruby ] } </th><th>#{ COLUMN_NAMES [ :json ] } </th><th>#{ COLUMN_NAMES [ :capnp ] } </th><th>#{ COLUMN_NAMES [ :pure ] } </th></tr></thead>\n "
180+ cell_style = "style='border:1px solid #999;padding:4px;text-align:center;'"
181+ svg << " <table style='border-collapse:collapse;font-family:sans-serif;'>\n "
182+ svg << " <thead><tr>"
183+ svg << "<th #{ cell_style } >#{ COLUMN_NAMES [ :benchmark ] } </th>"
184+ svg << "<th #{ cell_style } >#{ COLUMN_NAMES [ :ruby ] } </th>"
185+ svg << "<th #{ cell_style } >#{ COLUMN_NAMES [ :json ] } </th>"
186+ svg << "<th #{ cell_style } >#{ COLUMN_NAMES [ :capnp ] } </th>"
187+ svg << "<th #{ cell_style } >#{ COLUMN_NAMES [ :pure ] } </th></tr></thead>\n "
183188 svg << " <tbody>\n "
184- results . each do |r |
189+ results . each_with_index do |r , idx |
190+ row_style = idx . odd? ? " style='background:#f0f0f0;'" : ''
185191 ruby_s = "#{ r [ :ruby_ms ] } ms"
186192 json_s = "#{ r [ :native_ok ] ? '✓' : '✗' } #{ r [ :native_ms ] } ms"
187193 capnp_s = "#{ r [ :native_bin_ms ] } ms"
188194 pure_s = "#{ r [ :pure_ok ] ? '✓' : '✗' } #{ r [ :pure_ms ] } ms"
189- svg << " <tr><td>#{ r [ :name ] } </td><td>#{ ruby_s } </td><td>#{ json_s } </td><td>#{ capnp_s } </td><td>#{ pure_s } </td></tr>\n "
195+ svg << " <tr#{ row_style } ><td #{ cell_style } >#{ r [ :name ] } </td><td #{ cell_style } >#{ ruby_s } </td><td #{ cell_style } >#{ json_s } </td><td #{ cell_style } >#{ capnp_s } </td><td #{ cell_style } >#{ pure_s } </td></tr>\n "
190196 end
191197 svg << " </tbody>\n "
192198 svg << " </table>\n "
0 commit comments