Created
October 7, 2025 12:05
-
-
Save caius/59480c3913d900c725007baddf8fe404 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # frozen_string_literal: true | |
| require "bundler/inline" | |
| gemfile do | |
| gem "grape", "2.2.0" | |
| gem "grape-swagger", "2.1.2" | |
| gem "benchmark-ips" | |
| end | |
| require "grape" | |
| require "grape-swagger" | |
| require "benchmark/ips" | |
| Entity = Class.new | |
| Benchmark.ips do |bm| | |
| bm.report("options description") do | |
| Module.new do | |
| Class.new(Grape::API) do | |
| format :json | |
| namespace :foo do | |
| desc 'Description', detail: "something here", success: Entity | |
| get :description do | |
| end | |
| end | |
| add_swagger_documentation | |
| end | |
| end | |
| end | |
| bm.report("block description") do | |
| Module.new do | |
| Class.new(Grape::API) do | |
| format :json | |
| namespace :foo do | |
| desc 'Description'do | |
| detail "something here" | |
| success Entity | |
| end | |
| get :description do | |
| end | |
| end | |
| add_swagger_documentation | |
| end | |
| end | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ruby 3.4.6 (2025-09-16 revision dbd83256b1) +YJIT +PRISM [arm64-darwin24.6.0] | |
| Warming up -------------------------------------- | |
| options description 214.000 i/100ms | |
| block description 153.000 i/100ms | |
| Calculating ------------------------------------- | |
| options description 1.025k (±15.1%) i/s (975.54 μs/i) - 5.136k in 5.123947s | |
| block description 701.153 (± 9.7%) i/s (1.43 ms/i) - 3.519k in 5.069357s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment