File: benchmark.rb

package info (click to toggle)
ruby-liquid 5.12.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,444 kB
  • sloc: ruby: 14,571; makefile: 6
file content (25 lines) | stat: -rw-r--r-- 757 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# frozen_string_literal: true

require 'benchmark/ips'
require_relative 'theme_runner'

RubyVM::YJIT.enable if defined?(RubyVM::YJIT)
Liquid::Environment.default.error_mode = ARGV.first.to_sym if ARGV.first

profiler = ThemeRunner.new

Benchmark.ips do |x|
  x.time   = 20
  x.warmup = 10

  puts
  puts "Running benchmark for #{x.time} seconds (with #{x.warmup} seconds warmup)."
  puts

  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"
end