File: c_profile.rb

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

require "liquid"
require "liquid/c"
liquid_lib_dir = $LOAD_PATH.detect { |p| File.exist?(File.join(p, "liquid.rb")) }
require File.join(File.dirname(liquid_lib_dir), "performance/theme_runner")

TASK_NAMES = ["run", "compile", "render"]
task_name = ARGV.first || "run"
unless TASK_NAMES.include?(task_name)
  raise "Unsupported task '#{task_name}' (must be one of #{TASK_NAMES})"
end
task = ThemeRunner.new.method(task_name)

runner_id = fork do
  end_time = Time.now + 5.0
  task.call until Time.now >= end_time
end

profiler_pid = spawn("instruments -t 'Time Profiler' -p #{runner_id}")

Process.waitpid(runner_id)
Process.waitpid(profiler_pid)