Skip to content
This repository was archived by the owner on Mar 24, 2026. It is now read-only.

Commit 0fbf61d

Browse files
authored
[ruby/padrino] Use postgres for the database (#10600)
For MySQL batch update isn't supported, so test it with PostgreSQL instead for better comparison.
1 parent a8782a1 commit 0fbf61d

6 files changed

Lines changed: 15 additions & 28 deletions

File tree

frameworks/Ruby/padrino/Gemfile

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
source 'https://rubygems.org'
22

3-
gem 'trilogy', '~> 2.9', platforms: [:ruby, :windows]
4-
3+
gem 'activerecord', '~> 8.1.0', require: 'active_record'
54
gem 'json'
6-
gem 'activerecord', '~> 8.1.0', :require => 'active_record'
7-
8-
gem 'slim'
9-
gem 'padrino', '0.16.0'
10-
gem 'rack'
115
gem 'ostruct' # required for Ruby 3.5
6+
gem 'padrino', '~> 0.16'
7+
gem 'pg'
8+
gem 'rack'
9+
gem 'slim'
1210

1311
group :iodine, optional: true do
1412
gem "iodine", "~> 0.7", require: false

frameworks/Ruby/padrino/Gemfile.lock

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ GEM
8888
mime-types (>= 3.1, < 4)
8989
padrino-core (= 0.16.0)
9090
padrino-support (0.16.0)
91+
pg (1.6.3)
92+
pg (1.6.3-x86_64-darwin)
93+
pg (1.6.3-x86_64-linux)
9194
rack (3.2.4)
9295
rack-protection (4.2.1)
9396
base64 (>= 0.1.0)
@@ -114,7 +117,6 @@ GEM
114117
thor (1.4.0)
115118
tilt (2.6.1)
116119
timeout (0.4.4)
117-
trilogy (2.9.0)
118120
tzinfo (2.0.6)
119121
concurrent-ruby (~> 1.0)
120122
uri (1.0.3)
@@ -129,10 +131,10 @@ DEPENDENCIES
129131
iodine (~> 0.7)
130132
json
131133
ostruct
132-
padrino (= 0.16.0)
134+
padrino (~> 0.16)
135+
pg
133136
rack
134137
slim
135-
trilogy (~> 2.9)
136138

137139
BUNDLED WITH
138140
2.7.0

frameworks/Ruby/padrino/app/controllers.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@
4545
world = World.find(id)
4646
new_value = rand1
4747
new_value = rand1 while new_value == world.randomNumber
48-
world.randomNumber = new_value
49-
world
48+
{ id: id, randomNumber: new_value }
5049
end
50+
worlds.sort_by!{_1[:id]}
5151
World.upsert_all(worlds)
5252
end
5353

frameworks/Ruby/padrino/benchmark_config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"port": 8080,
1212
"approach": "Realistic",
1313
"classification": "Micro",
14-
"database": "MySQL",
14+
"database": "Postgres",
1515
"framework": "padrino",
1616
"language": "Ruby",
1717
"orm": "Full",

frameworks/Ruby/padrino/config/database.rb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
Bundler.require('trilogy')
1+
Bundler.require('pg')
22
opts = {
3-
adapter: 'trilogy',
3+
adapter: 'postgresql',
44
username: 'benchmarkdbuser',
55
password: 'benchmarkdbpass',
66
host: 'tfb-database',
77
database: 'hello_world',
8-
ssl: true,
9-
ssl_mode: 4, # Trilogy::SSL_PREFERRED_NOVERIFY
10-
tls_min_version: 3 # Trilogy::TLS_VERSION_12
118
}
129

1310
# Determine threading/thread pool size and timeout

frameworks/Ruby/padrino/models/world.rb

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,4 @@ class World < ActiveRecord::Base
33

44
alias_attribute(:randomNumber, :randomnumber) \
55
if connection.adapter_name.downcase.start_with?('postgres')
6-
7-
if connection.adapter_name.downcase.start_with?('trilogy')
8-
def self.upsert_all(attributes, on_duplicate: :update, update_only: nil, returning: nil, unique_by: nil, record_timestamps: nil)
9-
# On MySQL Batch updates verification isn't supported yet by TechEmpower.
10-
# https://github.com/TechEmpower/FrameworkBenchmarks/issues/5983
11-
attributes.each do |attrs|
12-
where(id: attrs[:id]).update_all(randomNumber: attrs[:randomNumber])
13-
end
14-
end
15-
end
166
end

0 commit comments

Comments
 (0)