Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Rubyを30倍速くした話
Search
Tsukasa OISHI
February 21, 2018
Programming
1.3k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Rubyを30倍速くした話
Tsukasa OISHI
February 21, 2018
More Decks by Tsukasa OISHI
See All by Tsukasa OISHI
怖くないメモリ肥大化
tsukasa_oishi
1
120
SLI/SLO をストリーム アラインドチームに導入した話
tsukasa_oishi
0
220
JITをたどるとそこはYARVの中
tsukasa_oishi
0
590
The Cacher in the Rye
tsukasa_oishi
1
6k
ISeqで遊ぼう
tsukasa_oishi
0
5.3k
はてブ砲をくらったときのお話
tsukasa_oishi
0
2.3k
食べログで動いている自作ライブラリのお話
tsukasa_oishi
0
330
奥さんとプログラミングを両立させる方法
tsukasa_oishi
0
120
MiyazakiResistanceを作ってみたよ
tsukasa_oishi
0
1.1k
Other Decks in Programming
See All in Programming
Workers Cache を知る
syumai
0
310
IBM Bob Dojo #1 仕様駆動開発入門
oniak3ibm
PRO
0
320
Turning Architecture into Unit Tests in the AI Era (NSSpain XIV)
steliosf
PRO
1
120
iOSDC2026登壇資料.pdf
riofujimon
0
200
UPDATE をやめる — EF Core でマスタをバージョン管理する
panda728
PRO
0
1k
AWSに止められる覚悟してますか?
morizo_1984
2
490
モバイル交通系ICへのチャージ実例から考える、クロスプラットフォーム開発におけるiOS実機テスト設計とCI運用
yusuga
1
560
Ghostty + Neovimで作る 透明でカッコ良い開発環境
j341nono
0
140
選挙速報を多くのユーザーへ 届ける Live Activities 設計
hamayokokuririn
0
190
Everything will be SERVERLESS — 信じて運用した10年の経験値 / Everything Will be Serverless — Lessons Learned from 10 Years of Operational Experience
seike460
PRO
1
580
手動確認はもう限界 〜XCUITestでCustom URL Schemeの遷移を起動種別ごとに自動テストする〜 / Testing Custom URL Schemes with XCUITest
otouto
0
360
AGENTS.md Is Not Enough:Build Skills, Don't Download Them
lx_t
0
130
Featured
See All Featured
Mobile First: as difficult as doing things right
swwweet
225
10k
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
850
The Illustrated Children's Guide to Kubernetes
chrisshort
51
53k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
270
WCS-LA-2024
lcolladotor
0
840
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
730
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
69
66k
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
420
SEO for Brand Visibility & Recognition
aleyda
0
4.8k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
690
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
56k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3k
Transcript
3VCZΛഒ ͨ͘͠
͓͓͍͔ͭ͠͞ @tsukasaoishi (Github) https://www.kaeruspoon.net
ࠂ࡞ͬͯͶ ͋ɺҰिؒͰ
ཁ݅ ɾαΠτͷݕࡧը໘ʹग़͢ 17ߴ ɾҎʹө ɾ͘͠ͳ͍Ͱ
ࠂΛग़݅͢ ɾ݅ग़͢ ɾݕࡧ݅ʹϚονͨ͠ͷ ɾϚον͠ͳ͔ͬͨΒݕࡧ݅Λ ɹΏΔͯ͘͠·ͨ୳͢ ɾશવϚον͠ͳ͍߹࠷େͰ ɹճ୳͢͜ͱʹͳΔ
͍࣋ͬͯΔث ɾݕࡧΤϯδϯͳ͠ ɾ%#Ͱ4&-&$5
ࢼߦࡨޡͦͷ ;ͭ͏ʹຖճ4&-&$5
NTYճNT
NTYճNT
ࢼߦࡨޡͦͷ ͻͱͭͻͱͭͷ݅͝ͱʹ *%ͷू߹Λ࡞ͬͯ ੵू߹
QSFGT\UPLZP< >^ BSFBT\FCJTV< >^ HFOSFT\ZBLJOJLV< > DVSSZ<>^
౦ژɺܙൺणɺΧϨʔ͕ݕࡧ݅ͩͬͨ߹ QSFGT<UPLZP>BSFBT<FCJTV> QSFGT<UPLZP>BSFBT<FCJTV>HFOSFT<DVSSZ>
QSFGT\UPLZP< >^ BSFBT\FCJTV< >^ HFOSFT\ZBLJOJLV< > DVSSZ<>^
౦ژɺܙൺणɺΧϨʔ͕ݕࡧ݅ͩͬͨ߹ QSFGT<UPLZP>BSFBT<FCJTV> QSFGT<UPLZP>BSFBT<FCJTV>HFOSFT<DVSSZ> ͕݅݅ະຬʹͳͬͨ࣌ʹɺͻͱͭલͷू߹Λ͏
ສ݅ͷू߹ݸͷੵ
Benchmark.realtime do m & m & m & m &
m & m end
4FU
m = Set.new(1..1_000_000)
"SSBZ
m = (1..1_000_000).to_a
None
࠶ߟ ɾͷू߹͔͠ѻΘͳ͍ ɾੵू߹ͱϏοτԋࢉࣅ͍ͯΔ
BCDE B C D E
QSFGT\UPLZP< >^ BSFBT\FCJTV< >^ HFOSFT\ZBLJOJLV< > DVSSZ<>^
QSFGT\UPLZP^ BSFBT\FCJTV^ HFOSFT\ZBLJOJLV DVSSZ^
Ϗοτԋࢉίϯϐϡʔλಘҙ
ʙ ʙ
ʜ ेສθϩ͕ଓ͘ ʜ
ʜ ेສθϩ͕ଓ͘ ʜ ༿ϊʔυ;ͨͭͰදݱͰ͖Δ
ʙ ʙ
ʙ ʙ ༿ϊʔυ͕Ұக͠ͳ͍߹ Ϗοτԋࢉࣗମෆཁ
3VCZ$ݴޠͰॻ͔Ε͍ͯΔ
͓Ε3VCZΛΊΔͧ
typedef struct _leaf_node { unsigned long offset; unsigned long data;
} *leaf_node;
void Init_figure_set(void) { rb_cFigureSet = rb_define_class("FigureSet", rb_cObject); rb_define_alloc_func(rb_cFigureSet, t_allocate); rb_define_private_method(rb_cFigureSet,
"initialize", t_initialize, -1); rb_define_method(rb_cFigureSet, "initialize_copy", t_initialize_copy, 1); rb_define_method(rb_cFigureSet, "add", t_add, 1); rb_define_method(rb_cFigureSet, "delete", t_delete, 1); rb_define_method(rb_cFigureSet, "intersection", t_intersection, 1); ΠϯλʔϑΣʔε3VCZͩΑ
Benchmark.realtime do m & m & m & m &
m & m end
'JHVSF4FU
m = FigureSet.new((1..1_000_000).to_a)
None
require "figure_set" require "benchmark/ips" m3 = [] m5 = []
(1..1_000_000).each do |i| m3 << i if i % 3 == 0 m5 << i if i % 5 == 0 end s_m3 = Set.new(m3) s_m5 = Set.new(m5) f_m3 = FigureSet.new(m3) f_m5 = FigureSet.new(m5) Benchmark.ips do |x| x.report("arry") { m3 & m5 } x.report("set") { s_m3 & s_m5 } x.report("figure_set") { f_m3 & f_m5 } x.compare! end
figure_set: 1069.1 i/s arry: 31.1 i/s - 34.34x slower set:
13.6 i/s - 78.68x slower
͓͠·͍