panko_serializer 0.8.2 → 0.8.4
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/dependabot.yml +6 -0
- data/.github/workflows/database_matrix.yml +85 -0
- data/.github/workflows/docs.yml +5 -5
- data/.github/workflows/lint.yml +10 -16
- data/.github/workflows/{ruby.yml → tests.yml} +9 -22
- data/.gitignore +2 -0
- data/.rubocop.yml +29 -21
- data/Appraisals +23 -12
- data/Gemfile +12 -3
- data/README.md +4 -4
- data/Rakefile +3 -1
- data/benchmarks/allocs.rb +2 -2
- data/benchmarks/benchmarking_support.rb +2 -1
- data/benchmarks/bm_ams_0_10.rb +3 -7
- data/benchmarks/bm_panko_json.rb +2 -6
- data/benchmarks/bm_panko_object.rb +2 -6
- data/benchmarks/bm_plain_object.rb +1 -4
- data/benchmarks/bm_serialization_descriptor.rb +1 -1
- data/benchmarks/bm_to_object.rb +2 -6
- data/benchmarks/profile.rb +2 -2
- data/benchmarks/sanity.rb +2 -6
- data/benchmarks/setup.rb +4 -3
- data/benchmarks/type_casts/support.rb +0 -1
- data/docs/docs/associations.md +28 -15
- data/docs/docs/attributes.md +33 -20
- data/docs/docs/design-choices.md +36 -35
- data/docs/docs/getting-started.md +13 -7
- data/docs/docs/introduction.md +6 -6
- data/docs/docs/performance.md +4 -5
- data/docs/docs/response-bag.md +13 -6
- data/docs/docusaurus.config.js +86 -0
- data/docs/package-lock.json +13999 -18188
- data/docs/package.json +10 -6
- data/docs/src/css/customTheme.css +9 -0
- data/docs/static/CNAME +1 -0
- data/ext/panko_serializer/attributes_writer/active_record.c +81 -77
- data/ext/panko_serializer/attributes_writer/active_record.h +2 -0
- data/ext/panko_serializer/attributes_writer/type_cast/type_cast.c +1 -1
- data/gemfiles/{6.1.0.gemfile → 7.2.0.gemfile} +17 -6
- data/gemfiles/7.2.0.gemfile.lock +221 -0
- data/gemfiles/{7.0.0.gemfile → 8.0.0.gemfile} +17 -6
- data/gemfiles/8.0.0.gemfile.lock +239 -0
- data/gemfiles/{7.1.0.gemfile → 8.1.0.gemfile} +17 -6
- data/gemfiles/8.1.0.gemfile.lock +248 -0
- data/lib/panko/version.rb +1 -1
- data/panko_serializer.gemspec +1 -1
- metadata +16 -21
- data/.standard.yml +0 -5
- data/docs/.DS_Store +0 -0
- data/docs/README.md +0 -198
- data/docs/core/Footer.js +0 -80
- data/docs/i18n/en.json +0 -50
- data/docs/siteConfig.js +0 -80
- data/gemfiles/6.1.0.gemfile.lock +0 -166
- data/gemfiles/7.0.0.gemfile.lock +0 -164
- data/gemfiles/7.1.0.gemfile.lock +0 -181
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7b4397a54b1f806131ee07ccaaa4062bba8eb5490c3810e5c6c3cc405b7167ec
|
|
4
|
+
data.tar.gz: 8f3127a38fe93844c3a82aa8e2a30ea82312ef1b0ebdf66f86bcd4761c392749
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 626bf9689a4be25a166a7ee3fe3b2274cfcc9b7bb17d57398d87301aca1c8039835d02ef37de647d62d3fa5c102cc22f752b2400e10240fa992d2007eaf9344c
|
|
7
|
+
data.tar.gz: 9a0048188abc83c9a064a0bb7721cc94a7f3965338f62a84fe4382a7b98f52941c1a1914f25dfee3bc7ed80168a1bb47f7def51954b9b1250029e4784f6f0a5d
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
name: Database Tests
|
|
2
|
+
|
|
3
|
+
on: [push, pull_request]
|
|
4
|
+
|
|
5
|
+
jobs:
|
|
6
|
+
database-matrix:
|
|
7
|
+
runs-on: ubuntu-latest
|
|
8
|
+
|
|
9
|
+
strategy:
|
|
10
|
+
fail-fast: false
|
|
11
|
+
matrix:
|
|
12
|
+
ruby: ["3.4"]
|
|
13
|
+
rails: ["7.2.0", "8.0.0"]
|
|
14
|
+
database: ["sqlite", "postgresql", "mysql"]
|
|
15
|
+
|
|
16
|
+
services:
|
|
17
|
+
postgres:
|
|
18
|
+
image: postgres:17
|
|
19
|
+
env:
|
|
20
|
+
POSTGRES_DB: panko_test
|
|
21
|
+
POSTGRES_USER: postgres
|
|
22
|
+
POSTGRES_PASSWORD: password
|
|
23
|
+
options: >-
|
|
24
|
+
--health-cmd pg_isready
|
|
25
|
+
--health-interval 10s
|
|
26
|
+
--health-timeout 5s
|
|
27
|
+
--health-retries 5
|
|
28
|
+
ports:
|
|
29
|
+
- 5432:5432
|
|
30
|
+
|
|
31
|
+
mysql:
|
|
32
|
+
image: mysql:8.0
|
|
33
|
+
env:
|
|
34
|
+
MYSQL_DATABASE: panko_test
|
|
35
|
+
MYSQL_ROOT_PASSWORD: password
|
|
36
|
+
options: >-
|
|
37
|
+
--health-cmd="mysqladmin ping"
|
|
38
|
+
--health-interval=10s
|
|
39
|
+
--health-timeout=5s
|
|
40
|
+
--health-retries=3
|
|
41
|
+
ports:
|
|
42
|
+
- 3306:3306
|
|
43
|
+
|
|
44
|
+
steps:
|
|
45
|
+
- name: Install system dependencies
|
|
46
|
+
run: |
|
|
47
|
+
sudo apt update -y
|
|
48
|
+
sudo apt install -y libsqlite3-dev libpq-dev libmysqlclient-dev
|
|
49
|
+
|
|
50
|
+
- uses: actions/checkout@v5
|
|
51
|
+
|
|
52
|
+
- name: Configure MySQL authentication
|
|
53
|
+
if: matrix.database == 'mysql'
|
|
54
|
+
run: |
|
|
55
|
+
# Configure MySQL to use mysql_native_password for Trilogy compatibility
|
|
56
|
+
mysql -h 127.0.0.1 -P 3306 -u root -ppassword -e "
|
|
57
|
+
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
|
|
58
|
+
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'password';
|
|
59
|
+
FLUSH PRIVILEGES;
|
|
60
|
+
"
|
|
61
|
+
|
|
62
|
+
- name: Set up Ruby ${{ matrix.ruby }}
|
|
63
|
+
uses: ruby/setup-ruby@v1
|
|
64
|
+
with:
|
|
65
|
+
ruby-version: ${{ matrix.ruby }}
|
|
66
|
+
bundler-cache: true
|
|
67
|
+
working-directory: .
|
|
68
|
+
env:
|
|
69
|
+
BUNDLE_GEMFILE: gemfiles/${{ matrix.rails }}.gemfile
|
|
70
|
+
DB: ${{ matrix.database }}
|
|
71
|
+
|
|
72
|
+
- name: Compile & test
|
|
73
|
+
env:
|
|
74
|
+
BUNDLE_GEMFILE: gemfiles/${{ matrix.rails }}.gemfile
|
|
75
|
+
DB: ${{ matrix.database }}
|
|
76
|
+
POSTGRES_HOST: localhost
|
|
77
|
+
POSTGRES_USER: postgres
|
|
78
|
+
POSTGRES_PASSWORD: password
|
|
79
|
+
POSTGRES_PORT: 5432
|
|
80
|
+
MYSQL_HOST: localhost
|
|
81
|
+
MYSQL_USER: root
|
|
82
|
+
MYSQL_PASSWORD: password
|
|
83
|
+
MYSQL_PORT: 3306
|
|
84
|
+
run: |
|
|
85
|
+
bundle exec rake
|
data/.github/workflows/docs.yml
CHANGED
|
@@ -5,7 +5,7 @@ name: Docs Publishing
|
|
|
5
5
|
|
|
6
6
|
on:
|
|
7
7
|
push:
|
|
8
|
-
branches: [ master ]
|
|
8
|
+
branches: [ master, docup ]
|
|
9
9
|
|
|
10
10
|
jobs:
|
|
11
11
|
build:
|
|
@@ -15,11 +15,11 @@ jobs:
|
|
|
15
15
|
working_directory: 'docs/'
|
|
16
16
|
|
|
17
17
|
steps:
|
|
18
|
-
- uses: actions/checkout@
|
|
18
|
+
- uses: actions/checkout@v5
|
|
19
19
|
- name: Use Node.js ${{ matrix.node-version }}
|
|
20
|
-
uses: actions/setup-node@
|
|
20
|
+
uses: actions/setup-node@v4
|
|
21
21
|
with:
|
|
22
|
-
node-version: '
|
|
22
|
+
node-version: '20.x'
|
|
23
23
|
|
|
24
24
|
- name: Install Dependencies
|
|
25
25
|
working-directory: ${{ env.working_directory }}
|
|
@@ -35,5 +35,5 @@ jobs:
|
|
|
35
35
|
run: |
|
|
36
36
|
git config --global user.email "action@github.com"
|
|
37
37
|
git config --global user.name "GitHub Action"
|
|
38
|
-
GIT_USER=yosiat CURRENT_BRANCH=master USE_SSH=true npm run
|
|
38
|
+
GIT_USER=yosiat CURRENT_BRANCH=master USE_SSH=true npm run deploy
|
|
39
39
|
|
data/.github/workflows/lint.yml
CHANGED
|
@@ -3,33 +3,27 @@ name: Lint
|
|
|
3
3
|
on: [push, pull_request]
|
|
4
4
|
|
|
5
5
|
jobs:
|
|
6
|
-
|
|
6
|
+
lint:
|
|
7
7
|
runs-on: ubuntu-latest
|
|
8
8
|
|
|
9
9
|
steps:
|
|
10
|
-
- uses: actions/checkout@
|
|
11
|
-
- name: Set up Ruby
|
|
12
|
-
uses: ruby/setup-ruby@v1
|
|
13
|
-
with:
|
|
14
|
-
ruby-version: 3.1.0
|
|
10
|
+
- uses: actions/checkout@v5
|
|
15
11
|
|
|
16
12
|
- name: Install deps
|
|
17
13
|
run: |
|
|
18
14
|
sudo apt update -y
|
|
19
15
|
sudo apt install -y libsqlite3-dev
|
|
20
16
|
|
|
21
|
-
- name:
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
run: |
|
|
29
|
-
bundle exec rake standard
|
|
17
|
+
- name: Lint Ruby code
|
|
18
|
+
uses: ruby/setup-ruby@v1
|
|
19
|
+
with:
|
|
20
|
+
ruby-version: 3
|
|
21
|
+
bundler-cache: true
|
|
22
|
+
- run: |
|
|
23
|
+
bundle exec rake rubocop
|
|
30
24
|
|
|
31
25
|
- name: Lint C
|
|
32
|
-
uses: jidicula/clang-format-action@v4.
|
|
26
|
+
uses: jidicula/clang-format-action@v4.16.0
|
|
33
27
|
with:
|
|
34
28
|
clang-format-version: "16"
|
|
35
29
|
check-path: "ext/panko_serializer"
|
|
@@ -3,42 +3,29 @@ name: Panko Serializer CI
|
|
|
3
3
|
on: [push, pull_request]
|
|
4
4
|
|
|
5
5
|
jobs:
|
|
6
|
-
|
|
6
|
+
tests:
|
|
7
7
|
runs-on: ubuntu-latest
|
|
8
8
|
strategy:
|
|
9
9
|
fail-fast: false
|
|
10
10
|
matrix:
|
|
11
|
-
ruby: ["3.
|
|
12
|
-
rails: ["
|
|
11
|
+
ruby: ["3.2", "3.3", "3.4"]
|
|
12
|
+
rails: ["7.2.0", "8.0.0", "8.1.0"]
|
|
13
13
|
|
|
14
14
|
steps:
|
|
15
|
-
- uses: actions/checkout@v4
|
|
16
|
-
- name: Set up Ruby ${{ matrix.ruby }}
|
|
17
|
-
uses: ruby/setup-ruby@v1
|
|
18
|
-
with:
|
|
19
|
-
ruby-version: ${{ matrix.ruby }}
|
|
20
|
-
|
|
21
15
|
- name: Install deps
|
|
22
16
|
run: |
|
|
23
17
|
sudo apt update -y
|
|
24
18
|
sudo apt install -y libsqlite3-dev
|
|
25
19
|
|
|
26
|
-
-
|
|
27
|
-
|
|
28
|
-
uses:
|
|
20
|
+
- uses: actions/checkout@v5
|
|
21
|
+
- name: Set up Ruby ${{ matrix.ruby }}
|
|
22
|
+
uses: ruby/setup-ruby@v1
|
|
29
23
|
with:
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
${{ runner.os }}-${{ matrix.ruby }}-${{ matrix.rails }}-gem
|
|
34
|
-
|
|
35
|
-
- name: Install gems
|
|
24
|
+
ruby-version: ${{ matrix.ruby }}
|
|
25
|
+
bundler-cache: true
|
|
26
|
+
working-directory: .
|
|
36
27
|
env:
|
|
37
28
|
BUNDLE_GEMFILE: gemfiles/${{ matrix.rails }}.gemfile
|
|
38
|
-
run: |
|
|
39
|
-
gem install bundler
|
|
40
|
-
bundle config set path 'vendor/bundle'
|
|
41
|
-
bundle check || bundle install --jobs 4 --retry 3
|
|
42
29
|
|
|
43
30
|
- name: Compile & test
|
|
44
31
|
env:
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
|
@@ -1,29 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
# We want Exclude directives from different
|
|
2
|
+
# config files to get merged, not overwritten
|
|
3
|
+
inherit_mode:
|
|
4
|
+
merge:
|
|
5
|
+
- Exclude
|
|
6
|
+
|
|
7
|
+
require:
|
|
8
|
+
- standard
|
|
9
|
+
- rubocop-performance
|
|
10
|
+
- standard-performance
|
|
11
|
+
- rubocop-rspec
|
|
12
|
+
|
|
13
|
+
inherit_gem:
|
|
14
|
+
standard: config/base.yml
|
|
15
|
+
standard-performance: config/base.yml
|
|
5
16
|
|
|
6
|
-
|
|
7
|
-
|
|
17
|
+
AllCops:
|
|
18
|
+
TargetRubyVersion: 3.1
|
|
19
|
+
SuggestExtensions: false
|
|
20
|
+
NewCops: disable
|
|
21
|
+
Exclude:
|
|
22
|
+
- ext/**/*
|
|
23
|
+
- gemfiles/**/*
|
|
8
24
|
|
|
9
|
-
Style/StringLiterals:
|
|
10
|
-
EnforcedStyle: double_quotes
|
|
11
25
|
|
|
12
26
|
Style/FrozenStringLiteralComment:
|
|
13
27
|
Enabled: true
|
|
14
28
|
EnforcedStyle: always
|
|
29
|
+
SafeAutoCorrect: true
|
|
15
30
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
Layout/TrailingWhitespace:
|
|
20
|
-
Enabled: true
|
|
31
|
+
# TODO: need to work on specs.
|
|
32
|
+
RSpec:
|
|
33
|
+
Enabled: false
|
|
21
34
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
Style/RedundantFreeze:
|
|
26
|
-
Enabled: true
|
|
27
|
-
|
|
28
|
-
Performance/UnfreezeString:
|
|
29
|
-
Enabled: true
|
|
35
|
+
Lint/ConstantDefinitionInBlock:
|
|
36
|
+
Exclude:
|
|
37
|
+
- spec/**/*
|
data/Appraisals
CHANGED
|
@@ -1,17 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
gem "
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
appraise "7.2.0" do
|
|
4
|
+
gem "activesupport", "~> 7.2.0"
|
|
5
|
+
gem "activemodel", "~> 7.2.0"
|
|
6
|
+
gem "activerecord", "~> 7.2.0", group: :test
|
|
7
|
+
|
|
8
|
+
gem "trilogy"
|
|
9
|
+
gem "sqlite3", "~> 1.4"
|
|
5
10
|
end
|
|
6
11
|
|
|
7
|
-
appraise "
|
|
8
|
-
gem "activesupport", "~>
|
|
9
|
-
gem "activemodel", "~>
|
|
10
|
-
gem "activerecord", "~>
|
|
12
|
+
appraise "8.0.0" do
|
|
13
|
+
gem "activesupport", "~> 8.0.0"
|
|
14
|
+
gem "activemodel", "~> 8.0.0"
|
|
15
|
+
gem "activerecord", "~> 8.0.0", group: :test
|
|
16
|
+
|
|
17
|
+
gem "trilogy"
|
|
18
|
+
gem "sqlite3", ">= 2.1"
|
|
11
19
|
end
|
|
12
20
|
|
|
13
|
-
appraise "
|
|
14
|
-
gem "activesupport", "~>
|
|
15
|
-
gem "activemodel", "~>
|
|
16
|
-
gem "activerecord", "~>
|
|
21
|
+
appraise "8.1.0" do
|
|
22
|
+
gem "activesupport", "~> 8.1.0"
|
|
23
|
+
gem "activemodel", "~> 8.1.0"
|
|
24
|
+
gem "activerecord", "~> 8.1.0", group: :test
|
|
25
|
+
|
|
26
|
+
gem "trilogy"
|
|
27
|
+
gem "sqlite3", ">= 2.1"
|
|
17
28
|
end
|
data/Gemfile
CHANGED
|
@@ -5,8 +5,9 @@ source "https://rubygems.org"
|
|
|
5
5
|
gemspec
|
|
6
6
|
|
|
7
7
|
group :benchmarks do
|
|
8
|
-
gem "
|
|
9
|
-
gem "
|
|
8
|
+
gem "vernier"
|
|
9
|
+
gem "stackprof"
|
|
10
|
+
gem "pg"
|
|
10
11
|
|
|
11
12
|
gem "benchmark-ips"
|
|
12
13
|
gem "active_model_serializers", "~> 0.10"
|
|
@@ -16,6 +17,7 @@ end
|
|
|
16
17
|
|
|
17
18
|
group :test do
|
|
18
19
|
gem "faker"
|
|
20
|
+
gem "temping"
|
|
19
21
|
end
|
|
20
22
|
|
|
21
23
|
group :development do
|
|
@@ -25,4 +27,11 @@ group :development do
|
|
|
25
27
|
gem "rake-compiler"
|
|
26
28
|
end
|
|
27
29
|
|
|
28
|
-
|
|
30
|
+
group :development, :test do
|
|
31
|
+
gem "rubocop"
|
|
32
|
+
|
|
33
|
+
gem "standard"
|
|
34
|
+
gem "standard-performance"
|
|
35
|
+
gem "rubocop-performance"
|
|
36
|
+
gem "rubocop-rspec"
|
|
37
|
+
end
|
data/README.md
CHANGED
|
@@ -4,20 +4,20 @@
|
|
|
4
4
|
|
|
5
5
|
Panko is a library which is inspired by ActiveModelSerializers 0.9 for serializing ActiveRecord/Ruby objects to JSON strings, fast.
|
|
6
6
|
|
|
7
|
-
To achieve its [performance](https://panko.dev/
|
|
7
|
+
To achieve its [performance](https://panko.dev/performance/):
|
|
8
8
|
|
|
9
9
|
* Oj - Panko relies on Oj since it's fast and allows for incremental serialization using `Oj::StringWriter`
|
|
10
10
|
* Serialization Descriptor - Panko computes most of the metadata ahead of time, to save time later in serialization.
|
|
11
11
|
* Type casting — Panko does type casting by itself, instead of relying on ActiveRecord.
|
|
12
12
|
|
|
13
|
-
To dig deeper about the performance choices, read [Design Choices](https://panko.dev/
|
|
13
|
+
To dig deeper about the performance choices, read [Design Choices](https://panko.dev/design-choices/).
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
Support
|
|
17
17
|
-------
|
|
18
18
|
|
|
19
|
-
- [Documentation](https://panko.dev/
|
|
20
|
-
- [Getting Started](https://panko.dev/
|
|
19
|
+
- [Documentation](https://panko.dev/)
|
|
20
|
+
- [Getting Started](https://panko.dev/getting-started/)
|
|
21
21
|
|
|
22
22
|
License
|
|
23
23
|
-------
|
data/Rakefile
CHANGED
|
@@ -6,7 +6,7 @@ require "json"
|
|
|
6
6
|
require "terminal-table"
|
|
7
7
|
require "rake/extensiontask"
|
|
8
8
|
require "pty"
|
|
9
|
-
require "
|
|
9
|
+
require "rubocop/rake_task"
|
|
10
10
|
|
|
11
11
|
gem = Gem::Specification.load(File.dirname(__FILE__) + "/panko_serializer.gemspec")
|
|
12
12
|
|
|
@@ -24,6 +24,8 @@ Rake::Task[:compile].prerequisites << :clean
|
|
|
24
24
|
|
|
25
25
|
task default: :spec
|
|
26
26
|
|
|
27
|
+
RuboCop::RakeTask.new
|
|
28
|
+
|
|
27
29
|
def print_and_flush(str)
|
|
28
30
|
print str
|
|
29
31
|
$stdout.flush
|
data/benchmarks/allocs.rb
CHANGED
|
@@ -10,8 +10,8 @@ class PostFastSerializer < Panko::Serializer
|
|
|
10
10
|
attributes :id, :body, :title, :author_id
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
def count_allocs(&
|
|
14
|
-
memory_report = MemoryProfiler.report(&
|
|
13
|
+
def count_allocs(&)
|
|
14
|
+
memory_report = MemoryProfiler.report(&)
|
|
15
15
|
puts memory_report.pretty_print
|
|
16
16
|
end
|
|
17
17
|
|
|
@@ -9,7 +9,8 @@ module Benchmark
|
|
|
9
9
|
def data
|
|
10
10
|
posts = Post.all.includes(:author).to_a
|
|
11
11
|
posts_50 = posts.first(50).to_a
|
|
12
|
-
|
|
12
|
+
posts_single = posts.first(1).to_a
|
|
13
|
+
{all: posts, small: posts_50, single: posts_single}
|
|
13
14
|
end
|
|
14
15
|
|
|
15
16
|
def run(label = nil, time: 10, disable_gc: true, warmup: 3, &block)
|
data/benchmarks/bm_ams_0_10.rb
CHANGED
|
@@ -5,7 +5,7 @@ require_relative "app"
|
|
|
5
5
|
require_relative "setup"
|
|
6
6
|
|
|
7
7
|
# disable logging for benchmarks
|
|
8
|
-
ActiveModelSerializers.logger = ActiveSupport::TaggedLogging.new(ActiveSupport::Logger.new(
|
|
8
|
+
ActiveModelSerializers.logger = ActiveSupport::TaggedLogging.new(ActiveSupport::Logger.new(File::NULL))
|
|
9
9
|
|
|
10
10
|
class AmsAuthorFastSerializer < ActiveModel::Serializer
|
|
11
11
|
attributes :id, :name
|
|
@@ -24,17 +24,13 @@ end
|
|
|
24
24
|
def benchmark_ams(prefix, serializer, options = {})
|
|
25
25
|
merged_options = options.merge(each_serializer: serializer)
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
posts = data[:all]
|
|
29
|
-
posts_50 = data[:small]
|
|
27
|
+
posts = Benchmark.data[:all]
|
|
30
28
|
|
|
31
29
|
Benchmark.run("AMS_#{prefix}_Posts_#{posts.count}") do
|
|
32
30
|
ActiveModelSerializers::SerializableResource.new(posts, merged_options).to_json
|
|
33
31
|
end
|
|
34
32
|
|
|
35
|
-
|
|
36
|
-
posts = data[:all]
|
|
37
|
-
posts_50 = data[:small]
|
|
33
|
+
posts_50 = Benchmark.data[:small]
|
|
38
34
|
|
|
39
35
|
Benchmark.run("AMS_#{prefix}_Posts_50") do
|
|
40
36
|
ActiveModelSerializers::SerializableResource.new(posts_50, merged_options).to_json
|
data/benchmarks/bm_panko_json.rb
CHANGED
|
@@ -37,9 +37,7 @@ class AuthorWithHasManyFastSerializer < Panko::Serializer
|
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
def benchmark(prefix, serializer, options = {})
|
|
40
|
-
|
|
41
|
-
posts = data[:all]
|
|
42
|
-
posts_50 = data[:small]
|
|
40
|
+
posts = Benchmark.data[:all]
|
|
43
41
|
|
|
44
42
|
merged_options = options.merge(each_serializer: serializer)
|
|
45
43
|
|
|
@@ -47,9 +45,7 @@ def benchmark(prefix, serializer, options = {})
|
|
|
47
45
|
Panko::ArraySerializer.new(posts, merged_options).to_json
|
|
48
46
|
end
|
|
49
47
|
|
|
50
|
-
|
|
51
|
-
posts = data[:all]
|
|
52
|
-
posts_50 = data[:small]
|
|
48
|
+
posts_50 = Benchmark.data[:small]
|
|
53
49
|
|
|
54
50
|
Benchmark.run("Panko_ActiveRecord_#{prefix}_Posts_50") do
|
|
55
51
|
Panko::ArraySerializer.new(posts_50, merged_options).to_json
|
|
@@ -25,9 +25,7 @@ class AuthorWithHasManyFastSerializer < Panko::Serializer
|
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
def benchmark(prefix, serializer, options = {})
|
|
28
|
-
|
|
29
|
-
posts = data[:all]
|
|
30
|
-
posts_50 = data[:small]
|
|
28
|
+
posts = Benchmark.data[:all]
|
|
31
29
|
|
|
32
30
|
merged_options = options.merge(each_serializer: serializer)
|
|
33
31
|
|
|
@@ -35,9 +33,7 @@ def benchmark(prefix, serializer, options = {})
|
|
|
35
33
|
Panko::ArraySerializer.new(posts, merged_options).to_a
|
|
36
34
|
end
|
|
37
35
|
|
|
38
|
-
|
|
39
|
-
posts = data[:all]
|
|
40
|
-
posts_50 = data[:small]
|
|
36
|
+
posts_50 = Benchmark.data[:small]
|
|
41
37
|
|
|
42
38
|
Benchmark.run("Panko_ActiveRecord_#{prefix}_Posts_50") do
|
|
43
39
|
Panko::ArraySerializer.new(posts_50, merged_options).to_a
|
|
@@ -78,7 +78,6 @@ end
|
|
|
78
78
|
def benchmark(prefix, serializer, options = {})
|
|
79
79
|
data = benchmark_data
|
|
80
80
|
posts = data[:all]
|
|
81
|
-
posts_50 = data[:small]
|
|
82
81
|
|
|
83
82
|
merged_options = options.merge(each_serializer: serializer)
|
|
84
83
|
|
|
@@ -86,9 +85,7 @@ def benchmark(prefix, serializer, options = {})
|
|
|
86
85
|
Panko::ArraySerializer.new(posts, merged_options).to_json
|
|
87
86
|
end
|
|
88
87
|
|
|
89
|
-
|
|
90
|
-
posts = data[:all]
|
|
91
|
-
posts_50 = data[:small]
|
|
88
|
+
posts_50 = benchmark_data[:small]
|
|
92
89
|
|
|
93
90
|
Benchmark.run("Panko_Plain_#{prefix}_Posts_50") do
|
|
94
91
|
Panko::ArraySerializer.new(posts_50, merged_options).to_json
|
data/benchmarks/bm_to_object.rb
CHANGED
|
@@ -62,9 +62,7 @@ class AuthorWithHasManyFastSerializer < Panko::Serializer
|
|
|
62
62
|
end
|
|
63
63
|
|
|
64
64
|
def benchmark(prefix, serializer, options = {})
|
|
65
|
-
|
|
66
|
-
posts = data[:all]
|
|
67
|
-
posts_50 = data[:small]
|
|
65
|
+
posts = Benchmark.data[:all]
|
|
68
66
|
|
|
69
67
|
merged_options = options.merge(each_serializer: serializer)
|
|
70
68
|
|
|
@@ -72,9 +70,7 @@ def benchmark(prefix, serializer, options = {})
|
|
|
72
70
|
Panko::ArraySerializer.new(posts, merged_options).to_a
|
|
73
71
|
end
|
|
74
72
|
|
|
75
|
-
|
|
76
|
-
posts = data[:all]
|
|
77
|
-
posts_50 = data[:small]
|
|
73
|
+
posts_50 = Benchmark.data[:small]
|
|
78
74
|
|
|
79
75
|
Benchmark.run("Panko_#{prefix}_Posts_50") do
|
|
80
76
|
Panko::ArraySerializer.new(posts_50, merged_options).to_a
|
data/benchmarks/profile.rb
CHANGED
data/benchmarks/sanity.rb
CHANGED
|
@@ -62,9 +62,7 @@ class AuthorWithHasManyFastSerializer < Panko::Serializer
|
|
|
62
62
|
end
|
|
63
63
|
|
|
64
64
|
def benchmark(prefix, serializer, options = {})
|
|
65
|
-
|
|
66
|
-
posts = data[:all]
|
|
67
|
-
posts_50 = data[:small]
|
|
65
|
+
posts = Benchmark.data[:all]
|
|
68
66
|
|
|
69
67
|
merged_options = options.merge(each_serializer: serializer)
|
|
70
68
|
|
|
@@ -72,9 +70,7 @@ def benchmark(prefix, serializer, options = {})
|
|
|
72
70
|
Panko::ArraySerializer.new(posts, merged_options).to_json
|
|
73
71
|
end
|
|
74
72
|
|
|
75
|
-
|
|
76
|
-
posts = data[:all]
|
|
77
|
-
posts_50 = data[:small]
|
|
73
|
+
posts_50 = Benchmark.data[:small]
|
|
78
74
|
|
|
79
75
|
Benchmark.run("Panko_#{prefix}_Posts_50") do
|
|
80
76
|
Panko::ArraySerializer.new(posts_50, merged_options).to_json
|
data/benchmarks/setup.rb
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
##########################################
|
|
6
6
|
require "active_record"
|
|
7
7
|
require "sqlite3"
|
|
8
|
+
require "securerandom"
|
|
8
9
|
|
|
9
10
|
# Change the following to reflect your database settings
|
|
10
11
|
ActiveRecord::Base.establish_connection(
|
|
@@ -46,9 +47,9 @@ Author.destroy_all
|
|
|
46
47
|
Post.transaction do
|
|
47
48
|
ENV.fetch("ITEMS_COUNT", "2300").to_i.times do
|
|
48
49
|
Post.create(
|
|
49
|
-
body:
|
|
50
|
-
title:
|
|
51
|
-
author: Author.create(name:
|
|
50
|
+
body: SecureRandom.hex(30),
|
|
51
|
+
title: SecureRandom.hex(20),
|
|
52
|
+
author: Author.create(name: SecureRandom.alphanumeric),
|
|
52
53
|
data: {a: 1, b: 2, c: 3}
|
|
53
54
|
)
|
|
54
55
|
end
|