serialbench 0.1.3 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/benchmark.yml +71 -51
  3. data/Gemfile +2 -0
  4. data/README.adoc +5 -0
  5. data/lib/serialbench/cli/resultset_cli.rb +40 -0
  6. data/lib/serialbench/models/platform.rb +5 -2
  7. data/lib/serialbench/serializers/json/rapidjson_serializer.rb +0 -4
  8. data/lib/serialbench/serializers/xml/base_xml_serializer.rb +6 -1
  9. data/lib/serialbench/serializers/xml/leptris_serializer.rb +167 -0
  10. data/lib/serialbench/serializers/xml/libxml_serializer.rb +9 -0
  11. data/lib/serialbench/serializers/xml/nokogiri_serializer.rb +9 -0
  12. data/lib/serialbench/serializers/xml/oga_serializer.rb +4 -0
  13. data/lib/serialbench/serializers/yaml/base_yaml_serializer.rb +1 -3
  14. data/lib/serialbench/serializers/yaml/psych_serializer.rb +0 -4
  15. data/lib/serialbench/serializers.rb +3 -1
  16. data/lib/serialbench/site_generator.rb +56 -2
  17. data/lib/serialbench/version.rb +1 -1
  18. data/site/.gitignore +5 -0
  19. data/site/README.md +32 -0
  20. data/site/astro.config.mjs +12 -0
  21. data/site/package-lock.json +6160 -0
  22. data/site/package.json +22 -0
  23. data/site/public/favicon.svg +4 -0
  24. data/site/scripts/gen-sample-data.mjs +154 -0
  25. data/site/src/components/AvailabilityMatrix.astro +61 -0
  26. data/site/src/components/CalibratedLeaderboard.vue +134 -0
  27. data/site/src/components/CitationBox.vue +50 -0
  28. data/site/src/components/DashboardConsole.vue +193 -0
  29. data/site/src/components/FeaturesTable.astro +97 -0
  30. data/site/src/components/MemoryPanel.vue +44 -0
  31. data/site/src/components/OpsChart.vue +135 -0
  32. data/site/src/config.ts +18 -0
  33. data/site/src/layouts/Layout.astro +85 -0
  34. data/site/src/lib/channels.ts +24 -0
  35. data/site/src/lib/dashboard.ts +269 -0
  36. data/site/src/pages/index.astro +44 -0
  37. data/site/src/pages/library/[slug].astro +128 -0
  38. data/site/src/pages/methodology.astro +55 -0
  39. data/site/src/styles/global.css +103 -0
  40. data/site/tsconfig.json +5 -0
  41. metadata +26 -2
@@ -30,6 +30,48 @@ module Serialbench
30
30
  generator.generate_site
31
31
  end
32
32
 
33
+ def self.resultset_payload(resultset)
34
+ new(output_path: '/dev/null', resultset: resultset).resultset_payload
35
+ end
36
+
37
+ def self.export_raw_data(resultset, data_dir)
38
+ new(output_path: '/dev/null', resultset: resultset).export_raw_data_to(data_dir)
39
+ end
40
+
41
+ def resultset_payload
42
+ transform_resultset_for_dashboard(@resultset)
43
+ .merge('libraries' => libraries_information(@resultset))
44
+ end
45
+
46
+ # Static capability matrix (adapter declarations) plus the versions
47
+ # actually measured in this resultset.
48
+ def libraries_information(resultset)
49
+ versions = {}
50
+ resultset.results.each do |result|
51
+ serializers = result.benchmark_result.serializers || []
52
+ serializers.each { |si| versions[si.name] ||= si.version }
53
+ end
54
+
55
+ Serialbench::Serializers.all.filter_map do |adapter|
56
+ next if adapter.name == 'syck'
57
+
58
+ features = adapter.features
59
+ next if features.is_a?(Array)
60
+
61
+ {
62
+ 'name' => adapter.name,
63
+ 'format' => adapter.format.to_s,
64
+ 'version' => versions[adapter.name] || 'unknown',
65
+ 'features' => features.transform_values { |v| v == true }
66
+ }
67
+ end
68
+ end
69
+
70
+ def export_raw_data_to(data_dir)
71
+ FileUtils.mkdir_p(data_dir)
72
+ export_resultset(@resultset, data_dir)
73
+ end
74
+
33
75
  def generate_site
34
76
  target_name = @result ? @result.environment_config.name : @resultset.name
35
77
 
@@ -140,6 +182,18 @@ module Serialbench
140
182
  }
141
183
  end
142
184
 
185
+ # Environment identity for the site: use the CI platform_string
186
+ # ("macos-26-ruby-3.4") when it is runner-shaped, so each runner label is
187
+ # its own environment; fall back to os-arch for other sources (docker,
188
+ # local runs, older resultsets).
189
+ def env_identity(result)
190
+ platform_string = result.platform.platform_string
191
+ ruby = result.platform.ruby_version
192
+ return platform_string if platform_string&.end_with?("-ruby-#{ruby}")
193
+
194
+ "#{result.platform.os}-#{result.platform.arch}-ruby-#{ruby}"
195
+ end
196
+
143
197
  # Transform a ResultSet (collection of Results) into dashboard-compatible format
144
198
  # Combines all results into a single dashboard structure
145
199
  def transform_resultset_for_dashboard(resultset)
@@ -148,7 +202,7 @@ module Serialbench
148
202
 
149
203
  resultset.results.each do |result|
150
204
  # Create unique env key for this result
151
- env_key = "#{result.platform.os}-#{result.platform.arch}-ruby-#{result.platform.ruby_version}"
205
+ env_key = env_identity(result)
152
206
 
153
207
  # Merge this result's data into combined_results
154
208
  result_combined = build_combined_results(result, env_key)
@@ -258,7 +312,7 @@ module Serialbench
258
312
 
259
313
  def export_single_result(result, data_dir)
260
314
  # Create filename based on platform info
261
- env_key = "#{result.platform.os}-#{result.platform.arch}-ruby-#{result.platform.ruby_version}"
315
+ env_key = env_identity(result)
262
316
  filename = "#{env_key}.yaml"
263
317
  filepath = File.join(data_dir, filename)
264
318
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Serialbench
4
- VERSION = '0.1.3'
4
+ VERSION = '0.2.0'
5
5
  end
data/site/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ node_modules/
2
+ dist/
3
+ .astro/
4
+ src/data/sample.json
5
+ public/data/
data/site/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # serialbench site
2
+
3
+ The benchmark console at https://metanorma.github.io/serialbench/.
4
+
5
+ Astro 7 (Vite 8) with Vue islands and Tailwind 4. Charts are Chart.js 4,
6
+ bundled — no CDN.
7
+
8
+ ## Develop
9
+
10
+ ```
11
+ npm install
12
+ npm run generate:sample-data # writes src/data/sample.json (gitignored)
13
+ npm run dev # http://localhost:4321/serialbench/
14
+ ```
15
+
16
+ `src/data/sample.json` is generated from the race numbers in
17
+ `scripts/gen-sample-data.mjs` and is ignored by git. In CI the real payload
18
+ (written by `serialbench resultset export-data`) replaces it before
19
+ `astro build`; the shape is identical — see `src/lib/dashboard.ts`.
20
+
21
+ ## Data contract
22
+
23
+ ```
24
+ combined_results[op][size][format][serializer][envKey] = {
25
+ iterations_per_second, time_per_iteration # perf ops
26
+ allocated_memory, retained_memory # op == "memory"
27
+ }
28
+ environments[envKey] = { ruby_version, os, arch, timestamp, ... }
29
+ metadata = { resultset_name, total_runs, generated_at }
30
+ ```
31
+
32
+ Missing entries mean "not measured on that leg" — never zero.
@@ -0,0 +1,12 @@
1
+ import { defineConfig } from 'astro/config';
2
+ import vue from '@astrojs/vue';
3
+ import tailwindcss from '@tailwindcss/vite';
4
+
5
+ export default defineConfig({
6
+ site: 'https://metanorma.github.io',
7
+ base: '/serialbench/',
8
+ integrations: [vue()],
9
+ vite: {
10
+ plugins: [tailwindcss()],
11
+ },
12
+ });