Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix performance benchmarks

  • Loading branch information...
commit eb10790e8b6dc73e455e67e67d66af98b98c9981 1 parent 6b5ea45
@txus authored
Showing with 5 additions and 9 deletions.
  1. +4 −8 perf/nobench.rb
  2. +1 −1  perf/trait_bench.rb
View
12 perf/nobench.rb
@@ -5,9 +5,7 @@ class Array; def mean; inject(:+) / size.to_f; end; end
TIMES = 10000
def benchmark(code)
- code.strip!
-
- Noscript::Parser.new.scan_str(code).compile(Noscript::Context.generate)
+ Noscript.eval_noscript(code)
# Do a first run to eliminate random GC effects
# LEXER
@@ -26,22 +24,20 @@ def benchmark(code)
parser = Noscript::Parser.new
parser_time = (0..TIMES).to_a.map do
Benchmark.realtime {
- parser.scan_str(code)
+ parser.parse_string(code, "(benchmark)")
}
end.mean * 1000
puts "PARSER: #{parser_time - lexer_time}"
# RUNTIME
- parser = Noscript::Parser.new
- ast = parser.scan_str(code)
runtime = (0..TIMES).to_a.map do
Benchmark.realtime {
- ast.compile(Noscript::Context.generate)
+ Noscript.eval_noscript(code)
}
end.mean * 1000
- puts "RUNTIME: #{runtime}"
+ puts "RUNTIME: #{runtime - parser_time - lexer_time}"
puts "TOTAL: #{lexer_time + parser_time + runtime}"
rescue
puts "ERROR"
View
2  perf/trait_bench.rb
@@ -2,7 +2,7 @@
benchmark(<<CODE)
- MyTrait = trait({
+ MyTrait = Trait.build("MyTrait", {
gimme my name: ->
@name
end
Please sign in to comment.
Something went wrong with that request. Please try again.