-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathtest.rb
More file actions
76 lines (56 loc) · 1.62 KB
/
test.rb
File metadata and controls
76 lines (56 loc) · 1.62 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
require "rubygems"
require "bundler/setup"
require "lattescript"
require "benchmark"
require "ruby-prof"
file = <<-FOO
/**
some docs
*/
App.Foo = SC.View.extend({
/**
some docs
*/
hi: function() {
}
});
FOO
parser = LatteScript::Parser.new(file)
parser.parse
ast = parser.result
new_string = LatteScript::Stringifier.to_string(ast) do |stringifier|
stringifier.include_comments = true
end
puts new_string
__END__
#result = RubyProf.profile do
Dir[File.expand_path("~/Code/cool_stuff/sproutcore20/packages/**/lib/**/*.js")].each do |file|
#Dir[File.expand_path("~/Code/cool_stuff/jquery/src/**/*.js")].each do |file|
#Dir["/Users/wycats/Code/cool_stuff/jquery/src/queue.js"].each do |file|
next if file =~ /jquery-|packages\/handlebars|packages\/metamorph/
#next if file =~ /intro|outro|sizzle\/(speed|test)|sizzle-jquery/
string = File.read(file)
puts "#{file}: "
puts
result = Benchmark.measure {
LatteScript::Parser.new(string).parse
}
#puts "#{string.size} bytes in #{result.total.round(2)}s = #{(string.size / result.total).round}bps"
end
#end
#printer = RubyProf::CallTreePrinter.new(result)
#printer.print(File.open("call.grind", "w"))
__END__
string = File.read("spec/fixtures/jquery.js")
#require "ruby-prof"
ast = nil
#result = RubyProf.profile do
parser = LatteScript::Parser.new(string)
ast = parser.parse
#end
#printer = RubyProf::FlatPrinter.new(result)
#printer.print(STDOUT)
#printer.print(File.open("profile.html", "w"))
#new_string = LatteScript::Stringifier.to_string(ast) do |stringifier|
#stringifier.include_comments = true
#end