serialbench 0.1.0 → 0.1.2
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 +4 -4
- data/.github/workflows/benchmark.yml +181 -30
- data/.github/workflows/ci.yml +3 -3
- data/.github/workflows/docker.yml +272 -0
- data/.github/workflows/rake.yml +15 -0
- data/.github/workflows/release.yml +25 -0
- data/Gemfile +6 -30
- data/README.adoc +381 -415
- data/Rakefile +0 -55
- data/config/benchmarks/full.yml +29 -0
- data/config/benchmarks/short.yml +26 -0
- data/config/environments/asdf-ruby-3.2.yml +8 -0
- data/config/environments/asdf-ruby-3.3.yml +8 -0
- data/config/environments/docker-ruby-3.0.yml +9 -0
- data/config/environments/docker-ruby-3.1.yml +9 -0
- data/config/environments/docker-ruby-3.2.yml +9 -0
- data/config/environments/docker-ruby-3.3.yml +9 -0
- data/config/environments/docker-ruby-3.4.yml +9 -0
- data/docker/Dockerfile.alpine +33 -0
- data/docker/Dockerfile.ubuntu +32 -0
- data/docker/README.md +214 -0
- data/exe/serialbench +1 -1
- data/lib/serialbench/benchmark_runner.rb +270 -350
- data/lib/serialbench/cli/base_cli.rb +51 -0
- data/lib/serialbench/cli/benchmark_cli.rb +380 -0
- data/lib/serialbench/cli/environment_cli.rb +181 -0
- data/lib/serialbench/cli/resultset_cli.rb +215 -0
- data/lib/serialbench/cli/ruby_build_cli.rb +238 -0
- data/lib/serialbench/cli.rb +59 -410
- data/lib/serialbench/config_manager.rb +140 -0
- data/lib/serialbench/models/benchmark_config.rb +63 -0
- data/lib/serialbench/models/benchmark_result.rb +45 -0
- data/lib/serialbench/models/environment_config.rb +71 -0
- data/lib/serialbench/models/platform.rb +59 -0
- data/lib/serialbench/models/result.rb +53 -0
- data/lib/serialbench/models/result_set.rb +71 -0
- data/lib/serialbench/models/result_store.rb +108 -0
- data/lib/serialbench/models.rb +54 -0
- data/lib/serialbench/ruby_build_manager.rb +153 -0
- data/lib/serialbench/runners/asdf_runner.rb +296 -0
- data/lib/serialbench/runners/base.rb +32 -0
- data/lib/serialbench/runners/docker_runner.rb +142 -0
- data/lib/serialbench/serializers/base_serializer.rb +8 -16
- data/lib/serialbench/serializers/json/base_json_serializer.rb +4 -4
- data/lib/serialbench/serializers/json/json_serializer.rb +0 -2
- data/lib/serialbench/serializers/json/oj_serializer.rb +0 -2
- data/lib/serialbench/serializers/json/rapidjson_serializer.rb +50 -0
- data/lib/serialbench/serializers/json/yajl_serializer.rb +6 -4
- data/lib/serialbench/serializers/toml/base_toml_serializer.rb +5 -3
- data/lib/serialbench/serializers/toml/toml_rb_serializer.rb +0 -2
- data/lib/serialbench/serializers/toml/tomlib_serializer.rb +0 -2
- data/lib/serialbench/serializers/toml/tomlrb_serializer.rb +56 -0
- data/lib/serialbench/serializers/xml/base_xml_serializer.rb +4 -9
- data/lib/serialbench/serializers/xml/libxml_serializer.rb +0 -2
- data/lib/serialbench/serializers/xml/nokogiri_serializer.rb +21 -5
- data/lib/serialbench/serializers/xml/oga_serializer.rb +0 -2
- data/lib/serialbench/serializers/xml/ox_serializer.rb +0 -2
- data/lib/serialbench/serializers/xml/rexml_serializer.rb +32 -4
- data/lib/serialbench/serializers/yaml/base_yaml_serializer.rb +59 -0
- data/lib/serialbench/serializers/yaml/psych_serializer.rb +54 -0
- data/lib/serialbench/serializers/yaml/syck_serializer.rb +102 -0
- data/lib/serialbench/serializers.rb +34 -6
- data/lib/serialbench/site_generator.rb +105 -0
- data/lib/serialbench/templates/assets/css/benchmark_report.css +535 -0
- data/lib/serialbench/templates/assets/css/format_based.css +526 -0
- data/lib/serialbench/templates/assets/css/themes.css +588 -0
- data/lib/serialbench/templates/assets/js/chart_helpers.js +381 -0
- data/lib/serialbench/templates/assets/js/dashboard.js +796 -0
- data/lib/serialbench/templates/assets/js/navigation.js +142 -0
- data/lib/serialbench/templates/base.liquid +49 -0
- data/lib/serialbench/templates/format_based.liquid +279 -0
- data/lib/serialbench/templates/partials/chart_section.liquid +4 -0
- data/lib/serialbench/version.rb +1 -1
- data/lib/serialbench.rb +2 -31
- data/serialbench.gemspec +28 -17
- metadata +192 -55
- data/lib/serialbench/chart_generator.rb +0 -821
- data/lib/serialbench/result_formatter.rb +0 -182
- data/lib/serialbench/result_merger.rb +0 -1201
- data/lib/serialbench/serializers/xml/base_parser.rb +0 -69
- data/lib/serialbench/serializers/xml/libxml_parser.rb +0 -98
- data/lib/serialbench/serializers/xml/nokogiri_parser.rb +0 -111
- data/lib/serialbench/serializers/xml/oga_parser.rb +0 -85
- data/lib/serialbench/serializers/xml/ox_parser.rb +0 -64
- data/lib/serialbench/serializers/xml/rexml_parser.rb +0 -129
data/Rakefile
CHANGED
@@ -5,59 +5,4 @@ require 'rspec/core/rake_task'
|
|
5
5
|
|
6
6
|
RSpec::Core::RakeTask.new(:spec)
|
7
7
|
|
8
|
-
desc 'Run benchmarks'
|
9
|
-
task :benchmark do
|
10
|
-
require_relative 'lib/serialbench'
|
11
|
-
|
12
|
-
puts 'Running XML benchmarks...'
|
13
|
-
results = Serialbench.run_benchmarks
|
14
|
-
|
15
|
-
puts "\nGenerating reports..."
|
16
|
-
report_files = Serialbench.generate_reports(results)
|
17
|
-
|
18
|
-
puts "\nBenchmark complete!"
|
19
|
-
puts 'Reports generated:'
|
20
|
-
puts " HTML: #{report_files[:html]}"
|
21
|
-
puts " AsciiDoc: #{report_files[:asciidoc]}"
|
22
|
-
puts " Charts: #{report_files[:charts].length} SVG files"
|
23
|
-
end
|
24
|
-
|
25
|
-
desc 'Install all XML library dependencies'
|
26
|
-
task :install_deps do
|
27
|
-
gems = %w[ox nokogiri libxml-ruby oga memory_profiler]
|
28
|
-
|
29
|
-
puts 'Installing XML library dependencies...'
|
30
|
-
gems.each do |gem_name|
|
31
|
-
puts "Installing #{gem_name}..."
|
32
|
-
system("gem install #{gem_name}")
|
33
|
-
rescue StandardError => e
|
34
|
-
puts "Warning: Failed to install #{gem_name}: #{e.message}"
|
35
|
-
end
|
36
|
-
puts 'Done!'
|
37
|
-
end
|
38
|
-
|
39
|
-
desc 'Check which XML libraries are available'
|
40
|
-
task :check_libs do
|
41
|
-
require_relative 'lib/serialbench'
|
42
|
-
|
43
|
-
runner = Serialbench::BenchmarkRunner.new
|
44
|
-
|
45
|
-
puts 'XML Library Availability Check'
|
46
|
-
puts '=' * 40
|
47
|
-
|
48
|
-
runner.parsers.each do |parser|
|
49
|
-
status = parser.available? ? '✓ Available' : '✗ Not available'
|
50
|
-
version = parser.available? ? " (#{parser.version})" : ''
|
51
|
-
puts "#{parser.name.ljust(15)} #{status}#{version}"
|
52
|
-
end
|
53
|
-
|
54
|
-
puts "\nMemory profiler: #{Serialbench::MemoryProfiler.available? ? '✓ Available' : '✗ Not available'}"
|
55
|
-
end
|
56
|
-
|
57
|
-
desc 'Clean generated files'
|
58
|
-
task :clean do
|
59
|
-
FileUtils.rm_rf('results')
|
60
|
-
puts 'Cleaned generated files'
|
61
|
-
end
|
62
|
-
|
63
8
|
task default: :spec
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# Configuration for comprehensive benchmarks - Full testing with all data sizes
|
2
|
+
# Used by Docker script for complete performance analysis
|
3
|
+
|
4
|
+
# Run name for identification
|
5
|
+
name: full-benchmark
|
6
|
+
|
7
|
+
data_sizes:
|
8
|
+
- small
|
9
|
+
- medium
|
10
|
+
- large
|
11
|
+
|
12
|
+
formats:
|
13
|
+
- xml
|
14
|
+
- json
|
15
|
+
- yaml
|
16
|
+
- toml
|
17
|
+
|
18
|
+
iterations:
|
19
|
+
small: 20
|
20
|
+
medium: 5
|
21
|
+
large: 2
|
22
|
+
|
23
|
+
operations:
|
24
|
+
- parse
|
25
|
+
- generate
|
26
|
+
- streaming
|
27
|
+
- memory
|
28
|
+
|
29
|
+
warmup: 3
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# Configuration for short benchmarks - Minimal memory usage for CI runners
|
2
|
+
# Designed for Windows and Ubuntu runners with limited memory
|
3
|
+
|
4
|
+
# Run name for identification
|
5
|
+
name: short-benchmark
|
6
|
+
|
7
|
+
data_sizes:
|
8
|
+
- small
|
9
|
+
|
10
|
+
formats:
|
11
|
+
- xml
|
12
|
+
- json
|
13
|
+
- yaml
|
14
|
+
- toml
|
15
|
+
|
16
|
+
iterations:
|
17
|
+
small: 5
|
18
|
+
medium: 2
|
19
|
+
large: 1
|
20
|
+
|
21
|
+
operations:
|
22
|
+
- parse
|
23
|
+
- generate
|
24
|
+
- streaming
|
25
|
+
|
26
|
+
warmup: 2
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# Alpine-based Ruby benchmark environment using official Ruby Alpine images
|
2
|
+
ARG BASE_IMAGE=ruby:3.4-alpine
|
3
|
+
FROM ${BASE_IMAGE}
|
4
|
+
|
5
|
+
# Install system dependencies for XML libraries and build tools
|
6
|
+
RUN apk add --no-cache \
|
7
|
+
build-base \
|
8
|
+
libxml2-dev \
|
9
|
+
libxslt-dev \
|
10
|
+
yaml-dev \
|
11
|
+
zlib-dev \
|
12
|
+
openssl-dev \
|
13
|
+
linux-headers \
|
14
|
+
git
|
15
|
+
|
16
|
+
# Set working directory
|
17
|
+
WORKDIR /app
|
18
|
+
|
19
|
+
# Copy the entire application (gemspec needs full context)
|
20
|
+
COPY . .
|
21
|
+
|
22
|
+
# Update bundler and configure bundle for cross-platform compatibility
|
23
|
+
RUN gem install bundler:2.5.22 && \
|
24
|
+
bundle config set --local deployment 'false' && \
|
25
|
+
bundle config set --local path '/usr/local/bundle' && \
|
26
|
+
bundle config set --local force_ruby_platform true && \
|
27
|
+
bundle install --jobs 4 --retry 3
|
28
|
+
|
29
|
+
# Create results directory
|
30
|
+
RUN mkdir -p /app/results
|
31
|
+
|
32
|
+
# Default command runs benchmarks
|
33
|
+
ENTRYPOINT ["bundle", "exec", "serialbench"]
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# Multi-stage Dockerfile for Ruby serialization benchmarks
|
2
|
+
# Supports multiple Ruby versions for comprehensive testing
|
3
|
+
|
4
|
+
ARG BASE_IMAGE=ruby:3.4-slim
|
5
|
+
FROM ${BASE_IMAGE}
|
6
|
+
|
7
|
+
# Install system dependencies for XML libraries
|
8
|
+
RUN apt-get update && apt-get install -y \
|
9
|
+
libxml2-dev \
|
10
|
+
libxslt1-dev \
|
11
|
+
build-essential \
|
12
|
+
git \
|
13
|
+
&& rm -rf /var/lib/apt/lists/*
|
14
|
+
|
15
|
+
# Set working directory
|
16
|
+
WORKDIR /app
|
17
|
+
|
18
|
+
# Copy the entire application (gemspec needs full context)
|
19
|
+
COPY . .
|
20
|
+
|
21
|
+
# Update bundler and configure bundle for cross-platform compatibility
|
22
|
+
RUN gem install bundler:2.5.22 && \
|
23
|
+
bundle config set --local deployment 'false' && \
|
24
|
+
bundle config set --local path '/usr/local/bundle' && \
|
25
|
+
bundle config set --local force_ruby_platform true && \
|
26
|
+
bundle install --jobs 4 --retry 3
|
27
|
+
|
28
|
+
# Create results directory
|
29
|
+
RUN mkdir -p /app/results
|
30
|
+
|
31
|
+
# Default command runs parsing and generation benchmarks (memory benchmarks disabled due to hanging in Docker)
|
32
|
+
ENTRYPOINT ["bundle", "exec", "serialbench"]
|
data/docker/README.md
ADDED
@@ -0,0 +1,214 @@
|
|
1
|
+
# Serialbench Docker Setup
|
2
|
+
|
3
|
+
This directory contains Docker infrastructure for running Serialbench across multiple Ruby versions in isolated environments.
|
4
|
+
|
5
|
+
## Files
|
6
|
+
|
7
|
+
- `Dockerfile.ubuntu` - Multi-stage Dockerfile for building benchmark environments
|
8
|
+
- `run-benchmarks.sh` - Automated script for running benchmarks across multiple Ruby versions
|
9
|
+
|
10
|
+
## Quick Start
|
11
|
+
|
12
|
+
### Prerequisites
|
13
|
+
|
14
|
+
- Docker installed and running
|
15
|
+
- Bash shell (Linux/macOS/WSL)
|
16
|
+
|
17
|
+
### Running Multi-Ruby Benchmarks
|
18
|
+
|
19
|
+
```bash
|
20
|
+
# From the project root directory
|
21
|
+
./docker/run-benchmarks.sh
|
22
|
+
```
|
23
|
+
|
24
|
+
This will:
|
25
|
+
1. Build Docker images for Ruby 3.1, 3.2, 3.3, and 3.4 (skipping existing images)
|
26
|
+
2. Run comprehensive benchmarks in each environment
|
27
|
+
3. Merge results from all Ruby versions
|
28
|
+
4. Generate GitHub Pages with comparative results
|
29
|
+
|
30
|
+
#### Force Rebuild Images
|
31
|
+
|
32
|
+
To force rebuild all Docker images (even if they already exist):
|
33
|
+
|
34
|
+
```bash
|
35
|
+
# Force rebuild all images
|
36
|
+
./docker/run-benchmarks.sh --force-rebuild
|
37
|
+
|
38
|
+
# Or use the short form
|
39
|
+
./docker/run-benchmarks.sh -f
|
40
|
+
```
|
41
|
+
|
42
|
+
This is useful when:
|
43
|
+
- Dependencies have been updated
|
44
|
+
- Dockerfile has been modified
|
45
|
+
- You want to ensure fresh builds
|
46
|
+
- Troubleshooting build-related issues
|
47
|
+
|
48
|
+
#### Command Line Options
|
49
|
+
|
50
|
+
```bash
|
51
|
+
# Show help and available options
|
52
|
+
./docker/run-benchmarks.sh --help
|
53
|
+
|
54
|
+
# Available options:
|
55
|
+
# --force-rebuild, -f Force rebuild of Docker images even if they exist
|
56
|
+
# --help, -h Show help message
|
57
|
+
```
|
58
|
+
|
59
|
+
### Results
|
60
|
+
|
61
|
+
Results are saved in `docker-results/`:
|
62
|
+
```
|
63
|
+
docker-results/
|
64
|
+
├── ruby-3.1/ # Ruby 3.1 results
|
65
|
+
├── ruby-3.2/ # Ruby 3.2 results
|
66
|
+
├── ruby-3.3/ # Ruby 3.3 results
|
67
|
+
├── ruby-3.4/ # Ruby 3.4 results
|
68
|
+
├── merged/ # Merged results from all versions
|
69
|
+
└── docs/ # GitHub Pages site
|
70
|
+
```
|
71
|
+
|
72
|
+
## Manual Docker Usage
|
73
|
+
|
74
|
+
### Build Image for Specific Ruby Version
|
75
|
+
|
76
|
+
```bash
|
77
|
+
docker build \
|
78
|
+
--build-arg RUBY_VERSION=3.3 \
|
79
|
+
-t serialbench:ruby-3.3 \
|
80
|
+
-f docker/Dockerfile.ubuntu \
|
81
|
+
.
|
82
|
+
```
|
83
|
+
|
84
|
+
### Run Benchmarks
|
85
|
+
|
86
|
+
```bash
|
87
|
+
# Create results directory
|
88
|
+
mkdir -p results
|
89
|
+
|
90
|
+
# Run benchmarks
|
91
|
+
docker run \
|
92
|
+
--rm \
|
93
|
+
-v $(pwd)/results:/app/results \
|
94
|
+
serialbench:ruby-3.3
|
95
|
+
```
|
96
|
+
|
97
|
+
### Custom Configuration
|
98
|
+
|
99
|
+
```bash
|
100
|
+
# Use custom config file
|
101
|
+
docker run \
|
102
|
+
--rm \
|
103
|
+
-v $(pwd)/results:/app/results \
|
104
|
+
-v $(pwd)/config:/app/config \
|
105
|
+
serialbench:ruby-3.3 \
|
106
|
+
bundle exec serialbench benchmark --config config/ci.yml
|
107
|
+
```
|
108
|
+
|
109
|
+
## Supported Ruby Versions
|
110
|
+
|
111
|
+
- Ruby 3.1
|
112
|
+
- Ruby 3.2
|
113
|
+
- Ruby 3.3
|
114
|
+
- Ruby 3.4
|
115
|
+
|
116
|
+
## Environment Variables
|
117
|
+
|
118
|
+
The Docker images support these environment variables:
|
119
|
+
|
120
|
+
- `BUNDLE_PATH` - Bundle installation path
|
121
|
+
- `BUNDLE_BIN` - Bundle binary path
|
122
|
+
- `PATH` - System PATH including bundle binaries
|
123
|
+
|
124
|
+
## Troubleshooting
|
125
|
+
|
126
|
+
### Build Failures
|
127
|
+
|
128
|
+
Check build logs in `docker-results/build-ruby-X.X.log`:
|
129
|
+
|
130
|
+
```bash
|
131
|
+
cat docker-results/build-ruby-3.3.log
|
132
|
+
```
|
133
|
+
|
134
|
+
### Runtime Failures
|
135
|
+
|
136
|
+
Check benchmark logs in `docker-results/ruby-X.X/benchmark.log`:
|
137
|
+
|
138
|
+
```bash
|
139
|
+
cat docker-results/ruby-3.3/benchmark.log
|
140
|
+
```
|
141
|
+
|
142
|
+
### Docker Issues
|
143
|
+
|
144
|
+
Ensure Docker is running:
|
145
|
+
```bash
|
146
|
+
docker info
|
147
|
+
```
|
148
|
+
|
149
|
+
Clean up Docker resources:
|
150
|
+
```bash
|
151
|
+
# Remove all serialbench images
|
152
|
+
docker rmi $(docker images serialbench -q)
|
153
|
+
|
154
|
+
# Remove all containers
|
155
|
+
docker container prune
|
156
|
+
```
|
157
|
+
|
158
|
+
## Customization
|
159
|
+
|
160
|
+
### Adding Ruby Versions
|
161
|
+
|
162
|
+
Edit `RUBY_VERSIONS` array in `run-benchmarks.sh`:
|
163
|
+
|
164
|
+
```bash
|
165
|
+
RUBY_VERSIONS=("3.1" "3.2" "3.3" "3.4" "head")
|
166
|
+
```
|
167
|
+
|
168
|
+
### Custom Benchmark Configuration
|
169
|
+
|
170
|
+
Create custom config files in `config/` directory and reference them:
|
171
|
+
|
172
|
+
```bash
|
173
|
+
# In run-benchmarks.sh
|
174
|
+
CONFIG_FILE="config/custom.yml"
|
175
|
+
```
|
176
|
+
|
177
|
+
### Output Directory
|
178
|
+
|
179
|
+
Change the output directory:
|
180
|
+
|
181
|
+
```bash
|
182
|
+
# In run-benchmarks.sh
|
183
|
+
OUTPUT_DIR="my-results"
|
184
|
+
```
|
185
|
+
|
186
|
+
## Integration with CI/CD
|
187
|
+
|
188
|
+
The Docker setup integrates with GitHub Actions. See `.github/workflows/benchmark.yml` for automated benchmark runs.
|
189
|
+
|
190
|
+
### GitHub Actions Usage
|
191
|
+
|
192
|
+
```yaml
|
193
|
+
- name: Run Docker Benchmarks
|
194
|
+
run: ./docker/run-benchmarks.sh
|
195
|
+
|
196
|
+
- name: Upload Results
|
197
|
+
uses: actions/upload-artifact@v3
|
198
|
+
with:
|
199
|
+
name: benchmark-results
|
200
|
+
path: docker-results/
|
201
|
+
```
|
202
|
+
|
203
|
+
## Performance Considerations
|
204
|
+
|
205
|
+
- Each Ruby version runs in isolation
|
206
|
+
- Results are automatically merged for comparison
|
207
|
+
- Memory profiling is enabled by default
|
208
|
+
- Build caching optimizes subsequent runs
|
209
|
+
|
210
|
+
## Security
|
211
|
+
|
212
|
+
- Containers run with minimal privileges
|
213
|
+
- No network access required during benchmarks
|
214
|
+
- Results are written to mounted volumes only
|
data/exe/serialbench
CHANGED