Skip to content

Commit

Permalink
[ruby/sinatra] Don't use JSON.fast_generate
Browse files Browse the repository at this point in the history
It's not faster for small payloads.

+--------------------+------+-----+-----+-------+--------------+
|         branch_name|update|   db|query|fortune|weighted_score|
+--------------------+------+-----+-----+-------+--------------+
|              master|  8301|36433|15826|  28025|          1089|
|remove-fast-generate|  8897|38895|16317|  27660|          1143|
+--------------------+------+-----+-----+-------+--------------+
  • Loading branch information
p8 committed Jan 12, 2025
1 parent ce36b84 commit 05d575f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion frameworks/Ruby/sinatra-sequel/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ GEM
base64 (0.2.0)
bigdecimal (3.1.8)
iodine (0.7.58)
json (2.8.2)
json (2.9.1)
kgio (2.11.4)
mustermann (3.0.3)
ruby2_keywords (~> 0.0.1)
Expand Down
2 changes: 1 addition & 1 deletion frameworks/Ruby/sinatra-sequel/hello_world.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def bounded_queries

def json(data)
content_type :json
JSON.fast_generate(data)
data.to_json
end

# Return a random number between 1 and MAX_PK
Expand Down
2 changes: 1 addition & 1 deletion frameworks/Ruby/sinatra/hello_world.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def bounded_queries

def json(data)
content_type :json
JSON.fast_generate(data)
data.to_json
end

# Return a random number between 1 and MAX_PK
Expand Down

0 comments on commit 05d575f

Please sign in to comment.