serialbench 0.4.0 → 0.5.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e90d8b6ebc8deebf308b1e02214b978597d0d2a9699c3845ebf6405953d733b7
4
- data.tar.gz: 4cc9e46139f7054919657d66fd26ed6b40430856e0bdd317f2677451bc1bf715
3
+ metadata.gz: 7267d278bec24e38ca217bfbf164c10411f03b4fb333295f05c617c56f91a8b8
4
+ data.tar.gz: fcf4034a75ee9615197e2fd0cd3e7b63a795c7f3f0b1ba2c3b1cd0170babecb6
5
5
  SHA512:
6
- metadata.gz: 38652e0714893c8ed9590fe1a7ef29c9c6e94cdbdcb0104d9190d12bad1c95f8635680b904d66b9edda72f55f7c037ce5e18894bf5fb66d5b88db21ba2dcaa3d
7
- data.tar.gz: 728e8ee7c92138afdfd722cfb93ef7463c22e7d1c8882e5d83507dba7861637addd659e489df21c91a80a45680fc532eb0898f9ffed9ce48402a604962b73c85
6
+ metadata.gz: 4acd59cfc6d0b8d47d1d09172ea2f034063633ba5435fccc2fcfbd35ec11d96d41080210d84d149423979b3e14873cf3833512d36917515dfdb0ccdb698dfc1f
7
+ data.tar.gz: a913c26df13272e009996925fc6dd4789f74c6f968d27cd02da6155b71f1026d03e8bc2bb1cef1ba400ca19170b3c5a7f0d04ab125658ebf8a54c14551c5607b
@@ -3,11 +3,7 @@ name: benchmark-weekly
3
3
  on:
4
4
  push:
5
5
  branches: [main]
6
- paths-ignore:
7
- - '.github/workflows/windows-debug.yml'
8
6
  pull_request:
9
- paths-ignore:
10
- - '.github/workflows/windows-debug.yml'
11
7
  schedule:
12
8
  # Run benchmarks weekly on Sundays at 2 AM UTC
13
9
  - cron: '0 2 * * 0'
@@ -1,26 +1,23 @@
1
- # Auto-generated by Cimas: Do not edit it manually!
2
- # See https://github.com/metanorma/cimas
3
1
  name: rake
4
2
 
5
3
  on:
6
4
  push:
7
- branches: [ master, main ]
5
+ branches: [ main ]
8
6
  tags: [ v* ]
9
- paths-ignore:
10
- - '.github/workflows/windows-debug.yml'
11
7
  pull_request:
12
- paths-ignore:
13
- - '.github/workflows/windows-debug.yml'
8
+
9
+ permissions:
10
+ contents: read
14
11
 
15
12
  jobs:
16
- rake:
17
- uses: metanorma/ci/.github/workflows/generic-rake.yml@main
18
- with:
19
- before-setup-ruby: |
20
- vcpkg install libxml2:x64-windows 2>&1 || true
21
- vcpkg integrate install 2>&1 || true
22
- mkdir -p .bundle 2>&1 || true
23
- echo "---" > .bundle/config 2>&1 || true
24
- echo 'BUNDLE_BUILD__LIBXML___RUBY: "--with-xml2-dir=C:/vcpkg/installed/x64-windows --with-xml2-include=C:/vcpkg/installed/x64-windows/include/libxml2 --with-xml2-lib=C:/vcpkg/installed/x64-windows/lib"' >> .bundle/config 2>&1 || true
25
- secrets:
26
- pat_token: ${{ secrets.METANORMA_CI_PAT_TOKEN }}
13
+ rspec:
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+
18
+ - uses: ruby/setup-ruby@v1
19
+ with:
20
+ ruby-version: '3.4'
21
+ bundler-cache: true
22
+
23
+ - run: bundle exec rspec --format progress
@@ -17,8 +17,8 @@ iterations:
17
17
  large: 1
18
18
 
19
19
  operations:
20
- - parse
21
- - generate
20
+ - parsing
21
+ - generation
22
22
  - streaming
23
23
  - memory
24
24
 
@@ -17,8 +17,8 @@ iterations:
17
17
  large: 1
18
18
 
19
19
  operations:
20
- - parse
21
- - generate
20
+ - parsing
21
+ - generation
22
22
  - streaming
23
23
  - memory
24
24
 
@@ -17,8 +17,8 @@ iterations:
17
17
  large: 1
18
18
 
19
19
  operations:
20
- - parse
21
- - generate
20
+ - parsing
21
+ - generation
22
22
  - streaming
23
23
  - xpath
24
24
  - memory
@@ -17,8 +17,8 @@ iterations:
17
17
  large: 1
18
18
 
19
19
  operations:
20
- - parse
21
- - generate
20
+ - parsing
21
+ - generation
22
22
  - streaming
23
23
  - memory
24
24
 
@@ -25,8 +25,8 @@ iterations:
25
25
  large: 1
26
26
 
27
27
  operations:
28
- - parse
29
- - generate
28
+ - parsing
29
+ - generation
30
30
  - streaming
31
31
  - xpath
32
32
  - memory
@@ -19,8 +19,8 @@ iterations:
19
19
  large: 1
20
20
 
21
21
  operations:
22
- - parse
23
- - generate
22
+ - parsing
23
+ - generation
24
24
  - streaming
25
25
 
26
26
  warmup: 2
@@ -21,6 +21,7 @@ module Serialbench
21
21
  @serializers = Serializers.available
22
22
  @test_data = {}
23
23
  @results = []
24
+ validate_operations!
24
25
  load_test_data
25
26
  end
26
27
 
@@ -45,11 +46,13 @@ module Serialbench
45
46
  puts "Test data sizes: #{@test_data.keys.join(', ')}"
46
47
  puts
47
48
 
49
+ selected = @benchmark_config.operations
50
+ selected = OPERATIONS.keys + ['memory'] if selected.nil? || selected.empty?
48
51
  results = {}
49
52
  OPERATIONS.each do |name, handler|
50
- results[name.to_sym] = run_benchmark_type(name, name, &handler)
53
+ results[name.to_sym] = selected.include?(name) ? run_benchmark_type(name, name, &handler) : []
51
54
  end
52
- results[:memory] = run_memory_benchmarks
55
+ results[:memory] = selected.include?('memory') ? run_memory_benchmarks : []
53
56
 
54
57
  Models::BenchmarkResult.new(
55
58
  serializers: Serializers.information,
@@ -165,6 +168,13 @@ module Serialbench
165
168
  end
166
169
  end
167
170
 
171
+ def validate_operations!
172
+ unknown = (@benchmark_config.operations || []) - (OPERATIONS.keys + ['memory'])
173
+ return if unknown.empty?
174
+
175
+ raise ArgumentError, "unknown operations #{unknown.inspect}; expected: #{OPERATIONS.keys.join(', ')}, memory"
176
+ end
177
+
168
178
  def load_test_data
169
179
  @test_data = TestData.load(@benchmark_config)
170
180
  end
@@ -284,7 +284,6 @@ module Serialbench
284
284
 
285
285
  say '✅ Local benchmark completed successfully!', :green
286
286
  say "Results saved to: #{result_dir}", :cyan
287
- say "Generate site: serialbench benchmark build-site #{result_dir}", :white
288
287
  rescue StandardError => e
289
288
  say "❌ Local benchmark failed: #{e.message}", :red
290
289
  say "Details: #{e.backtrace.first(3).join("\n")}", :white if options[:verbose]
@@ -308,7 +307,6 @@ module Serialbench
308
307
 
309
308
  say '✅ Docker benchmark completed successfully!', :green
310
309
  say "Results saved to: #{result_dir}", :cyan
311
- say "Generate site: serialbench benchmark build-site #{result_dir}", :white
312
310
  rescue StandardError => e
313
311
  say "❌ Docker benchmark failed: #{e.message}", :red
314
312
  say "Details: #{e.backtrace.first(3).join("\n")}", :white if options[:verbose]
@@ -357,92 +355,21 @@ module Serialbench
357
355
  exit 1
358
356
  end
359
357
 
360
- # def execute_local_benchmark(environment, config, benchmark_config_path)
361
- # say '🏠 Executing local benchmark', :green
362
-
363
- # # Create benchmark runner with config
364
- # runner_options = {
365
- # formats: (config['formats'] || %w[xml json yaml toml]).map(&:to_sym),
366
- # iterations: config['iterations'] || 10,
367
- # warmup: config['warmup'] || 3,
368
- # config: config
369
- # }
370
-
371
- # runner = Serialbench::BenchmarkRunner.new(**runner_options)
372
-
373
- # # Run benchmarks
374
- # say "Running benchmarks with #{runner_options[:iterations]} iterations...", :white
375
- # results = runner.run_all_benchmarks
376
-
377
- # # Create platform-specific directory name using environment's ruby_build_tag
378
- # require_relative '../models/platform'
379
- # platform = Serialbench::Models::Platform.current_local
380
- # platform_string = "local-#{platform.os}-#{platform.arch}-ruby-#{environment['ruby_build_tag']}"
381
-
382
- # # Create results directory
383
- # result_dir = "results/runs/#{environment['name']}"
384
- # FileUtils.mkdir_p(result_dir)
385
-
386
- # # Save results to single YAML file with platform and metadata merged in
387
- # results_file = File.join(result_dir, 'results.yaml')
388
- # full_results = {
389
- # 'platform' => {
390
- # 'platform_string' => platform_string,
391
- # 'os' => platform.os,
392
- # 'arch' => platform.arch
393
- # },
394
- # 'metadata' => {
395
- # 'environment_name' => environment['name'],
396
- # 'benchmark_config' => benchmark_config_path,
397
- # 'created_at' => Time.now.iso8601,
398
- # 'tags' => ['local', platform.os, platform.arch, "ruby-#{environment['ruby_build_tag']}"]
399
- # },
400
- # 'environment' => {
401
- # 'name' => environment['name'],
402
- # 'type' => environment.kind,
403
- # 'ruby_build_tag' => environment['ruby_build_tag'],
404
- # 'created_at' => Time.now.iso8601
405
- # },
406
- # 'config' => {
407
- # 'benchmark_config' => benchmark_config_path,
408
- # 'formats' => config['formats'],
409
- # 'iterations' => config['iterations'],
410
- # 'data_sizes' => config['data_sizes']
411
- # },
412
- # 'results' => results
413
- # }
414
-
415
- # File.write(results_file, full_results.to_yaml)
416
-
417
- # say '✅ Local benchmark completed successfully!', :green
418
- # say "Results saved to: #{result_dir}", :cyan
419
- # say "Generate site: serialbench benchmark build-site #{result_dir}", :white
420
- # rescue StandardError => e
421
- # say "❌ Local benchmark failed: #{e.message}", :red
422
- # say "Details: #{e.backtrace.first(3).join("\n")}", :white if options[:verbose]
423
- # raise e
424
- # end
425
-
426
- def execute_asdf_benchmark(environment, _config, benchmark_config_path)
358
+ def execute_asdf_benchmark(environment, config, benchmark_config_path)
427
359
  say '🔧 Executing ASDF benchmark', :green
428
360
 
429
- # Use the ASDF runner to execute the benchmark
430
- require_relative '../asdf_runner'
361
+ require_relative '../runners/asdf_runner'
431
362
 
432
- # Create a config object that AsdfRunner expects
433
- asdf_config = environment.merge({
434
- 'benchmark_config' => benchmark_config_path
435
- })
363
+ environment_config_path = "config/environments/#{environment.name}.yml"
364
+ runner = Runners::AsdfRunner.new(environment, environment_config_path)
436
365
 
437
- runner = Serialbench::AsdfRunner.new(asdf_config)
366
+ result_dir = "results/runs/#{environment.name}-results"
367
+ FileUtils.mkdir_p(result_dir)
438
368
 
439
- say "Installing Ruby #{environment['ruby_build_tag']} via ASDF...", :white
440
- runner.prepare
441
- runner.benchmark
369
+ runner.run_benchmark(config, benchmark_config_path, result_dir)
442
370
 
443
371
  say '✅ ASDF benchmark completed successfully!', :green
444
- say "Results saved to: results/runs/#{environment['name']}", :cyan
445
- say "Generate site: serialbench benchmark build-site results/runs/#{environment['name']}", :white
372
+ say "Results saved to: #{result_dir}", :cyan
446
373
  rescue StandardError => e
447
374
  say "❌ ASDF benchmark failed: #{e.message}", :red
448
375
  say "Details: #{e.backtrace.first(3).join("\n")}", :white if options[:verbose]
@@ -51,7 +51,7 @@ module Serialbench
51
51
  attribute :formats, :string, collection: true, values: %w[xml json yaml toml]
52
52
  attribute :iterations, BenchmarkIteration
53
53
  attribute :warmup, :integer, default: -> { 1 }
54
- attribute :operations, :string, collection: true, values: %w[parse generate memory streaming]
54
+ attribute :operations, :string, collection: true, values: %w[parsing generation xpath streaming memory]
55
55
 
56
56
  key_value do
57
57
  map 'name', to: :name
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Serialbench
4
- VERSION = '0.4.0'
4
+ VERSION = '0.5.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: serialbench
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose
@@ -260,7 +260,6 @@ files:
260
260
  - ".github/workflows/benchmark.yml"
261
261
  - ".github/workflows/rake.yml"
262
262
  - ".github/workflows/release.yml"
263
- - ".github/workflows/windows-debug.yml"
264
263
  - ".gitignore"
265
264
  - ".rspec"
266
265
  - ".rubocop.yml"
@@ -1,171 +0,0 @@
1
- name: Windows Debug
2
-
3
- on:
4
- push:
5
- branches: [ master, main ]
6
- paths:
7
- - '.github/workflows/windows-debug.yml'
8
- pull_request:
9
- paths:
10
- - '.github/workflows/windows-debug.yml'
11
- workflow_dispatch:
12
-
13
- jobs:
14
- test-libxml2-install:
15
- runs-on: windows-latest
16
- strategy:
17
- fail-fast: false
18
- matrix:
19
- ruby: ['3.1', '3.4']
20
- method: ['vcpkg', 'msys2', 'direct']
21
-
22
- name: Test ${{ matrix.method }} on Ruby ${{ matrix.ruby }}
23
-
24
- steps:
25
- - uses: actions/checkout@v4
26
-
27
- - name: Set up Ruby
28
- uses: ruby/setup-ruby@v1
29
- with:
30
- ruby-version: ${{ matrix.ruby }}
31
-
32
- - name: Install via vcpkg
33
- if: matrix.method == 'vcpkg'
34
- shell: powershell
35
- run: |
36
- Write-Host "Installing libxml2 via vcpkg..."
37
- vcpkg install libxml2:x64-windows
38
- vcpkg integrate install
39
-
40
- # Find the libxml2 installation
41
- $vcpkgRoot = "C:\vcpkg"
42
- $libxml2Path = Join-Path $vcpkgRoot "installed\x64-windows"
43
-
44
- Write-Host "libxml2 installed at: $libxml2Path"
45
-
46
- # Set environment variables
47
- echo "LIBXML2_INCLUDE=$libxml2Path\include" >> $env:GITHUB_ENV
48
- echo "LIBXML2_LIB=$libxml2Path\lib" >> $env:GITHUB_ENV
49
- echo "PKG_CONFIG_PATH=$libxml2Path\lib\pkgconfig" >> $env:GITHUB_ENV
50
-
51
- # Add to PATH
52
- $currentPath = [Environment]::GetEnvironmentVariable("PATH", "Process")
53
- $newPath = "$libxml2Path\bin;$currentPath"
54
- echo "$newPath" >> $env:GITHUB_PATH
55
-
56
- # Verify installation
57
- Get-ChildItem -Path $libxml2Path -Recurse | Where-Object { $_.Name -like "*libxml*" } | Select-Object FullName
58
-
59
- - name: Install via msys2
60
- if: matrix.method == 'msys2'
61
- shell: powershell
62
- run: |
63
- Write-Host "Installing libxml2 via msys2..."
64
- choco install -y msys2
65
-
66
- # Initialize msys2 and install libxml2
67
- C:\tools\msys64\usr\bin\bash -lc "pacman -Syu --noconfirm"
68
- C:\tools\msys64\usr\bin\bash -lc "pacman -S --noconfirm mingw-w64-x86_64-libxml2 mingw-w64-x86_64-pkg-config"
69
-
70
- # Set environment variables
71
- $msys2Root = "C:\tools\msys64\mingw64"
72
- echo "LIBXML2_INCLUDE=$msys2Root\include\libxml2" >> $env:GITHUB_ENV
73
- echo "LIBXML2_LIB=$msys2Root\lib" >> $env:GITHUB_ENV
74
- echo "PKG_CONFIG_PATH=$msys2Root\lib\pkgconfig" >> $env:GITHUB_ENV
75
-
76
- # Add to PATH
77
- echo "$msys2Root\bin" >> $env:GITHUB_PATH
78
-
79
- # Verify installation
80
- Get-ChildItem -Path $msys2Root -Recurse | Where-Object { $_.Name -like "*libxml*" } | Select-Object FullName
81
-
82
- - name: Install via direct download
83
- if: matrix.method == 'direct'
84
- shell: powershell
85
- run: |
86
- Write-Host "Installing libxml2 via direct download..."
87
-
88
- # Download pre-built binaries from gnome.org
89
- $downloadDir = "$env:TEMP\libxml2"
90
- New-Item -ItemType Directory -Force -Path $downloadDir
91
-
92
- # Download libxml2 and dependencies
93
- $libxml2Url = "https://download.gnome.org/binaries/win64/libxml2/2.9/libxml2-2.9.14-x64_dll.zip"
94
- $zlibUrl = "https://download.gnome.org/binaries/win64/dependencies/zlib-1.2.13-x64_dll.zip"
95
- $iconvUrl = "https://download.gnome.org/binaries/win64/dependencies/libiconv-1.17-x64_dll.zip"
96
-
97
- Invoke-WebRequest -Uri $libxml2Url -OutFile "$downloadDir\libxml2.zip"
98
- Invoke-WebRequest -Uri $zlibUrl -OutFile "$downloadDir\zlib.zip"
99
- Invoke-WebRequest -Uri $iconvUrl -OutFile "$downloadDir\iconv.zip"
100
-
101
- # Extract archives
102
- Expand-Archive -Path "$downloadDir\libxml2.zip" -DestinationPath "C:\libxml2" -Force
103
- Expand-Archive -Path "$downloadDir\zlib.zip" -DestinationPath "C:\libxml2" -Force
104
- Expand-Archive -Path "$downloadDir\iconv.zip" -DestinationPath "C:\libxml2" -Force
105
-
106
- # Set environment variables
107
- echo "LIBXML2_INCLUDE=C:\libxml2\include" >> $env:GITHUB_ENV
108
- echo "LIBXML2_LIB=C:\libxml2\lib" >> $env:GITHUB_ENV
109
-
110
- # Add to PATH
111
- echo "C:\libxml2\bin" >> $env:GITHUB_PATH
112
-
113
- # Verify installation
114
- Get-ChildItem -Path "C:\libxml2" -Recurse | Where-Object { $_.Name -like "*libxml*" } | Select-Object FullName
115
-
116
- - name: Verify pkg-config
117
- shell: powershell
118
- run: |
119
- Write-Host "Checking for pkg-config..."
120
- try {
121
- $pkgConfigPath = Get-Command pkg-config -ErrorAction Stop
122
- Write-Host "pkg-config found at: $($pkgConfigPath.Source)"
123
- pkg-config --version
124
- } catch {
125
- Write-Host "pkg-config not found, installing pkgconfiglite..."
126
- choco install -y pkgconfiglite
127
- pkg-config --version
128
- }
129
-
130
- # Try to find libxml2 via pkg-config
131
- Write-Host "`nSearching for libxml-2.0.pc..."
132
- if ($env:PKG_CONFIG_PATH) {
133
- Write-Host "PKG_CONFIG_PATH: $env:PKG_CONFIG_PATH"
134
- pkg-config --list-all | Select-String libxml
135
- }
136
-
137
- - name: Install bundler
138
- run: gem install bundler
139
-
140
- - name: Try to install libxml-ruby gem
141
- shell: powershell
142
- continue-on-error: true
143
- run: |
144
- Write-Host "Attempting to install libxml-ruby..."
145
-
146
- # Set additional environment variables for gem installation
147
- if ($env:LIBXML2_INCLUDE) {
148
- $env:CFLAGS = "-I$env:LIBXML2_INCLUDE"
149
- $env:CPPFLAGS = "-I$env:LIBXML2_INCLUDE"
150
- }
151
- if ($env:LIBXML2_LIB) {
152
- $env:LDFLAGS = "-L$env:LIBXML2_LIB"
153
- }
154
-
155
- gem install libxml-ruby --verbose
156
-
157
- - name: Report results
158
- if: always()
159
- shell: powershell
160
- run: |
161
- Write-Host "`n=== Installation Method: ${{ matrix.method }} ==="
162
- Write-Host "Ruby Version: ${{ matrix.ruby }}"
163
- Write-Host "`nEnvironment Variables:"
164
- Write-Host "LIBXML2_INCLUDE: $env:LIBXML2_INCLUDE"
165
- Write-Host "LIBXML2_LIB: $env:LIBXML2_LIB"
166
- Write-Host "PKG_CONFIG_PATH: $env:PKG_CONFIG_PATH"
167
- Write-Host "`nPATH:"
168
- $env:PATH -split ';' | ForEach-Object { Write-Host " $_" }
169
-
170
- Write-Host "`nChecking for libxml2 files..."
171
- Get-ChildItem C:\ -Recurse -ErrorAction SilentlyContinue -Include libxml2.dll,libxml2.lib,xml2-config.h 2>$null | Select-Object FullName