
Security News
CISA’s 2025 SBOM Guidance Adds Hashes, Licenses, Tool Metadata, and Context
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
= Serialbench: Ruby serialization library performance benchmarker
image:https://img.shields.io/gem/v/serialbench.svg["Gem Version", link="https://rubygems.org/gems/serialbench"] image:https://github.com/metanorma/serialbench/actions/workflows/ci.yml/badge.svg["Build Status", link="https://github.com/metanorma/serialbench/actions/workflows/ci.yml"] image:https://github.com/metanorma/serialbench/actions/workflows/benchmark.yml/badge.svg["Benchmark Status", link="https://github.com/metanorma/serialbench/actions/workflows/benchmark.yml"] image:https://img.shields.io/github/issues-pr-raw/metanorma/serialbench.svg["Pull Requests", link="https://github.com/metanorma/serialbench/pulls"]
== Overview
Serialbench is a comprehensive benchmarking suite that evaluates the performance of popular Ruby serialization libraries across multiple formats. It provides detailed performance comparisons and analysis to help developers make informed decisions when choosing serialization libraries for their Ruby applications.
Supported Formats: XML, JSON, YAML, TOML, and more
Key Metrics: Parsing speed, generation speed, memory usage, streaming capabilities, and feature completeness
Multi-Environment Support: Docker and ASDF-based multi-Ruby version benchmarking with automated result aggregation and HTML site generation
== Supported serialization libraries
[cols="1,3,1,4", options="header"] |=== | Format | Name | Version | Description
| XML | https://github.com/ohler55/ox[Ox] | v2.14.23 | C extension XML parser
| XML | https://github.com/xml4r/libxml-ruby[LibXML] | v4.1.2 | Ruby bindings for libxml2
| XML | https://github.com/sparklemotion/nokogiri[Nokogiri] | v1.18.8 | XML/HTML parser with XPath and CSS selectors
| XML | https://github.com/YorickPeterse/oga[Oga] | v3.4 | Pure Ruby XML parser with XPath support
| XML | https://github.com/ruby/rexml[REXML] | v3.4.1 | Ruby's standard library XML parser
| JSON | https://github.com/ohler55/oj[Oj] | v3.16.11 | JSON parser with multiple parsing modes
| JSON | https://github.com/brianmario/yajl-ruby[YAJL] | v1.4.3 | JSON library with streaming capabilities
| JSON | https://github.com/flori/json[JSON] | v2.12.2 | Ruby's standard library JSON parser
| YAML | https://github.com/ruby/psych[Psych] | v5.1.2 | Ruby's standard library YAML parser
| YAML | https://github.com/ruby/syck[Syck] | v1.5.1.1 | Legacy YAML parser
| TOML | https://github.com/fbernier/tomlib[Tomlib] | v0.7.3 | TOML parser implemented in C
| TOML | https://github.com/emancu/toml-rb[TOML-RB] | v2.2.0 | Pure Ruby TOML parser
| TOML | https://github.com/fbernier/tomlrb[tomlrb] | v2.0.3 | A Racc based TOML Ruby parser (Only supports parsing, no support for dumping/writing.)
|===
== Data formats and schema
Serialbench generates structured YAML output for benchmark results, with different formats for single-environment and multi-environment runs.
The data formats include:
== Prerequisites
=== System requirements
=== Library dependencies
System dependencies (required for some native extensions):
$ brew install libxml2 libxslt
$ sudo apt-get install libxml2-dev libxslt1-dev build-essential
== Installation
Add this line to your application's Gemfile:
And then execute:
Or install it yourself as:
== Command line interface
Serialbench provides a comprehensive Thor-based CLI with four main subcommands for managing environments, benchmarks, result sets, and Ruby builds.
=== Main Commands Overview
$ serialbench Serialbench - Benchmarking Framework for Ruby Serialization Libraries
USAGE: serialbench COMMAND [SUBCOMMAND] [OPTIONS]
COMMANDS: environment Manage benchmark environments (Docker, ASDF, Local) benchmark Manage individual benchmark runs resultset Manage benchmark resultsets (collections of runs) ruby-build Manage Ruby-Build definitions for validation version Show version information help Show this help message
EXAMPLES:
serialbench environment new docker-test docker
serialbench environment multi-execute asdf --config=serialbench-asdf.yml serialbench environment multi-execute docker --config=serialbench-docker.yml
serialbench benchmark create my-benchmark serialbench benchmark execute my-benchmark.yml
serialbench resultset create comparison-set serialbench resultset add-result comparison-set results/my-benchmark
=== Environment management
The environment
subcommand manages environment configurations and executes
benchmarks across different Ruby environments.
=== Benchmark management
The benchmark
subcommand handles individual benchmark runs and site generation.
The _docker_execute
command is a private command used internally by the
execute
command to run benchmarks in Docker environments.
=== Result set management
The resultset
subcommand manages collections of benchmark runs for comparison analysis.
=== ruby-build management
The ruby-build
subcommand manages Ruby build definitions and version information.
Serialbench uses ruby-build definitions of Ruby interpreter types and versions for identification.
== Workflow examples
=== Docker-based testing
NOTE: This works.
$ bundle exec serialbench environment prepare config/environments/docker-ruby-3.1.yml
$ bundle exec serialbench environment execute config/environments/docker-ruby-3.1.yml config/benchmarks/short.yml results/runs/docker-ruby-3.1-results
$ bundle exec serialbench resultset create docker-comparison results/sets/docker-comparison
$ bundle exec serialbench benchmark build-site results/runs/docker-ruby-3.1-results/ --output_dir=_site_result
$ bundle exec serialbench resultset add-result results/sets/docker-comparison/ results/runs/docker-ruby-3.1-results/
$ bundle exec serialbench resultset build-site results/sets/docker-comparison/
=== ASDF-based testing
WARNING: THIS IS NOT YET WORKING.
$ bundle exec serialbench benchmark validate serialbench-asdf.yml
$ bundle exec serialbench benchmark prepare asdf --config=serialbench-asdf.yml
$ bundle exec serialbench benchmark execute asdf --config=serialbench-asdf.yml
== Configuration Files
=== Environment configuration
Environment configuration files define how benchmarks are executed in different runtime environments.
config/environments/docker-ruby-3.4.yml
)
[source,yaml]config/environments/asdf-ruby-3.3.yml
)
[source,yaml]=== Benchmark configuration
Benchmark configuration files control what tests to run and how to run them.
config/benchmarks/short.yml
)
[source,yaml]name: short-benchmark
data_sizes:
formats:
iterations: small: 5 medium: 2 large: 1
operations:
config/benchmarks/full.yml
)
[source,yaml]name: full-benchmark
data_sizes:
formats:
iterations: small: 20 medium: 5 large: 2
operations:
== Results structure
=== Individual run results
Results are stored in a structured directory format, with each run containing raw benchmark data and execution logs.
The directory is located at results/runs/{name}/
, where {name}
is the name
of the environment used for the benchmark.
=== ResultSet structure
ResultSets aggregate multiple benchmark runs for comparison. They are stored in
a structured directory format at results/sets/{name}/
, where {name}
is the
name of the result set.
== Benchmark categories
=== Parsing performance
Measures the time required to parse serialized data into Ruby objects.
=== Generation performance
Tests how quickly libraries can convert Ruby objects into serialized strings.
=== Streaming performance
Evaluates streaming event-based parsing performance for libraries that support it, which processes data sequentially and is memory-efficient for large files.
=== Memory usage analysis
Profiles memory allocation and retention during serialization operations using
the memory_profiler
gem.
== Interactive Dashboard Features
The generated HTML sites provide comprehensive interactive dashboards with:
=== Navigation and Filtering
=== Visualization Capabilities
=== User Experience
== Development
=== Running Tests
=== Adding a new serializers
To add support for additional serialization libraries:
. Create a new serializer class in lib/serialbench/serializers/{format}/
. Inherit from the appropriate base class (BaseXmlSerializer
, BaseJsonSerializer
, etc.)
. Implement the required methods: parse
, generate
, name
, version
. Add the serializer to the registry in lib/serialbench/serializers.rb
. Update documentation and tests
=== Contributing
. Fork the repository
. Create your feature branch (git checkout -b feature/my-new-feature
)
. Commit your changes (git commit -am 'Add some feature'
)
. Push to the branch (git push origin feature/my-new-feature
)
. Create a new Pull Request
== Known issues
=== Syck YAML serializer segmentation faults
The Syck YAML serializer at version 1.5+ is known to cause segmentation faults on Ruby 3.1 and later versions. Serialbench automatically detects this problematic configuration and:
=== Syck overrides YAML constant
On occasion after Syck is loaded, the constant YAML
may be redefined to
Syck
, which can cause issues in other parts of the codebase. This can cause
YAML output to fail when using libraries that expect YAML
to have the
Psych
API.
In benchmark_cli.rb
there is therefore such code to ensure that
YAML
is defined as Psych
when writing to file is needed:
== License and copyright
Copyright Ribose.
This gem is developed, maintained and funded by https://www.ribose.com[Ribose]
The gem is available as open source under the terms of the https://opensource.org/licenses/BSD-2-Clause[2-Clause BSD License].
FAQs
Unknown package
We found that serialbench demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.
Security News
ESLint now supports parallel linting with a new --concurrency flag, delivering major speed gains and closing a 10-year-old feature request.