Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions performance/benchmark.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
require 'benchmark/ips'
require_relative 'theme_runner'

RubyVM::YJIT.enable if defined?(RubyVM::YJIT)
if defined?(RubyVM::YJIT)
RubyVM::YJIT.enable
puts "* YJIT enabled"
else
puts "* YJIT not enabled"
end

Liquid::Environment.default.error_mode = ARGV.first.to_sym if ARGV.first

profiler = ThemeRunner.new
Expand All @@ -18,8 +24,8 @@

phase = ENV["PHASE"] || "all"

x.report("tokenize:") { profiler.tokenize } if phase == "all" || phase == "tokenize"
x.report("parse:") { profiler.compile } if phase == "all" || phase == "parse"
x.report("render:") { profiler.render } if phase == "all" || phase == "render"
x.report("parse & render:") { profiler.run } if phase == "all" || phase == "run"
x.report("tokenize:") { profiler.tokenize_all } if phase == "all" || phase == "tokenize"
x.report("parse:") { profiler.compile_all } if phase == "all" || phase == "parse"
x.report("render:") { profiler.render_all } if phase == "all" || phase == "render"
x.report("parse & render:") { profiler.run_all } if phase == "all" || phase == "run"
end
4 changes: 2 additions & 2 deletions performance/memory_profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def sanitize(string)

runner = ThemeRunner.new
Profiler.run do |x|
x.profile('parse') { runner.compile }
x.profile('render') { runner.render }
x.profile('parse') { runner.compile_all }
x.profile('render') { runner.render_all }
x.tabulate
end
36 changes: 26 additions & 10 deletions performance/profile.rb
Original file line number Diff line number Diff line change
@@ -1,26 +1,42 @@
# frozen_string_literal: true

require 'stackprof'
require 'fileutils'
require_relative 'theme_runner'

output_dir = ENV['OUTPUT_DIR'] || "/tmp/liquid-performance"
FileUtils.mkdir_p(output_dir)

Liquid::Template.error_mode = ARGV.first.to_sym if ARGV.first
profiler = ThemeRunner.new
profiler.run
profiler.run_all # warmup

[:cpu, :object].each do |profile_type|
puts "Profiling in #{profile_type} mode..."
results = StackProf.run(mode: profile_type) do
[:cpu, :object].each do |mode|
puts
puts "Profiling in #{mode} mode..."
puts "writing to #{output_dir}/#{mode}.profile:"
puts
StackProf.run(mode: mode, raw: true, out: "#{output_dir}/#{mode}.profile") do
200.times do
profiler.run
profiler.run_all
end
end

if profile_type == :cpu && (graph_filename = ENV['GRAPH_FILENAME'])
File.open(graph_filename, 'w') do |f|
StackProf::Report.new(results).print_graphviz(nil, f)
result = StackProf.run(mode: mode) do
100.times do
profiler.run_all
end
end

StackProf::Report.new(results).print_text(false, 20)
File.write(ENV['FILENAME'] + "." + profile_type.to_s, Marshal.dump(results)) if ENV['FILENAME']
StackProf::Report.new(result).print_text(false, 30)
end

puts
puts "files in #{output_dir}:"
Dir.glob("#{output_dir}/*").each do |file|
puts " #{file}"
end
puts "Recommended:"
puts " stackprof --d3-flamegraph #{output_dir}/cpu.profile > #{output_dir}/flame.html"
puts " stackprof --method #{output_dir}/cpu.profile"
puts " etc"
25 changes: 21 additions & 4 deletions performance/shopify/database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,36 @@ def self.tables
end
end

# Some standard direct accessors so that the specialized templates
# render correctly
db['collection'] = db['collections'].values.first
db['product'] = db['products'].values.first
db['blog'] = db['blogs'].values.first
db['article'] = db['blog']['articles'].first

db['cart'] = {
# Some standard direct accessors so that the specialized templates
# render correctly
db['collection'] = db['collections'].values.first
db['collection']['tags'] = db['collection']['products'].map { |product| product['tags'] }.flatten.uniq.sort

db['tags'] = db['collection']['tags'][0..1]
db['all_tags'] = db['products'].values.map { |product| product['tags'] }.flatten.uniq.sort
db['current_tags'] = db['collection']['tags'][0..1]
db['handle'] = db['collection']['handle']

db['cart'] = {
'total_price' => db['line_items'].values.inject(0) { |sum, item| sum + item['line_price'] * item['quantity'] },
'item_count' => db['line_items'].values.inject(0) { |sum, item| sum + item['quantity'] },
'items' => db['line_items'].values,
}

db['linklists'] = db['link_lists']

db['shop'] = {
'name' => 'Snowdevil',
'currency' => 'USD',
'money_format' => '${{amount}}',
'money_with_currency_format' => '${{amount}} USD',
'money_format_with_currency' => 'USD ${{amount}}',
}

db
end
end
Expand Down
68 changes: 27 additions & 41 deletions performance/shopify/vision.database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,7 @@ products:
featured_image: products/arbor_draft.jpg
images:
- products/arbor_draft.jpg
description:
The Arbor Draft snowboard wouldn't exist if Polynesians hadn't figured out how to surf hundreds of years ago. But the Draft does exist, and it's here to bring your urban and park riding to a new level. The board's freaky Tiki design pays homage to culture that inspired snowboarding. It's designed to spin with ease, land smoothly, lock hook-free onto rails, and take the abuse of a pavement pounding or twelve. The Draft will pop off kickers with authority and carve solidly across the pipe. The Draft features targeted Koa wood die cuts inlayed into the deck that enhance the flex pattern. Now bow down to riding's ancestors.
description: The Arbor Draft snowboard wouldn't exist if Polynesians hadn't figured out how to surf hundreds of years ago. But the Draft does exist, and it's here to bring your urban and park riding to a new level. The board's freaky Tiki design pays homage to culture that inspired snowboarding. It's designed to spin with ease, land smoothly, lock hook-free onto rails, and take the abuse of a pavement pounding or twelve. The Draft will pop off kickers with authority and carve solidly across the pipe. The Draft features targeted Koa wood die cuts inlayed into the deck that enhance the flex pattern. Now bow down to riding's ancestors.
variants:
- *product-1-var-1
- *product-1-var-2
Expand Down Expand Up @@ -377,8 +376,7 @@ products:
featured_image: products/element58.jpg
images:
- products/element58.jpg
description:
The Element is a technically advanced all-mountain board for riders who readily transition from one terrain, snow condition, or riding style to another. Its balanced design provides the versatility needed for the true ride-it-all experience. The Element is exceedingly lively, freely initiates, and holds a tight edge at speed. Its structural real-wood topsheet is made with book-matched Koa.
description: The Element is a technically advanced all-mountain board for riders who readily transition from one terrain, snow condition, or riding style to another. Its balanced design provides the versatility needed for the true ride-it-all experience. The Element is exceedingly lively, freely initiates, and holds a tight edge at speed. Its structural real-wood topsheet is made with book-matched Koa.
variants:
- *product-2-var-1

Expand Down Expand Up @@ -411,8 +409,7 @@ products:
- products/technine1.jpg
- products/technine2.jpg
- products/technine_detail.jpg
description:
2005 Technine Comic Series Description The Comic series was developed to be the ultimate progressive freestyle board in the Technine line. Dependable edge control and a perfect flex pattern for jumping in the park or out of bounds. Landins and progression will come easy with this board and it will help your riding progress to the next level. Street rails, park jibs, backcountry booters and park jumps, this board will do it all.
description: 2005 Technine Comic Series Description The Comic series was developed to be the ultimate progressive freestyle board in the Technine line. Dependable edge control and a perfect flex pattern for jumping in the park or out of bounds. Landins and progression will come easy with this board and it will help your riding progress to the next level. Street rails, park jibs, backcountry booters and park jumps, this board will do it all.
variants:
- *product-3-var-1
- *product-3-var-2
Expand Down Expand Up @@ -446,8 +443,7 @@ products:
images:
- products/technine3.jpg
- products/technine4.jpg
description:
2005 Technine Comic Series Description The Comic series was developed to be the ultimate progressive freestyle board in the Technine line. Dependable edge control and a perfect flex pattern for jumping in the park or out of bounds. Landins and progression will come easy with this board and it will help your riding progress to the next level. Street rails, park jibs, backcountry booters and park jumps, this board will do it all.
description: 2005 Technine Comic Series Description The Comic series was developed to be the ultimate progressive freestyle board in the Technine line. Dependable edge control and a perfect flex pattern for jumping in the park or out of bounds. Landins and progression will come easy with this board and it will help your riding progress to the next level. Street rails, park jibs, backcountry booters and park jumps, this board will do it all.
variants:
- *product-4-var-1

Expand Down Expand Up @@ -478,8 +474,7 @@ products:
featured_image: products/burton.jpg
images:
- products/burton.jpg
description:
The Burton boots are particularly well on snowboards. The very best thing about them is that the according picture is cubic. This makes testing in a Vision testing environment very easy.
description: The Burton boots are particularly well on snowboards. The very best thing about them is that the according picture is cubic. This makes testing in a Vision testing environment very easy.
variants:
- *product-5-var-1
- *product-5-var-2
Expand Down Expand Up @@ -516,8 +511,7 @@ products:
featured_image: products/ducati.jpg
images:
- products/ducati.jpg
description:
<h3>‘S’ PERFORMANCE</h3>
description: <h3>‘S’ PERFORMANCE</h3>
<p>Producing 170hp (125kW) and with a dry weight of just 169kg (372.6lb), the new 1198 S now incorporates more World Superbike technology than ever before by taking the 1198 motor and adding top-of-the-range suspension, lightweight chassis components and a true racing-style traction control system designed for road use.</p>
<p>The high performance, fully adjustable 43mm Öhlins forks, which sport low friction titanium nitride-treated fork sliders, respond effortlessly to every imperfection in the tarmac. Beyond their advanced engineering solutions, one of the most important characteristics of Öhlins forks is their ability to communicate the condition and quality of the tyre-to-road contact patch, a feature that puts every rider in superior control. The suspension set-up at the rear is complemented with a fully adjustable Öhlins rear shock equipped with a ride enhancing top-out spring and mounted to a single-sided swingarm for outstanding drive and traction. The front-to-rear Öhlins package is completed with a control-enhancing adjustable steering damper.</p>
variants:
Expand Down Expand Up @@ -636,16 +630,15 @@ products:
- *product-9-var-2
- *product-9-var-3


# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# Line Items
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

line_items:
- &line_item-1
id: 1
title: 'Arbor Draft'
subtitle: '151cm'
title: "Arbor Draft"
subtitle: "151cm"
price: 29900
line_price: 29900
quantity: 1
Expand All @@ -654,8 +647,8 @@ line_items:

- &line_item-2
id: 2
title: 'Comic ~ Orange'
subtitle: '159cm'
title: "Comic ~ Orange"
subtitle: "159cm"
price: 19900
line_price: 39800
quantity: 2
Expand All @@ -681,7 +674,7 @@ links:
- &link-4
id: 4
title: Powered by Shopify
url: 'http://shopify.com'
url: "http://shopify.com"
- &link-5
id: 5
title: About Us
Expand Down Expand Up @@ -715,26 +708,24 @@ links:
title: Catalog
url: /collections/all



# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# Link Lists
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

link_lists:
- &link-list-1
id: 1
title: 'Main Menu'
handle: 'main-menu'
title: "Main Menu"
handle: "main-menu"
links:
- *link-12
- *link-5
- *link-7
- *link-8
- &link-list-2
id: 1
title: 'Footer Menu'
handle: 'footer'
title: "Footer Menu"
handle: "footer"
links:
- *link-5
- *link-6
Expand Down Expand Up @@ -768,8 +759,7 @@ collections:
title: Snowboards
handle: snowboards
url: /collections/snowboards
description:
<p>This is a description for my <strong>Snowboards</strong> collection.</p>
description: <p>This is a description for my <strong>Snowboards</strong> collection.</p>
products:
- *product-1
- *product-2
Expand All @@ -787,8 +777,8 @@ collections:
- &collection-5
id: 5
title: Paginated Sale
handle: 'paginated-sale'
url: '/collections/paginated-sale'
handle: "paginated-sale"
url: "/collections/paginated-sale"
products:
- *product-1
- *product-2
Expand All @@ -799,8 +789,8 @@ collections:
- &collection-6
id: 6
title: All products
handle: 'all'
url: '/collections/all'
handle: "all"
url: "/collections/all"
products:
- *product-7
- *product-8
Expand All @@ -812,7 +802,6 @@ collections:
- *product-4
- *product-5


# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# Pages and Blogs
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Expand All @@ -823,8 +812,7 @@ pages:
handle: contact
url: /pages/contact
author: Tobi
content:
"<p>You can contact us via phone under (555) 567-2222.</p>
content: "<p>You can contact us via phone under (555) 567-2222.</p>
<p>Our retail store is located at <em>Rue d'Avignon 32, Avignon (Provence)</em>.</p>
<p><strong>Opening Hours:</strong><br />Monday through Friday: 9am - 6pm<br />Saturday: 10am - 3pm<br />Sunday: closed</p>"
created_at: 2005-04-04 12:00
Expand Down Expand Up @@ -874,12 +862,12 @@ blogs:
url: /blogs/news
articles:
- id: 3
title: 'Welcome to the new Foo Shop'
title: "Welcome to the new Foo Shop"
author: Daniel
content: <p><strong>Welcome to your Shopify store! The jaded Pixel crew is really glad you decided to take Shopify for a spin.</strong></p><p>To help you get you started with Shopify, here are a couple of tips regarding what you see on this page.</p><p>The text you see here is an article. To edit this article, create new articles or create new pages you can go to the <a href="/admin/pages">Blogs &amp; Pages</a> tab of the administration menu.</p><p>The Shopify t-shirt above is a product and selling products is what Shopify is all about. To edit this product, or create new products you can go to the <a href="/admin/products">Products Tab</a> in of the administration menu.</p><p>While you're looking around be sure to check out the <a href="/admin/collections">Collections</a> and <a href="/admin/links">Navigations</a> tabs and soon you will be well on your way to populating your site.</p><p>And of course don't forget to browse the <a href="admin/design/appearance/themes">theme gallery</a> to pick a new look for your shop!</p><p><strong>Shopify is in beta</strong><br />If you would like to make comments or suggestions please visit us in the <a href="http://forums.shopify.com/community">Shopify Forums</a> or drop us an <a href="mailto:feedback@shopify.com">email</a>.</p>
created_at: 2005-04-04 16:00
- id: 4
title: 'Breaking News: Restock on all sales products'
title: "Breaking News: Restock on all sales products"
author: Tobi
content: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
created_at: 2005-04-04 12:00
Expand All @@ -891,22 +879,20 @@ blogs:
url: /blogs/bigcheese-blog
articles:
- id: 1
title: 'One thing you probably did not know yet...'
title: "One thing you probably did not know yet..."
author: Justin
content: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
created_at: 2005-04-04 16:00
comments:
-
id: 1
- id: 1
author: John Smith
email: john@smith.com
content: Wow...great article man.
status: published
created_at: 2009-01-01 12:00
updated_at: 2009-02-01 12:00
url: ""
-
id: 2
- id: 2
author: John Jones
email: john@jones.com
content: I really enjoyed this article. And I love your shop! It's awesome. Shopify rocks!
Expand All @@ -932,7 +918,7 @@ blogs:
url: /blogs/paginated-blog
articles:
- id: 6
title: 'One thing you probably did not know yet...'
title: "One thing you probably did not know yet..."
author: Justin
content: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
created_at: 2005-04-04 16:00
Expand Down
Loading