Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Rubyを30倍速くした話
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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
210
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
320
奥さんとプログラミングを両立させる方法
tsukasa_oishi
0
110
MiyazakiResistanceを作ってみたよ
tsukasa_oishi
0
1.1k
Other Decks in Programming
See All in Programming
170k Jobs a Day on GKE: Scaling Mercari's CI Platform - and What's Next for AI-Native Development
junyaokabe
0
110
TSX の <Hoge<Fuga>> という構文に驚いた話 / tsx-type-argument-syntax
kanaru0928
0
230
yield再入門 #phpcon
o0h
PRO
0
1k
AWS DevOps AgentのAzure接続機能を検証して見えた活用法/Use Cases Verified for the AWS DevOps Agent's Azure Connectivity Feature
masakiokuda
1
230
Cloudflare is Agents
chimame
0
160
Detecting Compromised CI with eBPF and Cilium Tetragon
lizrice
0
180
言葉の格闘技のススメ~紙とペンと言葉から始める、キャリアの描き方~
progresscicada
2
140
Flow は今どうなっているか
mizdra
PRO
0
340
Claude CodeとAgentCore Gatewayを繋ぐ際の認証認可 / Authentication and authorization when connecting Claude Code with AgentCore Gateway
har1101
2
270
React本体のコードリーディング
high_g_engineer
1
140
数百円から始めるRuby電子工作
tarosay
0
150
仕様書を書く前にハーネスを作る - Agent Native開発は「探索を速く、判定を固く」
gotalab555
4
1.6k
Featured
See All Featured
Designing for Performance
lara
611
70k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
370
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
790
Context Engineering - Making Every Token Count
addyosmani
9
1k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
230
23k
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
160
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
640
Building an army of robots
kneath
306
46k
Six Lessons from altMBA
skipperchong
29
4.4k
The browser strikes back
jonoalderson
0
1.5k
Ruling the World: When Life Gets Gamed
codingconduct
0
300
Art, The Web, and Tiny UX
lynnandtonic
304
22k
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
͓͠·͍