alba 3.5.0 → 3.7.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 +4 -4
- data/CHANGELOG.md +27 -0
- data/README.md +96 -40
- data/lib/alba/association.rb +4 -1
- data/lib/alba/conditional_attribute.rb +11 -14
- data/lib/alba/layout.rb +8 -6
- data/lib/alba/railtie.rb +2 -2
- data/lib/alba/resource.rb +90 -17
- data/lib/alba/typed_attribute.rb +2 -0
- data/lib/alba/version.rb +1 -1
- data/lib/alba.rb +51 -32
- metadata +5 -53
- data/.codeclimate.yml +0 -12
- data/.editorconfig +0 -10
- data/.github/ISSUE_TEMPLATE/bug_report.md +0 -26
- data/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
- data/.github/dependabot.yml +0 -12
- data/.github/workflows/codeql-analysis.yml +0 -70
- data/.github/workflows/lint.yml +0 -17
- data/.github/workflows/main.yml +0 -41
- data/.gitignore +0 -11
- data/.rubocop.yml +0 -156
- data/.yardopts +0 -4
- data/CODE_OF_CONDUCT.md +0 -132
- data/CONTRIBUTING.md +0 -30
- data/Gemfile +0 -39
- data/HACKING.md +0 -42
- data/Rakefile +0 -17
- data/SECURITY.md +0 -12
- data/alba.gemspec +0 -33
- data/benchmark/Gemfile +0 -26
- data/benchmark/README.md +0 -137
- data/benchmark/collection.rb +0 -297
- data/benchmark/prep.rb +0 -56
- data/benchmark/single_resource.rb +0 -300
- data/bin/console +0 -15
- data/bin/setup +0 -8
- data/codecov.yml +0 -8
- data/docs/migrate_from_active_model_serializers.md +0 -359
- data/docs/migrate_from_jbuilder.md +0 -237
- data/docs/rails.md +0 -56
- data/gemfiles/without_active_support.gemfile +0 -19
- data/gemfiles/without_oj.gemfile +0 -19
- data/logo/alba-card.png +0 -0
- data/logo/alba-sign.png +0 -0
- data/logo/alba-typography.png +0 -0
data/CODE_OF_CONDUCT.md
DELETED
@@ -1,132 +0,0 @@
|
|
1
|
-
|
2
|
-
# Contributor Covenant Code of Conduct
|
3
|
-
|
4
|
-
## Our Pledge
|
5
|
-
|
6
|
-
We as members, contributors, and leaders pledge to make participation in our
|
7
|
-
community a harassment-free experience for everyone, regardless of age, body
|
8
|
-
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
9
|
-
identity and expression, level of experience, education, socio-economic status,
|
10
|
-
nationality, personal appearance, race, caste, color, religion, or sexual
|
11
|
-
identity and orientation.
|
12
|
-
|
13
|
-
We pledge to act and interact in ways that contribute to an open, welcoming,
|
14
|
-
diverse, inclusive, and healthy community.
|
15
|
-
|
16
|
-
## Our Standards
|
17
|
-
|
18
|
-
Examples of behavior that contributes to a positive environment for our
|
19
|
-
community include:
|
20
|
-
|
21
|
-
* Demonstrating empathy and kindness toward other people
|
22
|
-
* Being respectful of differing opinions, viewpoints, and experiences
|
23
|
-
* Giving and gracefully accepting constructive feedback
|
24
|
-
* Accepting responsibility and apologizing to those affected by our mistakes,
|
25
|
-
and learning from the experience
|
26
|
-
* Focusing on what is best not just for us as individuals, but for the overall
|
27
|
-
community
|
28
|
-
|
29
|
-
Examples of unacceptable behavior include:
|
30
|
-
|
31
|
-
* The use of sexualized language or imagery, and sexual attention or advances of
|
32
|
-
any kind
|
33
|
-
* Trolling, insulting or derogatory comments, and personal or political attacks
|
34
|
-
* Public or private harassment
|
35
|
-
* Publishing others' private information, such as a physical or email address,
|
36
|
-
without their explicit permission
|
37
|
-
* Other conduct which could reasonably be considered inappropriate in a
|
38
|
-
professional setting
|
39
|
-
|
40
|
-
## Enforcement Responsibilities
|
41
|
-
|
42
|
-
Community leaders are responsible for clarifying and enforcing our standards of
|
43
|
-
acceptable behavior and will take appropriate and fair corrective action in
|
44
|
-
response to any behavior that they deem inappropriate, threatening, offensive,
|
45
|
-
or harmful.
|
46
|
-
|
47
|
-
Community leaders have the right and responsibility to remove, edit, or reject
|
48
|
-
comments, commits, code, wiki edits, issues, and other contributions that are
|
49
|
-
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
50
|
-
decisions when appropriate.
|
51
|
-
|
52
|
-
## Scope
|
53
|
-
|
54
|
-
This Code of Conduct applies within all community spaces, and also applies when
|
55
|
-
an individual is officially representing the community in public spaces.
|
56
|
-
Examples of representing our community include using an official e-mail address,
|
57
|
-
posting via an official social media account, or acting as an appointed
|
58
|
-
representative at an online or offline event.
|
59
|
-
|
60
|
-
## Enforcement
|
61
|
-
|
62
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
63
|
-
reported to the community leaders responsible for enforcement at masafumi.o1988@gmail.com .
|
64
|
-
All complaints will be reviewed and investigated promptly and fairly.
|
65
|
-
|
66
|
-
All community leaders are obligated to respect the privacy and security of the
|
67
|
-
reporter of any incident.
|
68
|
-
|
69
|
-
## Enforcement Guidelines
|
70
|
-
|
71
|
-
Community leaders will follow these Community Impact Guidelines in determining
|
72
|
-
the consequences for any action they deem in violation of this Code of Conduct:
|
73
|
-
|
74
|
-
### 1. Correction
|
75
|
-
|
76
|
-
**Community Impact**: Use of inappropriate language or other behavior deemed
|
77
|
-
unprofessional or unwelcome in the community.
|
78
|
-
|
79
|
-
**Consequence**: A private, written warning from community leaders, providing
|
80
|
-
clarity around the nature of the violation and an explanation of why the
|
81
|
-
behavior was inappropriate. A public apology may be requested.
|
82
|
-
|
83
|
-
### 2. Warning
|
84
|
-
|
85
|
-
**Community Impact**: A violation through a single incident or series of
|
86
|
-
actions.
|
87
|
-
|
88
|
-
**Consequence**: A warning with consequences for continued behavior. No
|
89
|
-
interaction with the people involved, including unsolicited interaction with
|
90
|
-
those enforcing the Code of Conduct, for a specified period of time. This
|
91
|
-
includes avoiding interactions in community spaces as well as external channels
|
92
|
-
like social media. Violating these terms may lead to a temporary or permanent
|
93
|
-
ban.
|
94
|
-
|
95
|
-
### 3. Temporary Ban
|
96
|
-
|
97
|
-
**Community Impact**: A serious violation of community standards, including
|
98
|
-
sustained inappropriate behavior.
|
99
|
-
|
100
|
-
**Consequence**: A temporary ban from any sort of interaction or public
|
101
|
-
communication with the community for a specified period of time. No public or
|
102
|
-
private interaction with the people involved, including unsolicited interaction
|
103
|
-
with those enforcing the Code of Conduct, is allowed during this period.
|
104
|
-
Violating these terms may lead to a permanent ban.
|
105
|
-
|
106
|
-
### 4. Permanent Ban
|
107
|
-
|
108
|
-
**Community Impact**: Demonstrating a pattern of violation of community
|
109
|
-
standards, including sustained inappropriate behavior, harassment of an
|
110
|
-
individual, or aggression toward or disparagement of classes of individuals.
|
111
|
-
|
112
|
-
**Consequence**: A permanent ban from any sort of public interaction within the
|
113
|
-
community.
|
114
|
-
|
115
|
-
## Attribution
|
116
|
-
|
117
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
118
|
-
version 2.1, available at
|
119
|
-
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
120
|
-
|
121
|
-
Community Impact Guidelines were inspired by
|
122
|
-
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
|
123
|
-
|
124
|
-
For answers to common questions about this code of conduct, see the FAQ at
|
125
|
-
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
|
126
|
-
[https://www.contributor-covenant.org/translations][translations].
|
127
|
-
|
128
|
-
[homepage]: https://www.contributor-covenant.org
|
129
|
-
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
130
|
-
[Mozilla CoC]: https://github.com/mozilla/diversity
|
131
|
-
[FAQ]: https://www.contributor-covenant.org/faq
|
132
|
-
[translations]: https://www.contributor-covenant.org/translations
|
data/CONTRIBUTING.md
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
# CONTRIBUTORS GUIDELINE
|
2
|
-
|
3
|
-
## Welcome
|
4
|
-
|
5
|
-
Welcome to Alba, and thank you for being interested in contributing to Alba. This document describes how to contribute to Alba.
|
6
|
-
|
7
|
-
## Code of Conduct
|
8
|
-
|
9
|
-
We have the [code of conduct](https://github.com/okuramasafumi/alba/blob/master/CODE_OF_CONDUCT.md) that all contributors are expected to adhere for Alba to be a safe and welcoming space.
|
10
|
-
|
11
|
-
## Bugs and Issues
|
12
|
-
|
13
|
-
If you find any bugs or issues, please submit an issue on [GitHub](https://github.com/okuramasafumi/alba/issues). Please follow the issue template as much as possible so that maintainers can find and fix it quickly.
|
14
|
-
|
15
|
-
## Feature Request
|
16
|
-
|
17
|
-
If you have any feature that you think Alba should have, please submit a feature request on [GitHub](https://github.com/okuramasafumi/alba/issues).
|
18
|
-
|
19
|
-
## Pull Request
|
20
|
-
|
21
|
-
You're more than welcomed to submit a Pull Request! You are expected to follow these rules before submitting:
|
22
|
-
|
23
|
-
* You must split your Pull Request into multiple ones if you solve more than one problem
|
24
|
-
* You must write tests if you implement a feature or fix a bug
|
25
|
-
* You should provide reason(s) behind your change unless it's so simple
|
26
|
-
|
27
|
-
## Documents
|
28
|
-
|
29
|
-
* [code of conduct](https://github.com/okuramasafumi/alba/blob/master/CODE_OF_CONDUCT.md) for all contributors
|
30
|
-
* [hacking document](https://github.com/okuramasafumi/alba/blob/main/HACKING.md) for those who want to know the internal of Alba
|
data/Gemfile
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
source 'https://rubygems.org'
|
4
|
-
|
5
|
-
# Specify your gem's dependencies in alba.gemspec
|
6
|
-
gemspec
|
7
|
-
|
8
|
-
gem 'activesupport', require: false # For backend
|
9
|
-
gem 'dry-inflector', require: false # For inflection
|
10
|
-
gem 'ffaker', require: false # For testing
|
11
|
-
gem 'minitest', '~> 5.14' # For test
|
12
|
-
gem 'railties', require: false # For Rails integration testing
|
13
|
-
gem 'rake', '~> 13.0' # For test and automation
|
14
|
-
gem 'rubocop', '~> 1.69.0', require: false # For lint
|
15
|
-
gem 'rubocop-gem_dev', '>= 0.3.0', require: false # For lint
|
16
|
-
gem 'rubocop-md', '~> 1.0', require: false # For lint
|
17
|
-
gem 'rubocop-minitest', '~> 0.36.0', require: false # For lint
|
18
|
-
gem 'rubocop-performance', '~> 1.23.0', require: false # For lint
|
19
|
-
gem 'rubocop-rake', '~> 0.6.0', require: false # For lint
|
20
|
-
gem 'simplecov', '~> 0.22.0', require: false # For test coverage
|
21
|
-
gem 'simplecov-cobertura', require: false # For test coverage
|
22
|
-
# gem 'steep', require: false # For language server and typing
|
23
|
-
# gem 'typeprof', require: false # For language server and typing
|
24
|
-
gem 'yard', require: false # For documentation
|
25
|
-
|
26
|
-
# FIXME: There is an upstream JRuby 9.4.9.0 issue with `psych` and the latest
|
27
|
-
# version of `jar-dependencies`. The issue will be resolved with the release of
|
28
|
-
# 9.4.10.0. Then, we can remove this `jar-dependencies` dependency lock.
|
29
|
-
#
|
30
|
-
# For more information, see: https://github.com/jruby/jruby/issues/8488
|
31
|
-
#
|
32
|
-
if defined?(JRUBY_VERSION) && Gem::Version.new(JRUBY_VERSION) < Gem::Version.new('9.4.10.0')
|
33
|
-
gem 'jar-dependencies', '< 0.5' # Fix
|
34
|
-
end
|
35
|
-
|
36
|
-
platforms :ruby do
|
37
|
-
gem 'oj', '~> 3.11', require: false # For backend
|
38
|
-
gem 'ruby-prof', require: false # For performance profiling
|
39
|
-
end
|
data/HACKING.md
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
# Hacking document
|
2
|
-
|
3
|
-
This document is intended to provide detailed information about the internal design and implementation of Alba. You are recommended to read through it if you want to hack Alba.
|
4
|
-
|
5
|
-
## Design
|
6
|
-
|
7
|
-
The design of Alba is simple. `Alba::Resource` module is the only interface end users use by `include`ing it. Other classes and modules are referenced by `Alba::Resource`.
|
8
|
-
|
9
|
-
When a class `include`s `Alba::Resource` module it defines `ClassMethods` such as `attributes` and `InstanceMethods` such as `serialize`. Instance methods work with information collected by class methods.
|
10
|
-
|
11
|
-
## Methods
|
12
|
-
|
13
|
-
The main methods users directly use are listed below.
|
14
|
-
|
15
|
-
Class methods (DSL):
|
16
|
-
|
17
|
-
* `attribute` for block style attribute
|
18
|
-
* `attributes` for symbol style attribute
|
19
|
-
* `association` and its aliases such as `one` for association
|
20
|
-
* `nested` for nested attribute
|
21
|
-
|
22
|
-
Instance methods:
|
23
|
-
|
24
|
-
* `serializable_hash` and `to_h` for hash from target object
|
25
|
-
* `serialize` and `to_json` for serialized JSON string
|
26
|
-
|
27
|
-
Other methods are rather trivial. They'll be added to this list when it turned out it's important enough.
|
28
|
-
|
29
|
-
## Implementation
|
30
|
-
|
31
|
-
In `Alba::Resource` module there are some things to note.
|
32
|
-
|
33
|
-
`@object` is an object for serialization. It's either a singular object or a collection.
|
34
|
-
|
35
|
-
Attribute object can be either `Symbol`, `Proc`, `Alba::Association` or `Alba::TypedAttribute`.
|
36
|
-
|
37
|
-
* `Symbol` attributes come from `attributes` method and are sent to `__send__` as method name
|
38
|
-
* `Proc` attributes come from `attribute` method and are `instance_exec`uted
|
39
|
-
* `Alba::Association` attributes come from `association` method and `to_h` method on the object is called
|
40
|
-
* `Alba::TypedAttribute` attributes come when users specify `type` option and `value` method on the object is called
|
41
|
-
|
42
|
-
When users provide `if` option, the attribute object becomes an `Array`. It contains two element, attribute itself and condition.
|
data/Rakefile
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'bundler/gem_tasks'
|
4
|
-
require 'rake/testtask'
|
5
|
-
|
6
|
-
if ENV['BUNDLE_GEMFILE'] == File.expand_path('Gemfile') || ENV['BUNDLE_GEMFILE'].empty? || ENV['BUNDLE_GEMFILE'].nil?
|
7
|
-
ENV['BUNDLE_GEMFILE'] = File.expand_path('Gemfile')
|
8
|
-
end
|
9
|
-
|
10
|
-
Rake::TestTask.new(:test) do |t|
|
11
|
-
t.libs << 'test'
|
12
|
-
t.libs << 'lib'
|
13
|
-
file_list = ENV['BUNDLE_GEMFILE'] == File.expand_path('Gemfile') ? FileList['test/**/*_test.rb'] : FileList['test/dependencies/test_dependencies.rb']
|
14
|
-
t.test_files = file_list
|
15
|
-
end
|
16
|
-
|
17
|
-
task default: :test
|
data/SECURITY.md
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
# Security Policy
|
2
|
-
|
3
|
-
## Supported Versions
|
4
|
-
|
5
|
-
| Version | Supported |
|
6
|
-
| ------- | ------------------ |
|
7
|
-
| 1.x.y | :white_check_mark: |
|
8
|
-
| < 1.0 | :x: |
|
9
|
-
|
10
|
-
## Reporting a Vulnerability
|
11
|
-
|
12
|
-
If you find a vulnerability of Alba, please contact me (OKURA Masafumi) via [email](masafumi.o1988@gmail.com). I'll report back within a few days.
|
data/alba.gemspec
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
require_relative 'lib/alba/version'
|
2
|
-
|
3
|
-
Gem::Specification.new do |spec|
|
4
|
-
spec.name = 'alba'
|
5
|
-
spec.version = Alba::VERSION
|
6
|
-
spec.authors = ['OKURA Masafumi']
|
7
|
-
spec.email = ['masafumi.o1988@gmail.com']
|
8
|
-
|
9
|
-
spec.summary = 'Alba is the fastest JSON serializer for Ruby.'
|
10
|
-
spec.description = "Alba is the fastest JSON serializer for Ruby. It focuses on performance, flexibility and usability."
|
11
|
-
spec.homepage = 'https://github.com/okuramasafumi/alba'
|
12
|
-
spec.license = 'MIT'
|
13
|
-
spec.required_ruby_version = Gem::Requirement.new('>= 3.0.0')
|
14
|
-
|
15
|
-
spec.metadata = {
|
16
|
-
'bug_tracker_uri' => 'https://github.com/okuramasafumi/alba/issues',
|
17
|
-
'changelog_uri' => 'https://github.com/okuramasafumi/alba/blob/main/CHANGELOG.md',
|
18
|
-
'documentation_uri' => 'https://rubydoc.info/github/okuramasafumi/alba',
|
19
|
-
'source_code_uri' => 'https://github.com/okuramasafumi/alba',
|
20
|
-
'rubygems_mfa_required' => 'true'
|
21
|
-
}
|
22
|
-
|
23
|
-
# Specify which files should be added to the gem when it is released.
|
24
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
25
|
-
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
26
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
27
|
-
end
|
28
|
-
spec.bindir = 'exe'
|
29
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
30
|
-
spec.require_paths = ['lib']
|
31
|
-
|
32
|
-
spec.add_dependency "ostruct", "~> 0.6"
|
33
|
-
end
|
data/benchmark/Gemfile
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
source 'https://rubygems.org'
|
4
|
-
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
5
|
-
|
6
|
-
gem 'active_model_serializers'
|
7
|
-
gem 'activerecord', '~> 7.1'
|
8
|
-
gem 'alba', path: '../'
|
9
|
-
gem 'benchmark-ips'
|
10
|
-
gem 'benchmark-memory'
|
11
|
-
gem 'blueprinter'
|
12
|
-
gem 'csv'
|
13
|
-
gem 'fast_serializer_ruby'
|
14
|
-
gem 'jbuilder'
|
15
|
-
gem 'jserializer'
|
16
|
-
gem 'json'
|
17
|
-
gem 'multi_json'
|
18
|
-
gem 'oj'
|
19
|
-
gem 'oj_serializers'
|
20
|
-
gem 'panko_serializer'
|
21
|
-
gem 'pg'
|
22
|
-
gem 'primalize'
|
23
|
-
gem 'representable'
|
24
|
-
gem 'simple_ams'
|
25
|
-
gem 'sqlite3', '~> 1.4'
|
26
|
-
gem 'turbostreamer'
|
data/benchmark/README.md
DELETED
@@ -1,137 +0,0 @@
|
|
1
|
-
## Benchmark for json serializers
|
2
|
-
|
3
|
-
This directory contains a few different benchmark scripts.
|
4
|
-
|
5
|
-
## How to run
|
6
|
-
|
7
|
-
```
|
8
|
-
bundle install
|
9
|
-
|
10
|
-
# with `Oj.optimize_rails`
|
11
|
-
bundle exec ruby collection.rb
|
12
|
-
|
13
|
-
# without `Oj.optimize_rails`
|
14
|
-
NO_OJ_OPTIMIZE_RAILS=1 bundle exec ruby collection.rb
|
15
|
-
|
16
|
-
# with `Oj.optimize_rails` and YJIT
|
17
|
-
YJIT=1 bundle exec ruby collection.rb
|
18
|
-
|
19
|
-
# with YJIT and without `Oj.optimize_rails`
|
20
|
-
YJIT=1 NO_OJ_OPTIMIZE_RAILS=1 bundle exec ruby collection.rb
|
21
|
-
```
|
22
|
-
|
23
|
-
## Result
|
24
|
-
|
25
|
-
As a reference, here's the benchmark result run in my (@okuramasafumi) machine.
|
26
|
-
|
27
|
-
Machine spec:
|
28
|
-
|
29
|
-
|Key|Value|
|
30
|
-
|---|---|
|
31
|
-
|OS|macOS 14.7|
|
32
|
-
|CPU|Apple M1 Pro|
|
33
|
-
|RAM|16GB|
|
34
|
-
|Ruby|ruby 3.3.5 (2024-09-03 revision ef084cc8f4) [arm64-darwin23]|
|
35
|
-
|
36
|
-
Library versions:
|
37
|
-
|
38
|
-
|Library|Version|
|
39
|
-
|---|---|
|
40
|
-
|alba|3.2.0|
|
41
|
-
|blueprinter|1.1.0|
|
42
|
-
|fast_serializer_ruby|0.6.9|
|
43
|
-
|jserializer|0.2.1|
|
44
|
-
|oj|3.16.6|
|
45
|
-
|simple_ams|0.2.6|
|
46
|
-
|representable|3.2.0|
|
47
|
-
|turbostreamer|1.11.0|
|
48
|
-
|jbuilder|2.13.0|
|
49
|
-
|panko_serializer|0.8.2|
|
50
|
-
|active_model_serializers|0.10.14|
|
51
|
-
|
52
|
-
`benchmark-ips` with `Oj.optimize_rails`:
|
53
|
-
|
54
|
-
```
|
55
|
-
Comparison:
|
56
|
-
panko: 447.0 i/s
|
57
|
-
jserializer: 168.9 i/s - 2.65x slower
|
58
|
-
alba_inline: 149.4 i/s - 2.99x slower
|
59
|
-
alba: 146.5 i/s - 3.05x slower
|
60
|
-
turbostreamer: 138.7 i/s - 3.22x slower
|
61
|
-
rails: 105.6 i/s - 4.23x slower
|
62
|
-
fast_serializer: 97.6 i/s - 4.58x slower
|
63
|
-
blueprinter: 66.7 i/s - 6.70x slower
|
64
|
-
representable: 50.6 i/s - 8.83x slower
|
65
|
-
simple_ams: 35.5 i/s - 12.57x slower
|
66
|
-
ams: 14.8 i/s - 30.25x slower
|
67
|
-
```
|
68
|
-
|
69
|
-
`benchmark-ips` without `Oj.optimize_rails`:
|
70
|
-
|
71
|
-
```
|
72
|
-
Comparison:
|
73
|
-
panko: 457.9 i/s
|
74
|
-
jserializer: 165.9 i/s - 2.76x slower
|
75
|
-
alba: 160.1 i/s - 2.86x slower
|
76
|
-
alba_inline: 158.5 i/s - 2.89x slower
|
77
|
-
turbostreamer: 141.7 i/s - 3.23x slower
|
78
|
-
fast_serializer: 96.2 i/s - 4.76x slower
|
79
|
-
rails: 87.2 i/s - 5.25x slower
|
80
|
-
blueprinter: 67.4 i/s - 6.80x slower
|
81
|
-
representable: 43.4 i/s - 10.55x slower
|
82
|
-
simple_ams: 34.7 i/s - 13.20x slower
|
83
|
-
ams: 14.2 i/s - 32.28x slower
|
84
|
-
```
|
85
|
-
|
86
|
-
`benchmark-ips` with `Oj.optimize_rails` and YJIT:
|
87
|
-
|
88
|
-
```
|
89
|
-
Comparison:
|
90
|
-
panko: 676.6 i/s
|
91
|
-
jserializer: 285.3 i/s - 2.37x slower
|
92
|
-
turbostreamer: 264.2 i/s - 2.56x slower
|
93
|
-
alba: 258.9 i/s - 2.61x slower
|
94
|
-
fast_serializer: 179.0 i/s - 3.78x slower
|
95
|
-
rails: 150.7 i/s - 4.49x slower
|
96
|
-
alba_inline: 131.5 i/s - 5.15x slower
|
97
|
-
blueprinter: 110.0 i/s - 6.15x slower
|
98
|
-
representable: 73.5 i/s - 9.21x slower
|
99
|
-
simple_ams: 62.8 i/s - 10.77x slower
|
100
|
-
ams: 20.4 i/s - 33.10x slower
|
101
|
-
```
|
102
|
-
|
103
|
-
`benchmark-ips` with YJIT and without `Oj.optimize_rails`:
|
104
|
-
|
105
|
-
```
|
106
|
-
Comparison:
|
107
|
-
panko: 701.9 i/s
|
108
|
-
alba: 311.1 i/s - 2.26x slower
|
109
|
-
jserializer: 281.6 i/s - 2.49x slower
|
110
|
-
turbostreamer: 240.4 i/s - 2.92x slower
|
111
|
-
fast_serializer: 180.5 i/s - 3.89x slower
|
112
|
-
alba_inline: 135.6 i/s - 5.18x slower
|
113
|
-
rails: 131.4 i/s - 5.34x slower
|
114
|
-
blueprinter: 110.7 i/s - 6.34x slower
|
115
|
-
representable: 70.5 i/s - 9.96x slower
|
116
|
-
simple_ams: 57.3 i/s - 12.24x slower
|
117
|
-
ams: 20.3 i/s - 34.51x slower
|
118
|
-
```
|
119
|
-
|
120
|
-
`benchmark-memory`:
|
121
|
-
|
122
|
-
```
|
123
|
-
Comparison:
|
124
|
-
panko: 259178 allocated
|
125
|
-
turbostreamer: 817800 allocated - 3.16x more
|
126
|
-
jserializer: 826425 allocated - 3.19x more
|
127
|
-
alba: 846465 allocated - 3.27x more
|
128
|
-
alba_inline: 867361 allocated - 3.35x more
|
129
|
-
fast_serializer: 1474345 allocated - 5.69x more
|
130
|
-
rails: 2265905 allocated - 8.74x more
|
131
|
-
blueprinter: 2469905 allocated - 9.53x more
|
132
|
-
representable: 4994281 allocated - 19.27x more
|
133
|
-
ams: 5233265 allocated - 20.19x more
|
134
|
-
simple_ams: 9506817 allocated - 36.68x more
|
135
|
-
```
|
136
|
-
|
137
|
-
Conclusion: panko is extremely fast but it's a C extension gem. As pure Ruby gems, Alba, `turbostreamer` and `jserializer` are notably faster than others, but Alba is slightly slower than other two. With `Oj.optimize_rails`, `jbuilder` and Rails standard serialization are also fast.
|