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
And Benchmarks For All
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Alex Navasardyan
August 26, 2014
Programming
1
51
And Benchmarks For All
A talk about browsers, JavaScript, V8 and compilers.
Alex Navasardyan
August 26, 2014
Tweet
Share
More Decks by Alex Navasardyan
See All by Alex Navasardyan
Ember App Kit
twokul
0
49
Ember Data
twokul
0
93
Ember List View
twokul
0
58
Other Decks in Programming
See All in Programming
フロントエンド開発の勘所 -複数事業を経験して見えた判断軸の違い-
heimusu
7
2.8k
今から始めるClaude Code超入門
448jp
8
8.7k
360° Signals in Angular: Signal Forms with SignalStore & Resources @ngLondon 01/2026
manfredsteyer
PRO
0
120
Lambda のコードストレージ容量に気をつけましょう
tattwan718
0
120
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
560
izumin5210のプロポーザルのネタ探し #tskaigi_msup
izumin5210
1
110
Data-Centric Kaggle
isax1015
2
770
Fragmented Architectures
denyspoltorak
0
150
Spinner 軸ズレ現象を調べたらレンダリング深淵に飲まれた #レバテックMeetup
bengo4com
1
230
AIによるイベントストーミング図からのコード生成 / AI-powered code generation from Event Storming diagrams
nrslib
2
1.9k
AI Agent の開発と運用を支える Durable Execution #AgentsInProd
izumin5210
7
2.3k
AI前提で考えるiOSアプリのモダナイズ設計
yuukiw00w
0
230
Featured
See All Featured
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.7k
Code Reviewing Like a Champion
maltzj
527
40k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.4k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.6k
Thoughts on Productivity
jonyablonski
74
5k
Designing for Performance
lara
610
70k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
1.8k
Become a Pro
speakerdeck
PRO
31
5.8k
My Coaching Mixtape
mlcsv
0
48
Measuring & Analyzing Core Web Vitals
bluesmoon
9
750
Bash Introduction
62gerente
615
210k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
117
110k
Transcript
And Benchmarks For All
How to be faster and keep the pace.
Alex Navasardyan @twokul
None
What is a Benchmark?
the act of running a computer program, in order to
assess the relative performance of an object.
Benchmark is a Measurement
What are you measuring?
@SciencePorn
History
1991 Getto JavaScript
2006 jQuery/Dojo/MooTools
jQuery vs. Dojo http://jsperf.com/mojo-of-dojo-and-jquery is jQuery better than Dojo? why
use Dojo? Dojo: Twice As Fast When It Matters Most?
None
2009 node.js
2011 Embularactymerbone
Sane Code Structure
Modules
Sane Code Tools
Build tools
Know your tools
Chrome Dev Tools
None
D8 + IRHydra 2
None
None
Perf linter?
V8
Spider Monkey
Chakra
The code that you write is not the code that
gets executed.
Vocabulary (for V8)
• Bailouts. • Deoptimizations. • Oddballs (undefined, true, null). •
Monomorphic, Polymorphic.
Hidden classes (or maps)
function Person(first, last) { this.firstName = first; this.lastName = last;
} ! var ironMan = new Person(‘Tony’, ‘Stark’); var captainAmerica = new Person(‘Steve’, ‘Rogers’); captainAmerica.age = 83;
function Person(first, last) { this.firstName = first; this.lastName = last;
} ! var ironMan = new Person(‘Tony’, ‘Stark’); var captainAmerica = new Person(‘Steve’, ‘Rogers’); captainAmerica.age = 83;
function Person(first, last) { this.firstName = first; this.lastName = last;
} ! var ironMan = new Person(‘Tony’, ‘Stark’); var captainAmerica = new Person(‘Steve’, ‘Rogers’); captainAmerica.age = 83; Class C0
function Person(first, last) { this.firstName = first; this.lastName = last;
} ! var ironMan = new Person(‘Tony’, ‘Stark’); var captainAmerica = new Person(‘Steve’, ‘Rogers’); captainAmerica.age = 83; Class C1:C0
function Person(first, last) { this.firstName = first; this.lastName = last;
} ! var ironMan = new Person(‘Tony’, ‘Stark’); var captainAmerica = new Person(‘Steve’, ‘Rogers’); captainAmerica.age = 83; Class C2:C1
function Person(first, last) { this.firstName = first; this.lastName = last;
} ! var ironMan = new Person(‘Tony’, ‘Stark’); var captainAmerica = new Person(‘Steve’, ‘Rogers’); captainAmerica.age = 83; Class C2:C1
function Person(first, last) { this.firstName = first; this.lastName = last;
} ! var ironMan = new Person(‘Tony’, ‘Stark’); var captainAmerica = new Person(‘Steve’, ‘Rogers’); captainAmerica.age = 83; Class C3:C2
• initialize object members in constructor functions. • always initialize
object members in the same order (different hidden class trees).
Numbers (and tagging)
• 32 bit are used to represent both a number
and an object (to use the same code path). • last bit is 0 (number), 31 bit signed integer. • last bit is 1 (object). • if bigger than 31 bit, it creates a pointer to a new object.
• use 31 bit signed integers to avoid boxing.
Arrays (and objects)
• Fast Elements, linear storage buffer. • Dictionary Elements, hash
table storage.
• use contiguous index starting at 0. • don’t preallocate
large arrays. • don’t delete elements in arrays. • use array literals.
Compilers
• Full Compiler. • Optimizing Compiler, Crankshaft.
Inline Cache (optimization)
var ironMan = new Person(‘Tony’, ‘Stark’); ! console.log(ironMan.firstName);
push [ebp+0x8] mov eax,[ebp+0xc] mov edx, eax mov ecx, 0x60b55dd1
call LoadIC_Initialize ;; ironMan.firstName
push [ebp+0x8] mov eax,[ebp+0xc] mov edx, eax mov ecx, 0x60b55dd1
call 0x311286e0 ;; ironMan.firstName
More optimizations
var a = “12342234”, b, start = Date.now(); ! for
(var i = 0; i < 1000; i++) { b = ~~a; } ! console.log(Date.now() - start); Convert string to a number
var a, b, start = Date.now(); ! for (var i
= 0; i < 1000; i++) { b = ~~“12342234”; } ! console.log(Date.now() - start); Inlines the string
var a, b, start = Date.now(); ! for (var i
= 0; i < 1000; i++) { b = 12342234; } ! console.log(Date.now() - start); Inlines the converted value
var a, b, start = Date.now(); ! for (var i
= 0; i < 1000; i++) { // benchmarking the assignment b = 12342234; } ! console.log(Date.now() - start); Constant Propagation
var a = Date.now().toString(); var b, start = Date.now(); !
for (var i = 0; i < 1000; i++) { b = ~~a; } ! console.log(Date.now() - start); Convert string to a number
var a = Date.now().toString(); var b, start = Date.now(); !
var c = ~~a; for (var i = 0; i < 1000; i++) { b = c; } ! console.log(Date.now() - start); Hoists the conversion
var a = Date.now().toString(); var b, start = Date.now(); !
var c = ~~a; for (var i = 0; i < 1000; i++) { // benchmarking the assignment b = c; } ! console.log(Date.now() - start); Loop Invariant Motion
var start = Date.now(); ! for (var i = 0;
i < 1000; i++) { // happy benchmarking } ! console.log(Date.now() - start); Dead Code Elimination
var add = function(a, b, c, d) { return a
+ b + c + d; }; ! for (var i = 0; i < 1000; i++) { add(“a”, “b”, “c”, “d"); } Function inlining
for (var i = 0; i < 1000; i++) {
“a” + “b” + “c” + “d” } Function inlining
for (var i = 0; i < 1000; i++) {
“a” + “b” + “c” + “d” } ! for (var i = 0; i < 1000; i++) { // happy benchmarking } Benchmarking inlining
Algorithmic
The power of your optimization comes from right data structures
and algorithms.
Fix what matters
Benchmarks tips
• leave your laptop plugged in. • close all running
applications. • be prepared for the results to be inconsistent.
Thanks!