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
Angularは本当に速いのか?
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
ponday
June 25, 2017
Programming
760
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Angularは本当に速いのか?
ng-fukuoka Angular Meetup #1の登壇資料です。
ponday
June 25, 2017
More Decks by ponday
See All by ponday
関数型でGoFのデザインパターンやってみる
honda
1
1.7k
TypeScriptの型表現
honda
10
3.1k
Web Componentsの今
honda
1
480
これまでのReact、これからのReact
honda
0
340
Gatsbyお試し
honda
0
140
styled-components or emotion?
honda
0
730
Web ComponentsとAngular
honda
0
160
Atomic Design周りについての私見
honda
1
810
え、まだWeb Componentsを未来の技術だと思ってるの?
honda
2
890
Other Decks in Programming
See All in Programming
ドリフトを絶対に許さない(?)CDK運用 / CDK Ops with Zero Tolerance for Drifts (?)
akihisaikeda
1
220
初めての模倣学習とVLA
natsutan
0
210
引き算の組織 ― アウトカムとAIに全振りするために辞めたこと ― / Organization by Subtraction
hirokiyamamoto14
PRO
0
290
人間の目はかわらない、だからJPEGは30年もつ
yuzneri
12
19k
DynamoDBの基礎を振り返りながらベクトル検索機能を理解する
musan
2
110
Cloudflare is Agents
chimame
0
180
プロポーザルを書いてもらう
pvcresin
0
580
承認済みなのに差戻しできてしまうバグ、型で潰せます
shinchit
0
100
KotlinConf Extended South Korea 2026 Keynote
l2hyunwoo
0
120
AWS Transform Customによる Spring Boot 2.xから4.xへのVerUp
satoshi256kbyte
2
100
170k Jobs a Day on GKE: Scaling Mercari's CI Platform - and What's Next for AI-Native Development
junyaokabe
0
120
S3 を使うアプリケーションをローカル完結で動かすことに全力を注いでみた / Running S3 Apps Offline
contour_gara
0
580
Featured
See All Featured
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.3k
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
420
Leo the Paperboy
mayatellez
8
2.2k
Typedesign – Prime Four
hannesfritz
42
3.1k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
480
Building Adaptive Systems
keathley
44
3.2k
A Tale of Four Properties
chriscoyier
163
24k
Exploring anti-patterns in Rails
aemeredith
3
470
How to Ace a Technical Interview
jacobian
281
24k
My Coaching Mixtape
mlcsv
0
270
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
580
Reality Check: Gamification 10 Years Later
codingconduct
0
2.3k
Transcript
Angularは本当に速いのか? ng-fukuoka Angular Meetup #1 / June 25, 2017 ponday(@ponday_dev)
Profile ponday (@ponday_dev) - chibi-developer - ng-fukuoka スタッフ community -
Kotlin, Java, C# etc... - JavaScript - Angular, Vue.js skill
AngularJS -> Angular 速くなった(らしい)
ほんとに?
測ってみる AngularとReactの速度比較 (AngularJS時代は AngularJS << Reactだったらしい) 以下の項目で比較してみる ① リストレンダリング(DOM) ②
リストレンダリング(コンポーネント) ③ パラメータ変更 → View反映
① リストレンダリング(DOM) リスト(100件, 1000件, 10000件)をレンダリング Angular React 100件 1,000件 10,000件
49.37ms 125.85ms 438.11ms 43.80ms 115.77ms 402.02ms
② リストレンダリング(コンポーネント) リスト(100件, 1000件, 10000件)をレンダリング Angular React 100件 1,000件 10,000件
55.73ms 154.31ms 632.97ms 64.72ms 177.30ms 842.09ms
③ パラメータ変更 → View反映 内部のパラメータを変更 → 表示に反映されるまでの時間を計測 Angular React 1,000件
23.66ms 41.13ms
Angularの変更検知 ・Angularの変更検知の仕組み = Change Detection ・zone.jsを活用。 あらゆる非同期処理を検知してパラメータの変更がないか チェックしている → Reactなどで流行った仮想DOMとは異なる考え方 ・各コンポーネントがChangeDetector(変更検知器)を 持つ。ChangeDetectorもコンポーネントツリーと
同じようにツリーを構成する。
Angularの変更検知 Component Component Component Component Component Component Change Detector Change
Detector Change Detector Change Detector Change Detector Change Detector
Angularの変更検知 DOM zone.js (NgZone) ApplicationRef Change Detection window オブジェクトを パッチ
Angularの変更検知 DOM zone.js (NgZone) ApplicationRef 通知 Change Detection イベント発生
Angularの変更検知 DOM zone.js (NgZone) ApplicationRef イベント発生 補足 Change Detection
Angularの変更検知 DOM zone.js (NgZone) ApplicationRef 変更チェックを実行 (tickメソッド) Change Detection
Angularの変更検知 DOM zone.js (NgZone) ApplicationRef Change Detection コンポーネント毎に変更をチェック → Viewに反映
コンポーネント毎にチェックって遅くないの? ・当然コストは0ではないが遅くない ・Reactの仮想DOMも似たようなもの → Angularが生成するコードはきちんと最適化される ・パラメータの型に応じて内部的に比較方法を切替えて ムダを省いている ・AngularJS時代はひたすらループしていた(らしい) Angularではイベントが起こらない限りチェックはしない
パフォーマンスチューニング ・そのままでも十分速い よほどパフォーマンスが求められない限り不要 ・オプションで変更チェックのタイミングも制御可能 ・ChangeDetectionを伴わない非同期処理も書ける → NgZone.runOutsideAngular() → スクロールやウィンドウのリサイズなどを省くと良いかも
まとめ ・レンダリングの速度はReactと遜色ない ・コンポーネントの生成コストはAngularの方が小さそう ・変更チェックについてもReact(仮想DOM)と遜色ない → ChangeDetectionすげえ
結論 Angularも速くなった!