Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Web Framework Benchmark Battle 2026, Any%

Web Framework Benchmark Battle 2026, Any%

Kaigi on Rails 2026 の発表「Web Framework Benchmark Battle 2026, Any%」の発表スライド https://kaigionrails.org/2026/talks/amatsuda/ #kaigionrails

Avatar for Akira Matsuda

Akira Matsuda

October 17, 2026

More Decks by Akira Matsuda

Other Decks in Programming

Transcript

  1. で、おもむろに以下のプロンプト "Now that you understand the concept and the workflow,

    can you try digging more and finding more room for similar optimizations?" 51 / 175
  2. 結果: アロケーション数 Endpoint | before | after | Change ---------------------------+----------+---------+-------/up

    | 400 | 271 | −32% Hello, World! | 322 | 250 | −22% scaffold index (20 rows) | 4611 | 2997 | −35% scaffold show | 593 | 512 | −14% scaffold new (form_with) | 1096 | 908 | −17% index.json (20 records) | 1479 | 1187 | −20% feed (collection partial) | 4195 | 3049 | −27% 58 / 175
  3. 結果: 実⾏時間 (µs) Endpoint | before | after | Change

    ---------------------------+----------+----------+-------/up | 93.8 | 79.4 | −15% Hello, World! | 82.2 | 74.3 | −10% scaffold index (20 rows) | 1231.6 | 1042.5 | −15% scaffold show | 177.4 | 168.2 | −5% scaffold new (form_with) | 310.8 | 269.6 | −13% index.json (20 records) | 318.1 | 298.0 | −6% feed (collection partial) | 939.7 | 807.4 | −14% 59 / 175
  4. 実例 + + + + + + def index_with(default =

    (no_default = true)) if block_given? to_h { |elem| [elem, yield(elem)] } # rubocop:disable Rails/IndexWith result = {} each { |elem| result[elem] = yield(elem) } result elsif no_default to_enum(:index_with) { size if respond_to?(:size) } else to_h { |elem| [elem, default] } # rubocop:disable Rails/IndexWith result = {} each { |elem| result[elem] = default } result end end 77 / 175
  5. 4. Active Record gem "activerecord", "8.1.4"; gem "activesupport", "8.1.4"; gem

    "sqlite3", "2.9.6" require "active_record" require "active_record/connection_adapters/sqlite3_adapter" ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:") ActiveRecord::Base.connection.execute(<<~SQL) CREATE TABLE users (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, age INTEGER) SQL class User < ActiveRecord::Base end User.create!(name: "alice", age: 30) User.create!(name: "bob", age: 25) User.create!(name: "carol", age: 35) puts User.count p User.where(name: "bob").pluck(:id, :name, :age) p User.where("age > ?", 26 u = User.find(1) puts "#{u.id} #{u.name} #{ p User.find_by(name: "nobody") 144 / 175
  6. Spinel on Rails ! 今のところは使い物になるかどうかは不明 ! Pinesってやつを使えば動くようになる未来が来る、かもしれない ! もしかしたらすっごい速い、かもしれない !

    コンパイルに異常に時間がかかる、かもしれない ! すっごい速いぱそこんを買ったら解決する、かもしれない 168 / 175