panko_serializer 0.7.6 → 0.7.9
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/docs.yml +1 -1
- data/.github/workflows/lint.yml +41 -0
- data/.github/workflows/ruby.yml +35 -36
- data/.standard.yml +4 -0
- data/Gemfile +3 -2
- data/Rakefile +12 -16
- data/benchmarks/allocs.rb +1 -1
- data/benchmarks/app.rb +1 -1
- data/benchmarks/benchmarking_support.rb +3 -3
- data/benchmarks/bm_ams_0_10.rb +2 -5
- data/benchmarks/bm_object_writer.rb +1 -0
- data/benchmarks/bm_panko_json.rb +1 -1
- data/benchmarks/bm_panko_object.rb +1 -2
- data/benchmarks/bm_plain_object.rb +7 -7
- data/benchmarks/bm_serialization_descriptor.rb +5 -5
- data/benchmarks/bm_serializer_resolver.rb +1 -0
- data/benchmarks/bm_to_object.rb +2 -10
- data/benchmarks/profile.rb +5 -7
- data/benchmarks/sanity.rb +2 -10
- data/benchmarks/setup.rb +2 -2
- data/benchmarks/type_casts/bm_active_record.rb +6 -8
- data/benchmarks/type_casts/bm_panko.rb +11 -11
- data/benchmarks/type_casts/support.rb +6 -2
- data/docs/docs/introduction.md +1 -1
- data/docs/docs/performance.md +6 -6
- data/docs/package-lock.json +12556 -168
- data/ext/panko_serializer/attributes_writer/active_record.c +6 -6
- data/ext/panko_serializer/attributes_writer/active_record.h +1 -2
- data/ext/panko_serializer/attributes_writer/attributes_writer.c +5 -7
- data/ext/panko_serializer/attributes_writer/attributes_writer.h +7 -2
- data/ext/panko_serializer/attributes_writer/common.h +2 -1
- data/ext/panko_serializer/attributes_writer/hash.c +3 -2
- data/ext/panko_serializer/attributes_writer/hash.h +2 -4
- data/ext/panko_serializer/attributes_writer/plain.c +2 -1
- data/ext/panko_serializer/attributes_writer/plain.h +2 -4
- data/ext/panko_serializer/attributes_writer/type_cast/type_cast.c +9 -9
- data/ext/panko_serializer/attributes_writer/type_cast/type_cast.h +2 -3
- data/ext/panko_serializer/common.h +0 -2
- data/ext/panko_serializer/panko_serializer.c +6 -8
- data/ext/panko_serializer/serialization_descriptor/association.c +1 -0
- data/ext/panko_serializer/serialization_descriptor/association.h +1 -1
- data/ext/panko_serializer/serialization_descriptor/attribute.c +1 -0
- data/ext/panko_serializer/serialization_descriptor/attribute.h +2 -2
- data/ext/panko_serializer/serialization_descriptor/serialization_descriptor.c +1 -1
- data/ext/panko_serializer/serialization_descriptor/serialization_descriptor.h +1 -1
- data/lib/panko/attribute.rb +5 -5
- data/lib/panko/object_writer.rb +5 -1
- data/lib/panko/response.rb +3 -3
- data/lib/panko/serialization_descriptor.rb +2 -2
- data/lib/panko/serializer.rb +8 -2
- data/lib/panko/serializer_resolver.rb +7 -4
- data/lib/panko/version.rb +1 -1
- data/panko_serializer.gemspec +8 -8
- metadata +5 -3
@@ -1,36 +1,36 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require_relative "./support"
|
3
4
|
|
4
5
|
def panko_type_convert(type_klass, from, to)
|
5
6
|
converter = type_klass.new
|
6
|
-
assert
|
7
|
+
assert type_klass.name.to_s, Panko._type_cast(converter, from), to
|
7
8
|
|
8
9
|
Benchmark.run("#{type_klass.name}_TypeCast") do
|
9
|
-
Panko
|
10
|
+
Panko._type_cast(converter, from)
|
10
11
|
end
|
11
12
|
|
12
13
|
Benchmark.run("#{type_klass.name}_NoTypeCast") do
|
13
|
-
Panko
|
14
|
+
Panko._type_cast(converter, to)
|
14
15
|
end
|
15
16
|
end
|
16
17
|
|
17
|
-
|
18
18
|
def utc_panko_time
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
date = DateTime.new(2017, 3, 4, 12, 45, 23)
|
20
|
+
tz = ActiveSupport::TimeZone.new("UTC")
|
21
|
+
from = date.in_time_zone(tz).iso8601
|
22
22
|
|
23
23
|
type = ActiveRecord::ConnectionAdapters::PostgreSQL::OID::DateTime.new
|
24
24
|
converter = ActiveRecord::AttributeMethods::TimeZoneConversion::TimeZoneConverter.new(type)
|
25
25
|
|
26
|
-
to = Panko
|
26
|
+
to = Panko._type_cast(converter, from)
|
27
27
|
|
28
28
|
Benchmark.run("#{tz}_#{type.class.name}_TypeCast") do
|
29
|
-
Panko
|
29
|
+
Panko._type_cast(converter, from)
|
30
30
|
end
|
31
31
|
|
32
32
|
Benchmark.run("#{tz}_#{type.class.name}_NoTypeCast") do
|
33
|
-
Panko
|
33
|
+
Panko._type_cast(converter, to)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
@@ -41,7 +41,7 @@ def db_panko_time
|
|
41
41
|
from = "2017-07-10 09:26:40.937392"
|
42
42
|
|
43
43
|
Benchmark.run("Panko_Time_TypeCast") do
|
44
|
-
|
44
|
+
Panko._type_cast(converter, from)
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require "active_record"
|
3
4
|
require "active_record/connection_adapters/postgresql_adapter"
|
4
5
|
require "active_model"
|
@@ -6,7 +7,6 @@ require "active_support/all"
|
|
6
7
|
require "pg"
|
7
8
|
require "oj"
|
8
9
|
|
9
|
-
|
10
10
|
require_relative "../benchmarking_support"
|
11
11
|
require_relative "../../lib/panko/panko_serializer"
|
12
12
|
|
@@ -15,7 +15,11 @@ def assert(type_name, from, to)
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def check_if_exists(module_name)
|
18
|
-
mod =
|
18
|
+
mod = begin
|
19
|
+
module_name.constantize
|
20
|
+
rescue
|
21
|
+
nil
|
22
|
+
end
|
19
23
|
return true if mod
|
20
24
|
return false unless mod
|
21
25
|
end
|
data/docs/docs/introduction.md
CHANGED
@@ -8,6 +8,6 @@ Panko is library which is inspired by ActiveModelSerializers 0.9 for serializing
|
|
8
8
|
|
9
9
|
To achieve it's [performance](https://panko.dev/docs/performance.html):
|
10
10
|
|
11
|
-
* Oj - Panko relies Oj since it's fast and allow to
|
11
|
+
* Oj - Panko relies Oj since it's fast and allow to serialize incrementally using `Oj::StringWriter`
|
12
12
|
* Serialization Descriptor - Panko computes most of the metadata ahead of time, to save time later in serialization.
|
13
13
|
* Type casting — Panko does type casting by it's self, instead of relying ActiveRecord.
|
data/docs/docs/performance.md
CHANGED
@@ -8,15 +8,15 @@ The performance of Panko is measured using microbenchmarks and load testing.
|
|
8
8
|
|
9
9
|
## Microbenchmarks
|
10
10
|
|
11
|
-
The following microbenchmarks are run on MacBook Pro (
|
12
|
-
demonstrating the performance of ActiveModelSerializers 0.10.
|
11
|
+
The following microbenchmarks are run on MacBook Pro (16-inch, 2021, M1 Max), Ruby 3.1.1 with Rails 7.0.2.3
|
12
|
+
demonstrating the performance of ActiveModelSerializers 0.10.13 and Panko 0.7.6
|
13
13
|
|
14
14
|
| Benchmark | AMS ip/s | Panko ip/s |
|
15
15
|
| ----------------- | -------- | ---------- |
|
16
|
-
| Simple_Posts_2300 |
|
17
|
-
| Simple_Posts_50 |
|
18
|
-
| HasOne_Posts_2300 |
|
19
|
-
| HasOne_Posts_50 |
|
16
|
+
| Simple_Posts_2300 | 11.15 | 489.71 |
|
17
|
+
| Simple_Posts_50 | 517.85 | 21,366.93 |
|
18
|
+
| HasOne_Posts_2300 | 5.68 | 229.57 |
|
19
|
+
| HasOne_Posts_50 | 268.14 | 10,126.33 |
|
20
20
|
|
21
21
|
## Real-world benchmark
|
22
22
|
|