Skip to content

Instantly share code, notes, and snippets.

@jasonroelofs
Created May 30, 2014 20:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonroelofs/56d48cbb5e0749ba3062 to your computer and use it in GitHub Desktop.
Save jasonroelofs/56d48cbb5e0749ba3062 to your computer and use it in GitHub Desktop.
Liquid benchmarking comparing render profiling changes
Ruby 2.1.2 -- Master
$ ruby ./performance/benchmark.rb lax
Rehearsal ------------------------------------------------
parse: 4.180000 0.030000 4.210000 ( 4.205455)
parse & run: 8.670000 0.010000 8.680000 ( 8.687521)
-------------------------------------- total: 12.890000sec
user system total real
parse: 4.100000 0.020000 4.120000 ( 4.112649)
parse & run: 8.550000 0.010000 8.560000 ( 8.554764)
$ ruby ./performance/benchmark.rb strict
Rehearsal ------------------------------------------------
parse: 4.590000 0.010000 4.600000 ( 4.601561)
parse & run: 9.110000 0.010000 9.120000 ( 9.121570)
-------------------------------------- total: 13.720000sec
user system total real
parse: 4.620000 0.020000 4.640000 ( 4.634911)
parse & run: 9.370000 0.010000 9.380000 ( 9.388722)
$ ruby ./performance/profile.rb
==================================
Mode: cpu(1000)
Samples: 1392 (0.00% miss rate)
GC: 268 (19.25%)
==================================
TOTAL (pct) SAMPLES (pct) FRAME
208 (14.9%) 127 (9.1%) Liquid::Variable#lax_parse
194 (13.9%) 117 (8.4%) Liquid::Context#variable
1076 (77.3%) 103 (7.4%) Liquid::Block#parse
1351 (97.1%) 95 (6.8%) Liquid::Block#render_all
277 (19.9%) 83 (6.0%) Liquid::Context#resolve
81 (5.8%) 81 (5.8%) block in Liquid::Variable#lax_parse
53 (3.8%) 53 (3.8%) Liquid::Template#tokenize
264 (19.0%) 51 (3.7%) Liquid::Variable#initialize
39 (2.8%) 39 (2.8%) Liquid::Context#has_interrupt?
1256 (90.2%) 30 (2.2%) block in Liquid::Block#render_all
24 (1.7%) 24 (1.7%) Liquid::Context#increment_used_resources
21 (1.5%) 21 (1.5%) Liquid::Context#lookup_and_evaluate
27 (1.9%) 21 (1.5%) Liquid::If#lax_parse
31 (2.2%) 20 (1.4%) block in Liquid::Context#variable
16 (1.1%) 15 (1.1%) Liquid::For#lax_parse
46 (3.3%) 15 (1.1%) Liquid::Context#find_variable
23 (1.7%) 13 (0.9%) Liquid::StandardFilters#to_date
12 (0.9%) 12 (0.9%) Liquid::StandardFilters#strip_html
11 (0.8%) 11 (0.8%) Set#include?
11 (0.8%) 11 (0.8%) block in Liquid::Context#find_variable
$ ruby ./performance/profile.rb strict
==================================
Mode: cpu(1000)
Samples: 1520 (0.00% miss rate)
GC: 287 (18.88%)
==================================
TOTAL (pct) SAMPLES (pct) FRAME
158 (10.4%) 158 (10.4%) Liquid::Lexer#tokenize
1287 (84.7%) 148 (9.7%) Liquid::Block#parse
216 (14.2%) 141 (9.3%) Liquid::Context#variable
314 (20.7%) 98 (6.4%) Liquid::Context#resolve
1353 (89.0%) 89 (5.9%) Liquid::Block#render_all
259 (17.0%) 54 (3.6%) Liquid::Variable#initialize
50 (3.3%) 50 (3.3%) Liquid::Template#tokenize
199 (13.1%) 49 (3.2%) Liquid::Variable#strict_parse
37 (2.4%) 37 (2.4%) Liquid::Context#has_interrupt?
27 (1.8%) 27 (1.8%) Liquid::Parser#consume
29 (1.9%) 26 (1.7%) block in Liquid::Context#variable
23 (1.5%) 23 (1.5%) Liquid::Lexer#initialize
1264 (83.2%) 19 (1.2%) block in Liquid::Block#render_all
19 (1.2%) 19 (1.2%) Liquid::Context#increment_used_resources
30 (2.0%) 19 (1.2%) Liquid::StandardFilters#to_date
17 (1.1%) 17 (1.1%) Liquid::Context#lookup_and_evaluate
46 (3.0%) 14 (0.9%) Liquid::Context#find_variable
11 (0.7%) 11 (0.7%) Liquid::Parser#look
348 (22.9%) 11 (0.7%) Liquid::Variable#render
11 (0.7%) 11 (0.7%) Liquid::Context#[]=
Ruby 2.1.2 -- Without Profiling
$ ruby ./performance/benchmark.rb lax
Rehearsal ------------------------------------------------
parse: 5.150000 0.020000 5.170000 ( 5.175809)
parse & run: 9.970000 0.020000 9.990000 ( 9.993836)
-------------------------------------- total: 15.160000sec
user system total real
parse: 5.070000 0.010000 5.080000 ( 5.080697)
parse & run: 9.930000 0.020000 9.950000 ( 9.953284)
$ ruby ./performance/benchmark.rb strict
Rehearsal ------------------------------------------------
parse: 5.650000 0.030000 5.680000 ( 5.677780)
parse & run: 10.490000 0.010000 10.500000 ( 10.509851)
-------------------------------------- total: 16.180000sec
user system total real
parse: 5.540000 0.020000 5.560000 ( 5.561073)
parse & run: 10.500000 0.020000 10.520000 ( 10.525464)
$ ruby ./performance/profile.rb
==================================
Mode: cpu(1000)
Samples: 1742 (0.00% miss rate)
GC: 372 (21.35%)
==================================
TOTAL (pct) SAMPLES (pct) FRAME
220 (12.6%) 129 (7.4%) Liquid::Variable#lax_parse
205 (11.8%) 125 (7.2%) Liquid::Context#variable
1447 (83.1%) 113 (6.5%) Liquid::Block#render_all
1099 (63.1%) 95 (5.5%) Liquid::Block#parse
93 (5.3%) 93 (5.3%) Liquid::Token#initialize
297 (17.0%) 92 (5.3%) Liquid::Context#resolve
91 (5.2%) 91 (5.2%) block in Liquid::Variable#lax_parse
285 (16.4%) 53 (3.0%) Liquid::Variable#initialize
53 (3.0%) 52 (3.0%) Liquid::Profiler::Timing#initialize
49 (2.8%) 49 (2.8%) Liquid::Context#has_interrupt?
143 (8.2%) 43 (2.5%) Liquid::Template#tokenize
34 (2.0%) 32 (1.8%) Liquid::If#lax_parse
33 (1.9%) 27 (1.5%) block in Liquid::Context#variable
1334 (76.6%) 23 (1.3%) block in Liquid::Block#render_all
21 (1.2%) 21 (1.2%) Liquid::Context#lookup_and_evaluate
19 (1.1%) 19 (1.1%) Liquid::Context#timing_end
18 (1.0%) 18 (1.0%) Liquid::Template.error_mode
17 (1.0%) 17 (1.0%) Liquid::For#lax_parse
16 (0.9%) 16 (0.9%) block in Liquid::Context#find_variable
16 (0.9%) 16 (0.9%) Liquid::Context#increment_used_resources
$ ruby ./performance/profile.rb strict
==================================
Mode: cpu(1000)
Samples: 1836 (0.00% miss rate)
GC: 386 (21.02%)
==================================
TOTAL (pct) SAMPLES (pct) FRAME
232 (12.6%) 160 (8.7%) Liquid::Context#variable
152 (8.3%) 152 (8.3%) Liquid::Lexer#tokenize
1339 (72.9%) 150 (8.2%) Liquid::Block#parse
102 (5.6%) 102 (5.6%) Liquid::Token#initialize
1479 (80.6%) 102 (5.6%) Liquid::Block#render_all
330 (18.0%) 98 (5.3%) Liquid::Context#resolve
54 (2.9%) 54 (2.9%) Liquid::Profiler::Timing#initialize
217 (11.8%) 51 (2.8%) Liquid::Variable#strict_parse
273 (14.9%) 51 (2.8%) Liquid::Variable#initialize
158 (8.6%) 44 (2.4%) Liquid::Template#tokenize
39 (2.1%) 39 (2.1%) Liquid::Context#has_interrupt?
30 (1.6%) 30 (1.6%) Liquid::Lexer#initialize
1377 (75.0%) 27 (1.5%) block in Liquid::Block#render_all
21 (1.1%) 21 (1.1%) Liquid::Parser#consume
25 (1.4%) 20 (1.1%) block in Liquid::Context#variable
19 (1.0%) 19 (1.0%) Liquid::Parser#look
18 (1.0%) 18 (1.0%) Liquid::Context#increment_used_resources
16 (0.9%) 16 (0.9%) Liquid::Context#lookup_and_evaluate
15 (0.8%) 15 (0.8%) Liquid::Context#[]=
15 (0.8%) 15 (0.8%) block in Liquid::Context#find_variable
Ruby 2.1.2 -- With Profiling
$ ruby ./performance/benchmark.rb lax
Rehearsal ------------------------------------------------
parse: 5.090000 0.030000 5.120000 ( 5.115540)
parse & run: 11.020000 0.030000 11.050000 ( 11.047344)
-------------------------------------- total: 16.170000sec
user system total real
parse: 5.010000 0.010000 5.020000 ( 5.029259)
parse & run: 10.900000 0.040000 10.940000 ( 10.945426)
$ ruby ./performance/benchmark.rb strict
Rehearsal ------------------------------------------------
parse: 5.590000 0.020000 5.610000 ( 5.615326)
parse & run: 11.400000 0.050000 11.450000 ( 11.441936)
-------------------------------------- total: 17.060000sec
user system total real
parse: 5.560000 0.020000 5.580000 ( 5.588626)
parse & run: 11.720000 0.060000 11.780000 ( 11.790123)
$ ruby ./performance/profile.rb
==================================
Mode: cpu(1000)
Samples: 2156 (0.00% miss rate)
GC: 543 (25.19%)
==================================
TOTAL (pct) SAMPLES (pct) FRAME
228 (10.6%) 151 (7.0%) Liquid::Variable#lax_parse
1196 (55.5%) 147 (6.8%) Liquid::Block#parse
342 (15.9%) 115 (5.3%) Liquid::Context#resolve
227 (10.5%) 113 (5.2%) Liquid::Context#variable
96 (4.5%) 96 (4.5%) Liquid::Profiler::Timing#finished
109 (5.1%) 89 (4.1%) Liquid::Profiler::Timing#initialize
88 (4.1%) 88 (4.1%) Liquid::Token#initialize
77 (3.6%) 77 (3.6%) block in Liquid::Variable#lax_parse
1953 (90.6%) 56 (2.6%) Liquid::Block#render_all
158 (7.3%) 54 (2.5%) Liquid::Template#tokenize
289 (13.4%) 48 (2.2%) Liquid::Variable#initialize
1897 (88.0%) 34 (1.6%) block in Liquid::Block#render_all
34 (1.6%) 34 (1.6%) Liquid::Context#has_interrupt?
33 (1.5%) 33 (1.5%) Liquid::Context#lookup_and_evaluate
43 (2.0%) 31 (1.4%) block in Liquid::Context#variable
32 (1.5%) 29 (1.3%) Liquid::If#lax_parse
26 (1.2%) 26 (1.2%) Liquid::Context#increment_used_resources
25 (1.2%) 24 (1.1%) Liquid::For#lax_parse
23 (1.1%) 23 (1.1%) block in Liquid::Context#find_variable
23 (1.1%) 23 (1.1%) Liquid::Template.error_mode
$ ruby ./performance/profile.rb strict
==================================
Mode: cpu(1000)
Samples: 2033 (0.00% miss rate)
GC: 428 (21.05%)
==================================
TOTAL (pct) SAMPLES (pct) FRAME
170 (8.4%) 170 (8.4%) Liquid::Lexer#tokenize
1369 (67.3%) 160 (7.9%) Liquid::Block#parse
215 (10.6%) 114 (5.6%) Liquid::Context#variable
99 (4.9%) 99 (4.9%) Liquid::Token#initialize
124 (6.1%) 96 (4.7%) Liquid::Profiler::Timing#initialize
310 (15.2%) 95 (4.7%) Liquid::Context#resolve
76 (3.7%) 76 (3.7%) Liquid::Profiler::Timing#finished
287 (14.1%) 51 (2.5%) Liquid::Variable#initialize
159 (7.8%) 47 (2.3%) Liquid::Template#tokenize
235 (11.6%) 46 (2.3%) Liquid::Variable#strict_parse
36 (1.8%) 36 (1.8%) Liquid::Parser#consume
34 (1.7%) 34 (1.7%) Liquid::Lexer#initialize
1775 (87.3%) 34 (1.7%) block in Liquid::Block#render_all
29 (1.4%) 29 (1.4%) Liquid::Context#increment_used_resources
28 (1.4%) 28 (1.4%) Liquid::Context#has_interrupt?
1801 (88.6%) 26 (1.3%) Liquid::Block#render_all
26 (1.3%) 26 (1.3%) block in Liquid::Context#find_variable
33 (1.6%) 26 (1.3%) block in Liquid::Context#variable
20 (1.0%) 20 (1.0%) block (2 levels) in Liquid::Template#tokenize
20 (1.0%) 20 (1.0%) Liquid::Context#lookup_and_evaluate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment