toon-format 0.1.0 → 0.1.2
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/benchmark/format_comparison_benchmark.rb +2 -4
- data/benchmark/memory_benchmark.rb +12 -12
- data/benchmark/nesting_benchmark.rb +11 -11
- data/benchmark/real_world_benchmark.rb +6 -6
- data/benchmark/round_trip_benchmark.rb +16 -16
- data/benchmark/run_all_benchmarks.rb +6 -7
- data/benchmark/scalability_benchmark.rb +2 -2
- data/benchmark/validation_benchmark.rb +11 -11
- data/lib/toon-format.rb +3 -0
- data/lib/toon_format/rails/extensions.rb +2 -2
- data/lib/toon_format/railtie.rb +2 -1
- data/lib/toon_format/version.rb +1 -1
- metadata +10 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e8462cf37df242a5570b54f39721592270bccba7ffefe3595a78aa4b92ab6c17
|
|
4
|
+
data.tar.gz: bab9f5a6d5a8906e9e2097d9cec3fd8cb3dfda9d6562b8adfe0d716960ba9596
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fde267242e762d78ce902907084a4dab67ac97dede3f90385907f7198010512e53dda875fbb158f6bdfc8afb14247649f545444b3bd5aa8de14b9a4edab7a936
|
|
7
|
+
data.tar.gz: a50e51a0e6da21dd211383d49c72ded1f0c5a561c08a00fad9e0c4dce1daf7477804e9bad7be68cf4002b623781b5fb1559b2341dd389efcc4a80f93dd3366e3
|
|
@@ -19,7 +19,7 @@ end
|
|
|
19
19
|
|
|
20
20
|
puts "=" * 80
|
|
21
21
|
puts "Format Comparison Benchmark"
|
|
22
|
-
puts "Comparing TOON with JSON, YAML#{
|
|
22
|
+
puts "Comparing TOON with JSON, YAML#{", and MessagePack" if MSGPACK_AVAILABLE}"
|
|
23
23
|
puts "=" * 80
|
|
24
24
|
puts
|
|
25
25
|
|
|
@@ -155,7 +155,5 @@ puts "When to use each format:"
|
|
|
155
155
|
puts " • JSON: Universal compatibility, well-established"
|
|
156
156
|
puts " • YAML: Configuration files, human editing priority"
|
|
157
157
|
puts " • TOON: LLM contexts, API responses, token optimization"
|
|
158
|
-
if MSGPACK_AVAILABLE
|
|
159
|
-
puts " • MessagePack: Maximum compression, binary protocols"
|
|
160
|
-
end
|
|
158
|
+
puts " • MessagePack: Maximum compression, binary protocols" if MSGPACK_AVAILABLE
|
|
161
159
|
puts "=" * 80
|
|
@@ -24,18 +24,18 @@ puts
|
|
|
24
24
|
|
|
25
25
|
# Test data sets with varying sizes
|
|
26
26
|
data_sets = {
|
|
27
|
-
"Small (10 records)" => Array.new(10)
|
|
27
|
+
"Small (10 records)" => Array.new(10) do |i|
|
|
28
28
|
{ id: i, name: "User#{i}", email: "user#{i}@example.com", active: i.even? }
|
|
29
|
-
|
|
30
|
-
"Medium (100 records)" => Array.new(100)
|
|
29
|
+
end,
|
|
30
|
+
"Medium (100 records)" => Array.new(100) do |i|
|
|
31
31
|
{ id: i, name: "User#{i}", email: "user#{i}@example.com", active: i.even? }
|
|
32
|
-
|
|
33
|
-
"Large (1,000 records)" => Array.new(1000)
|
|
32
|
+
end,
|
|
33
|
+
"Large (1,000 records)" => Array.new(1000) do |i|
|
|
34
34
|
{ id: i, name: "User#{i}", email: "user#{i}@example.com", active: i.even? }
|
|
35
|
-
|
|
36
|
-
"Very Large (10,000 records)" => Array.new(10_000)
|
|
35
|
+
end,
|
|
36
|
+
"Very Large (10,000 records)" => Array.new(10_000) do |i|
|
|
37
37
|
{ id: i, name: "User#{i}", email: "user#{i}@example.com", active: i.even? }
|
|
38
|
-
|
|
38
|
+
end
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
data_sets.each do |name, data|
|
|
@@ -56,9 +56,9 @@ data_sets.each do |name, data|
|
|
|
56
56
|
puts "TOON encoding (1000 iterations): #{toon_memory} KB"
|
|
57
57
|
|
|
58
58
|
diff = json_memory - toon_memory
|
|
59
|
-
if diff
|
|
59
|
+
if diff.positive?
|
|
60
60
|
puts "Memory saved: #{diff} KB (#{((diff / json_memory.to_f) * 100).round(1)}%)"
|
|
61
|
-
elsif diff
|
|
61
|
+
elsif diff.negative?
|
|
62
62
|
puts "Memory overhead: #{diff.abs} KB (#{((diff.abs / json_memory.to_f) * 100).round(1)}%)"
|
|
63
63
|
else
|
|
64
64
|
puts "Memory usage: equivalent"
|
|
@@ -81,9 +81,9 @@ data_sets.each do |name, data|
|
|
|
81
81
|
puts "TOON decoding (1000 iterations): #{toon_decode_memory} KB"
|
|
82
82
|
|
|
83
83
|
diff = json_decode_memory - toon_decode_memory
|
|
84
|
-
if diff
|
|
84
|
+
if diff.positive?
|
|
85
85
|
puts "Memory saved: #{diff} KB (#{((diff / json_decode_memory.to_f) * 100).round(1)}%)"
|
|
86
|
-
elsif diff
|
|
86
|
+
elsif diff.negative?
|
|
87
87
|
puts "Memory overhead: #{diff.abs} KB (#{((diff.abs / json_decode_memory.to_f) * 100).round(1)}%)"
|
|
88
88
|
else
|
|
89
89
|
puts "Memory usage: equivalent"
|
|
@@ -57,7 +57,7 @@ depths.each do |depth|
|
|
|
57
57
|
puts "Nesting Depth: #{depth}"
|
|
58
58
|
puts "-" * 80
|
|
59
59
|
puts "JSON size: #{json_str.bytesize} bytes"
|
|
60
|
-
puts "TOON size: #{toon_str.bytesize} bytes (#{((1 - toon_str.bytesize.to_f / json_str.bytesize) * 100).round(1)}% difference)"
|
|
60
|
+
puts "TOON size: #{toon_str.bytesize} bytes (#{((1 - (toon_str.bytesize.to_f / json_str.bytesize)) * 100).round(1)}% difference)"
|
|
61
61
|
puts
|
|
62
62
|
|
|
63
63
|
Benchmark.ips do |x|
|
|
@@ -118,9 +118,9 @@ puts "=" * 80
|
|
|
118
118
|
puts
|
|
119
119
|
|
|
120
120
|
wide_structure = {
|
|
121
|
-
data: Array.new(100)
|
|
121
|
+
data: Array.new(100) do |i|
|
|
122
122
|
{ id: i, name: "Item#{i}", value: rand(100) }
|
|
123
|
-
|
|
123
|
+
end
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
deep_structure = create_nested_object(15)
|
|
@@ -130,7 +130,7 @@ puts "-" * 80
|
|
|
130
130
|
json_wide = JSON.generate(wide_structure)
|
|
131
131
|
toon_wide = ToonFormat.encode(wide_structure)
|
|
132
132
|
puts "JSON: #{json_wide.bytesize} bytes"
|
|
133
|
-
puts "TOON: #{toon_wide.bytesize} bytes (#{((1 - toon_wide.bytesize.to_f / json_wide.bytesize) * 100).round(1)}% difference)"
|
|
133
|
+
puts "TOON: #{toon_wide.bytesize} bytes (#{((1 - (toon_wide.bytesize.to_f / json_wide.bytesize)) * 100).round(1)}% difference)"
|
|
134
134
|
puts
|
|
135
135
|
|
|
136
136
|
Benchmark.ips do |x|
|
|
@@ -166,21 +166,21 @@ puts "=" * 80
|
|
|
166
166
|
puts
|
|
167
167
|
|
|
168
168
|
complex_data = {
|
|
169
|
-
users: Array.new(20)
|
|
169
|
+
users: Array.new(20) do |i|
|
|
170
170
|
{
|
|
171
171
|
id: i,
|
|
172
172
|
name: "User#{i}",
|
|
173
|
-
posts: Array.new(5)
|
|
173
|
+
posts: Array.new(5) do |j|
|
|
174
174
|
{
|
|
175
175
|
id: j,
|
|
176
176
|
title: "Post #{j}",
|
|
177
|
-
comments: Array.new(3)
|
|
177
|
+
comments: Array.new(3) do |k|
|
|
178
178
|
{ id: k, text: "Comment #{k}", likes: rand(10) }
|
|
179
|
-
|
|
179
|
+
end
|
|
180
180
|
}
|
|
181
|
-
|
|
181
|
+
end
|
|
182
182
|
}
|
|
183
|
-
|
|
183
|
+
end
|
|
184
184
|
}
|
|
185
185
|
|
|
186
186
|
json_complex = JSON.generate(complex_data)
|
|
@@ -190,7 +190,7 @@ puts "20 users × 5 posts × 3 comments = 300 total items"
|
|
|
190
190
|
puts "-" * 80
|
|
191
191
|
puts "JSON size: #{json_complex.bytesize} bytes"
|
|
192
192
|
puts "TOON size: #{toon_complex.bytesize} bytes"
|
|
193
|
-
puts "Savings: #{((1 - toon_complex.bytesize.to_f / json_complex.bytesize) * 100).round(1)}%"
|
|
193
|
+
puts "Savings: #{((1 - (toon_complex.bytesize.to_f / json_complex.bytesize)) * 100).round(1)}%"
|
|
194
194
|
puts
|
|
195
195
|
|
|
196
196
|
Benchmark.ips do |x|
|
|
@@ -38,7 +38,7 @@ toon_response = ToonFormat.encode(api_users)
|
|
|
38
38
|
puts "Response sizes:"
|
|
39
39
|
puts " JSON: #{json_response.bytesize} bytes (~#{(json_response.bytesize / 4.0).ceil} tokens)"
|
|
40
40
|
puts " TOON: #{toon_response.bytesize} bytes (~#{(toon_response.bytesize / 4.0).ceil} tokens)"
|
|
41
|
-
puts " Savings: #{((1 - toon_response.bytesize.to_f / json_response.bytesize) * 100).round(1)}%"
|
|
41
|
+
puts " Savings: #{((1 - (toon_response.bytesize.to_f / json_response.bytesize)) * 100).round(1)}%"
|
|
42
42
|
puts
|
|
43
43
|
|
|
44
44
|
Benchmark.ips do |x|
|
|
@@ -57,7 +57,7 @@ puts
|
|
|
57
57
|
|
|
58
58
|
products = Array.new(200) do |i|
|
|
59
59
|
{
|
|
60
|
-
sku: "PROD#{i.to_s.rjust(5,
|
|
60
|
+
sku: "PROD#{i.to_s.rjust(5, "0")}",
|
|
61
61
|
name: "Product #{i}",
|
|
62
62
|
category: %w[Electronics Clothing Books Home].sample,
|
|
63
63
|
price: (rand(10..1000) * 100) / 100.0,
|
|
@@ -74,7 +74,7 @@ toon_export = ToonFormat.encode(products)
|
|
|
74
74
|
puts "Export sizes:"
|
|
75
75
|
puts " JSON: #{json_export.bytesize} bytes"
|
|
76
76
|
puts " TOON: #{toon_export.bytesize} bytes"
|
|
77
|
-
puts " Savings: #{((1 - toon_export.bytesize.to_f / json_export.bytesize) * 100).round(1)}%"
|
|
77
|
+
puts " Savings: #{((1 - (toon_export.bytesize.to_f / json_export.bytesize)) * 100).round(1)}%"
|
|
78
78
|
puts
|
|
79
79
|
|
|
80
80
|
Benchmark.ips do |x|
|
|
@@ -96,7 +96,7 @@ chat_history = Array.new(20) do |i|
|
|
|
96
96
|
id: i + 1,
|
|
97
97
|
role: i.even? ? "user" : "assistant",
|
|
98
98
|
content: "This is message number #{i + 1} in the conversation. " * 3,
|
|
99
|
-
timestamp: "2025-01-26T#{(10 + i).to_s.rjust(2,
|
|
99
|
+
timestamp: "2025-01-26T#{(10 + i).to_s.rjust(2, "0")}:30:00Z",
|
|
100
100
|
tokens: rand(50..200)
|
|
101
101
|
}
|
|
102
102
|
end
|
|
@@ -145,7 +145,7 @@ toon_events = ToonFormat.encode(analytics_events)
|
|
|
145
145
|
puts "Event log sizes:"
|
|
146
146
|
puts " JSON: #{json_events.bytesize} bytes"
|
|
147
147
|
puts " TOON: #{toon_events.bytesize} bytes"
|
|
148
|
-
puts " Savings: #{((1 - toon_events.bytesize.to_f / json_events.bytesize) * 100).round(1)}%"
|
|
148
|
+
puts " Savings: #{((1 - (toon_events.bytesize.to_f / json_events.bytesize)) * 100).round(1)}%"
|
|
149
149
|
puts " Bandwidth saved per 1000 requests: #{((json_events.bytesize - toon_events.bytesize) * 1000 / 1024.0).round(2)} KB"
|
|
150
150
|
puts
|
|
151
151
|
|
|
@@ -201,7 +201,7 @@ toon_config = ToonFormat.encode(config)
|
|
|
201
201
|
puts "Config sizes:"
|
|
202
202
|
puts " JSON (pretty): #{json_config.bytesize} bytes"
|
|
203
203
|
puts " TOON: #{toon_config.bytesize} bytes"
|
|
204
|
-
puts " Savings: #{((1 - toon_config.bytesize.to_f / json_config.bytesize) * 100).round(1)}%"
|
|
204
|
+
puts " Savings: #{((1 - (toon_config.bytesize.to_f / json_config.bytesize)) * 100).round(1)}%"
|
|
205
205
|
puts
|
|
206
206
|
|
|
207
207
|
Benchmark.ips do |x|
|
|
@@ -21,29 +21,29 @@ datasets = {
|
|
|
21
21
|
active: true
|
|
22
22
|
},
|
|
23
23
|
|
|
24
|
-
"Small Array (10 records)" => Array.new(10)
|
|
24
|
+
"Small Array (10 records)" => Array.new(10) do |i|
|
|
25
25
|
{ id: i, name: "User#{i}", email: "user#{i}@example.com" }
|
|
26
|
-
|
|
26
|
+
end,
|
|
27
27
|
|
|
28
|
-
"Medium Array (100 records)" => Array.new(100)
|
|
28
|
+
"Medium Array (100 records)" => Array.new(100) do |i|
|
|
29
29
|
{ id: i, name: "User#{i}", email: "user#{i}@example.com", score: rand(100) }
|
|
30
|
-
|
|
30
|
+
end,
|
|
31
31
|
|
|
32
|
-
"Large Array (1000 records)" => Array.new(1000)
|
|
32
|
+
"Large Array (1000 records)" => Array.new(1000) do |i|
|
|
33
33
|
{ id: i, name: "User#{i}", score: rand(100) }
|
|
34
|
-
|
|
34
|
+
end,
|
|
35
35
|
|
|
36
36
|
"Complex Nested" => {
|
|
37
|
-
users: Array.new(20)
|
|
37
|
+
users: Array.new(20) do |i|
|
|
38
38
|
{
|
|
39
39
|
id: i,
|
|
40
40
|
name: "User#{i}",
|
|
41
41
|
profile: {
|
|
42
42
|
age: 20 + i,
|
|
43
|
-
tags: [
|
|
43
|
+
tags: %w[tag1 tag2]
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
|
|
46
|
+
end,
|
|
47
47
|
metadata: { total: 20, page: 1 }
|
|
48
48
|
}
|
|
49
49
|
}
|
|
@@ -94,7 +94,7 @@ test_cases = [
|
|
|
94
94
|
score: 95.5,
|
|
95
95
|
active: true,
|
|
96
96
|
metadata: nil,
|
|
97
|
-
tags: [
|
|
97
|
+
tags: %w[a b],
|
|
98
98
|
nested: { key: "value" }
|
|
99
99
|
}]
|
|
100
100
|
]
|
|
@@ -102,7 +102,7 @@ test_cases = [
|
|
|
102
102
|
test_cases.each do |name, data|
|
|
103
103
|
# JSON round-trip
|
|
104
104
|
json_encoded = JSON.generate(data)
|
|
105
|
-
|
|
105
|
+
JSON.parse(json_encoded, symbolize_names: true)
|
|
106
106
|
|
|
107
107
|
# TOON round-trip
|
|
108
108
|
toon_encoded = ToonFormat.encode(data)
|
|
@@ -126,16 +126,16 @@ puts
|
|
|
126
126
|
|
|
127
127
|
# Test data for multiple round-trips
|
|
128
128
|
test_data = {
|
|
129
|
-
users: Array.new(50)
|
|
129
|
+
users: Array.new(50) do |i|
|
|
130
130
|
{ id: i, name: "User#{i}", score: rand(100), active: i.even? }
|
|
131
|
-
|
|
131
|
+
end
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
puts "Testing 10 consecutive round-trips..."
|
|
135
135
|
puts "-" * 80
|
|
136
136
|
|
|
137
137
|
current = test_data
|
|
138
|
-
10.times do |
|
|
138
|
+
10.times do |_i|
|
|
139
139
|
encoded = ToonFormat.encode(current)
|
|
140
140
|
current = ToonFormat.decode(encoded)
|
|
141
141
|
end
|
|
@@ -154,9 +154,9 @@ puts "PERFORMANCE: Multiple Encode-Decode Cycles"
|
|
|
154
154
|
puts "=" * 80
|
|
155
155
|
puts
|
|
156
156
|
|
|
157
|
-
data = Array.new(100)
|
|
157
|
+
data = Array.new(100) do |i|
|
|
158
158
|
{ id: i, name: "User#{i}", email: "user#{i}@example.com" }
|
|
159
|
-
|
|
159
|
+
end
|
|
160
160
|
|
|
161
161
|
puts "100 records, 5 round-trips each iteration:"
|
|
162
162
|
puts "-" * 80
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
|
+
require "English"
|
|
4
5
|
require "fileutils"
|
|
5
6
|
require "time"
|
|
6
7
|
|
|
@@ -58,7 +59,7 @@ benchmarks.each_with_index do |(file, description), index|
|
|
|
58
59
|
begin
|
|
59
60
|
# Run the benchmark
|
|
60
61
|
system("ruby #{benchmark_path}")
|
|
61
|
-
status =
|
|
62
|
+
status = $CHILD_STATUS.success? ? "✓ SUCCESS" : "✗ FAILED"
|
|
62
63
|
elapsed = Time.now - start_time
|
|
63
64
|
|
|
64
65
|
results << {
|
|
@@ -97,7 +98,7 @@ failed = results.count { |r| r[:status] != "✓ SUCCESS" }
|
|
|
97
98
|
|
|
98
99
|
summary = []
|
|
99
100
|
summary << "TOON Format Benchmark Suite Results"
|
|
100
|
-
summary << "=" * 80
|
|
101
|
+
summary << ("=" * 80)
|
|
101
102
|
summary << "Run Date: #{Time.now}"
|
|
102
103
|
summary << "Total Time: #{total_time.round(2)}s"
|
|
103
104
|
summary << "Total Benchmarks: #{results.size}"
|
|
@@ -105,7 +106,7 @@ summary << "Successful: #{successful}"
|
|
|
105
106
|
summary << "Failed: #{failed}"
|
|
106
107
|
summary << ""
|
|
107
108
|
summary << "Individual Results:"
|
|
108
|
-
summary << "-" * 80
|
|
109
|
+
summary << ("-" * 80)
|
|
109
110
|
|
|
110
111
|
results.each_with_index do |result, index|
|
|
111
112
|
line = "#{index + 1}. #{result[:description]}"
|
|
@@ -113,13 +114,11 @@ results.each_with_index do |result, index|
|
|
|
113
114
|
line += "#{result[:status]} (#{result[:elapsed].round(2)}s)"
|
|
114
115
|
summary << line
|
|
115
116
|
|
|
116
|
-
if result[:error]
|
|
117
|
-
summary << " Error: #{result[:error]}"
|
|
118
|
-
end
|
|
117
|
+
summary << " Error: #{result[:error]}" if result[:error]
|
|
119
118
|
end
|
|
120
119
|
|
|
121
120
|
summary << ""
|
|
122
|
-
summary << "=" * 80
|
|
121
|
+
summary << ("=" * 80)
|
|
123
122
|
|
|
124
123
|
# Print summary
|
|
125
124
|
summary.each { |line| puts line }
|
|
@@ -64,7 +64,7 @@ sizes.each do |size|
|
|
|
64
64
|
|
|
65
65
|
puts "\nDataset: #{size} records"
|
|
66
66
|
puts " JSON size: #{json_str.bytesize} bytes"
|
|
67
|
-
puts " TOON size: #{toon_str.bytesize} bytes (#{((1 - toon_str.bytesize.to_f / json_str.bytesize) * 100).round(1)}% smaller)"
|
|
67
|
+
puts " TOON size: #{toon_str.bytesize} bytes (#{((1 - (toon_str.bytesize.to_f / json_str.bytesize)) * 100).round(1)}% smaller)"
|
|
68
68
|
puts "-" * 80
|
|
69
69
|
|
|
70
70
|
Benchmark.ips do |x|
|
|
@@ -103,7 +103,7 @@ results = {}
|
|
|
103
103
|
|
|
104
104
|
json_str = JSON.generate(data)
|
|
105
105
|
toon_str = ToonFormat.encode(data)
|
|
106
|
-
size_reduction = ((1 - toon_str.bytesize.to_f / json_str.bytesize) * 100).round(1)
|
|
106
|
+
size_reduction = ((1 - (toon_str.bytesize.to_f / json_str.bytesize)) * 100).round(1)
|
|
107
107
|
|
|
108
108
|
results[size] = {
|
|
109
109
|
speedup: speedup,
|
|
@@ -14,27 +14,27 @@ puts
|
|
|
14
14
|
|
|
15
15
|
# Test datasets
|
|
16
16
|
datasets = {
|
|
17
|
-
"Small (10 records)" => Array.new(10)
|
|
17
|
+
"Small (10 records)" => Array.new(10) do |i|
|
|
18
18
|
{ id: i, name: "User#{i}", email: "user#{i}@example.com", active: i.even? }
|
|
19
|
-
|
|
19
|
+
end,
|
|
20
20
|
|
|
21
|
-
"Medium (100 records)" => Array.new(100)
|
|
21
|
+
"Medium (100 records)" => Array.new(100) do |i|
|
|
22
22
|
{ id: i, name: "User#{i}", email: "user#{i}@example.com", active: i.even? }
|
|
23
|
-
|
|
23
|
+
end,
|
|
24
24
|
|
|
25
|
-
"Large (1000 records)" => Array.new(1000)
|
|
25
|
+
"Large (1000 records)" => Array.new(1000) do |i|
|
|
26
26
|
{ id: i, name: "User#{i}", email: "user#{i}@example.com", active: i.even? }
|
|
27
|
-
|
|
27
|
+
end,
|
|
28
28
|
|
|
29
29
|
"Nested Structure" => {
|
|
30
|
-
users: Array.new(50)
|
|
30
|
+
users: Array.new(50) do |i|
|
|
31
31
|
{
|
|
32
32
|
id: i,
|
|
33
33
|
name: "User#{i}",
|
|
34
34
|
age: 20 + i,
|
|
35
35
|
city: "City#{i % 10}"
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
end,
|
|
38
38
|
metadata: {
|
|
39
39
|
total: 50,
|
|
40
40
|
page: 1,
|
|
@@ -70,7 +70,7 @@ datasets.each do |name, data|
|
|
|
70
70
|
end
|
|
71
71
|
|
|
72
72
|
# Test validation overhead with different complexities
|
|
73
|
-
puts "\n"
|
|
73
|
+
puts "\n#{"=" * 80}"
|
|
74
74
|
puts "Validation Overhead Analysis"
|
|
75
75
|
puts "=" * 80
|
|
76
76
|
puts
|
|
@@ -83,9 +83,9 @@ puts "Dataset Size | Strict (ms) | Lenient (ms) | Overhead (%)"
|
|
|
83
83
|
puts "-" * 80
|
|
84
84
|
|
|
85
85
|
test_sizes.each do |size|
|
|
86
|
-
data = Array.new(size)
|
|
86
|
+
data = Array.new(size) do |i|
|
|
87
87
|
{ id: i, name: "User#{i}", email: "user#{i}@example.com", score: rand(100) }
|
|
88
|
-
|
|
88
|
+
end
|
|
89
89
|
|
|
90
90
|
toon_str = ToonFormat.encode(data)
|
|
91
91
|
|
data/lib/toon-format.rb
ADDED
data/lib/toon_format/railtie.rb
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
if defined?(Rails)
|
|
4
|
+
require "rails/railtie"
|
|
4
5
|
require "toon_format/rails/extensions"
|
|
5
6
|
|
|
6
7
|
module ToonFormat
|
|
7
|
-
class Railtie < Rails::Railtie
|
|
8
|
+
class Railtie < ::Rails::Railtie
|
|
8
9
|
initializer "toon_format.active_record" do
|
|
9
10
|
ActiveSupport.on_load(:active_record) do
|
|
10
11
|
include ToonFormat::Rails::Extensions
|
data/lib/toon_format/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: toon-format
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Osman Okuyan
|
|
8
|
+
autorequire:
|
|
8
9
|
bindir: exe
|
|
9
10
|
cert_chain: []
|
|
10
|
-
date:
|
|
11
|
+
date: 2025-11-27 00:00:00.000000000 Z
|
|
11
12
|
dependencies: []
|
|
12
13
|
description: Compact serialization format optimized for LLM contexts with 30-60% token
|
|
13
14
|
reduction compared to JSON
|
|
@@ -39,6 +40,7 @@ files:
|
|
|
39
40
|
- benchmark/token_reduction_benchmark.rb
|
|
40
41
|
- benchmark/validation_benchmark.rb
|
|
41
42
|
- exe/toon-format
|
|
43
|
+
- lib/toon-format.rb
|
|
42
44
|
- lib/toon_format.rb
|
|
43
45
|
- lib/toon_format/decoder.rb
|
|
44
46
|
- lib/toon_format/encoder.rb
|
|
@@ -54,8 +56,9 @@ licenses:
|
|
|
54
56
|
- MIT
|
|
55
57
|
metadata:
|
|
56
58
|
homepage_uri: https://github.com/osmanok/toon-format
|
|
57
|
-
source_code_uri: https://github.com/
|
|
58
|
-
changelog_uri: https://github.com/
|
|
59
|
+
source_code_uri: https://github.com/osmanok/toon-format
|
|
60
|
+
changelog_uri: https://github.com/osmanok/toon-format/blob/main/CHANGELOG.md
|
|
61
|
+
post_install_message:
|
|
59
62
|
rdoc_options: []
|
|
60
63
|
require_paths:
|
|
61
64
|
- lib
|
|
@@ -63,14 +66,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
63
66
|
requirements:
|
|
64
67
|
- - ">="
|
|
65
68
|
- !ruby/object:Gem::Version
|
|
66
|
-
version: 3.
|
|
69
|
+
version: 3.2.0
|
|
67
70
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
68
71
|
requirements:
|
|
69
72
|
- - ">="
|
|
70
73
|
- !ruby/object:Gem::Version
|
|
71
74
|
version: '0'
|
|
72
75
|
requirements: []
|
|
73
|
-
rubygems_version: 3.
|
|
76
|
+
rubygems_version: 3.4.19
|
|
77
|
+
signing_key:
|
|
74
78
|
specification_version: 4
|
|
75
79
|
summary: TOON format serialization for Ruby
|
|
76
80
|
test_files: []
|