From 70e2043e2ad6cbbc813c850c3be710538bbc7e19 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Sat, 31 Oct 2015 12:16:56 +0900 Subject: [PATCH] Add bin/lineprof --- bin/lineprof | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 bin/lineprof diff --git a/bin/lineprof b/bin/lineprof new file mode 100755 index 00000000..5fc5f50d --- /dev/null +++ b/bin/lineprof @@ -0,0 +1,26 @@ +#!/usr/bin/env ruby + +require 'bundler/setup' +require 'hamlit' +require 'lineprof' +require 'tempfile' +require 'thor' + +class CLI < Thor + desc 'compile HAML', 'Benchmark compile' + def compile(file) + haml = File.read(file) + Lineprof.profile(/./) do + 100.times { Hamlit::Engine.new.call(haml) } + end + end + + private + + def method_missing(*args) + return super if args.length > 1 + compile(args.first.to_s) + end +end + +CLI.start