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.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/docs.yml +1 -1
  3. data/.github/workflows/lint.yml +41 -0
  4. data/.github/workflows/ruby.yml +35 -36
  5. data/.standard.yml +4 -0
  6. data/Gemfile +3 -2
  7. data/Rakefile +12 -16
  8. data/benchmarks/allocs.rb +1 -1
  9. data/benchmarks/app.rb +1 -1
  10. data/benchmarks/benchmarking_support.rb +3 -3
  11. data/benchmarks/bm_ams_0_10.rb +2 -5
  12. data/benchmarks/bm_object_writer.rb +1 -0
  13. data/benchmarks/bm_panko_json.rb +1 -1
  14. data/benchmarks/bm_panko_object.rb +1 -2
  15. data/benchmarks/bm_plain_object.rb +7 -7
  16. data/benchmarks/bm_serialization_descriptor.rb +5 -5
  17. data/benchmarks/bm_serializer_resolver.rb +1 -0
  18. data/benchmarks/bm_to_object.rb +2 -10
  19. data/benchmarks/profile.rb +5 -7
  20. data/benchmarks/sanity.rb +2 -10
  21. data/benchmarks/setup.rb +2 -2
  22. data/benchmarks/type_casts/bm_active_record.rb +6 -8
  23. data/benchmarks/type_casts/bm_panko.rb +11 -11
  24. data/benchmarks/type_casts/support.rb +6 -2
  25. data/docs/docs/introduction.md +1 -1
  26. data/docs/docs/performance.md +6 -6
  27. data/docs/package-lock.json +12556 -168
  28. data/ext/panko_serializer/attributes_writer/active_record.c +6 -6
  29. data/ext/panko_serializer/attributes_writer/active_record.h +1 -2
  30. data/ext/panko_serializer/attributes_writer/attributes_writer.c +5 -7
  31. data/ext/panko_serializer/attributes_writer/attributes_writer.h +7 -2
  32. data/ext/panko_serializer/attributes_writer/common.h +2 -1
  33. data/ext/panko_serializer/attributes_writer/hash.c +3 -2
  34. data/ext/panko_serializer/attributes_writer/hash.h +2 -4
  35. data/ext/panko_serializer/attributes_writer/plain.c +2 -1
  36. data/ext/panko_serializer/attributes_writer/plain.h +2 -4
  37. data/ext/panko_serializer/attributes_writer/type_cast/type_cast.c +9 -9
  38. data/ext/panko_serializer/attributes_writer/type_cast/type_cast.h +2 -3
  39. data/ext/panko_serializer/common.h +0 -2
  40. data/ext/panko_serializer/panko_serializer.c +6 -8
  41. data/ext/panko_serializer/serialization_descriptor/association.c +1 -0
  42. data/ext/panko_serializer/serialization_descriptor/association.h +1 -1
  43. data/ext/panko_serializer/serialization_descriptor/attribute.c +1 -0
  44. data/ext/panko_serializer/serialization_descriptor/attribute.h +2 -2
  45. data/ext/panko_serializer/serialization_descriptor/serialization_descriptor.c +1 -1
  46. data/ext/panko_serializer/serialization_descriptor/serialization_descriptor.h +1 -1
  47. data/lib/panko/attribute.rb +5 -5
  48. data/lib/panko/object_writer.rb +5 -1
  49. data/lib/panko/response.rb +3 -3
  50. data/lib/panko/serialization_descriptor.rb +2 -2
  51. data/lib/panko/serializer.rb +8 -2
  52. data/lib/panko/serializer_resolver.rb +7 -4
  53. data/lib/panko/version.rb +1 -1
  54. data/panko_serializer.gemspec +8 -8
  55. 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 "#{type_klass.name}", Panko::_type_cast(converter, from), to
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::_type_cast(converter, from)
10
+ Panko._type_cast(converter, from)
10
11
  end
11
12
 
12
13
  Benchmark.run("#{type_klass.name}_NoTypeCast") do
13
- Panko::_type_cast(converter, to)
14
+ Panko._type_cast(converter, to)
14
15
  end
15
16
  end
16
17
 
17
-
18
18
  def utc_panko_time
19
- date = DateTime.new(2017, 3, 4, 12, 45, 23)
20
- tz = ActiveSupport::TimeZone.new("UTC")
21
- from = date.in_time_zone(tz).iso8601
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::_type_cast(converter, from)
26
+ to = Panko._type_cast(converter, from)
27
27
 
28
28
  Benchmark.run("#{tz}_#{type.class.name}_TypeCast") do
29
- Panko::_type_cast(converter, from)
29
+ Panko._type_cast(converter, from)
30
30
  end
31
31
 
32
32
  Benchmark.run("#{tz}_#{type.class.name}_NoTypeCast") do
33
- Panko::_type_cast(converter, to)
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
- Panko::_type_cast(converter, from)
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 = (module_name.constantize rescue nil)
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
@@ -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 to serialize incrementally using `Oj::StringWriter`
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.
@@ -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 (15-inch, 2018), Ruby 2.6.3 with Rails 6.0.2.1
12
- demonstrating the performance of ActiveModelSerializers 0.10.10 and Panko 0.7.2
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 | 5.4 | 190.48 |
17
- | Simple_Posts_50 | 261.28 | 9,347.4 |
18
- | HasOne_Posts_2300 | 2.54 | 90.71 |
19
- | HasOne_Posts_50 | 124.29 | 5,421.55 |
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