mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
parent
2669cd5c03
commit
311c046c65
1 changed files with 0 additions and 48 deletions
48
bin/lineprof
48
bin/lineprof
|
@ -1,48 +0,0 @@
|
|||
#!/usr/bin/env ruby
|
||||
|
||||
require 'bundler/setup'
|
||||
require 'hamlit'
|
||||
require 'lineprof'
|
||||
require 'tempfile'
|
||||
require 'thor'
|
||||
|
||||
class CLI < Thor
|
||||
desc 'render HAML', 'Benchmark render'
|
||||
def render(file)
|
||||
haml = File.read(file)
|
||||
compiled = Hamlit::Engine.new.call(haml)
|
||||
code = [
|
||||
'require "lineprof"',
|
||||
'require "hamlit"',
|
||||
|
||||
'Lineprof.profile(/./) do',
|
||||
'100.times do',
|
||||
compiled,
|
||||
'end',
|
||||
'end',
|
||||
].join("\n")
|
||||
|
||||
file = Tempfile.create('compiled')
|
||||
file.write(code)
|
||||
file.close
|
||||
|
||||
system("bundle exec ruby #{file.path}")
|
||||
end
|
||||
|
||||
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
|
||||
render(args.first.to_s)
|
||||
end
|
||||
end
|
||||
|
||||
CLI.start
|
Loading…
Reference in a new issue