compiler/benchmarks/PPCBenchmark.st
changeset 459 4751c407bb40
parent 452 9f4558b3be66
child 460 87a3d30ab570
child 464 f6d77fee9811
--- a/compiler/benchmarks/PPCBenchmark.st	Sun May 10 06:28:36 2015 +0100
+++ b/compiler/benchmarks/PPCBenchmark.st	Tue May 12 01:24:03 2015 +0100
@@ -30,7 +30,7 @@
     ].
     ^ (benchmarkSuiteClass  class:self) run
 
-  	"
+  		"
     PPCBenchmark run.
     "
 !
@@ -211,6 +211,68 @@
         self reportInput: input time: time name: 'Smalltalk Parser Compiled'.
 ! !
 
+!PPCBenchmark methodsFor:'benchmarks - expression grammar'!
+
+benchmarkExpressionGrammar
+    | time |
+
+    self setupExpressionGrammar.
+
+    time := [ input do: [ :source | parser parse: source withContext: context ]] timeToRun asMilliSeconds.
+    
+    self reportInput: input time: time name: 'Expression Grammar'.
+!
+
+benchmarkExpressionGrammarCompiled
+    | time |
+
+    self setupExpressionGrammarCompiled.
+
+    time := [ input do: [ :source | parser parse: source withContext: context ]] timeToRun asMilliSeconds.
+    
+    self reportInput: input time: time name: 'Compiled Expression Grammar'.
+!
+
+benchmarkExpressionGrammarTokenized
+    | time |
+
+    self setupExpressionGrammarTokenized.
+
+    time := [ input do: [ :source | parser parse: source withContext: context ]] timeToRun asMilliSeconds.
+    
+    self reportInput: input time: time name: 'Tokenized Expression Grammar'.
+!
+
+benchmarkLL1ExpressionGrammar
+    | time |
+
+    self setupLL1ExpressionGrammar.
+
+    time := [ input do: [ :source | parser parse: source withContext: context ]] timeToRun asMilliSeconds.
+    
+    self reportInput: input time: time name: 'LL1 Expression Grammar'.
+!
+
+benchmarkLL1ExpressionGrammarCompiled
+    | time |
+
+    self setupLL1ExpressionGrammarCompiled.
+
+    time := [ input do: [ :source | parser parse: source withContext: context ]] timeToRun asMilliSeconds.
+    
+    self reportInput: input time: time name: 'Compiled LL1 Expression Grammar'.
+!
+
+benchmarkLL1ExpressionGrammarTokenized
+    | time |
+
+    self setupLL1ExpressionGrammarTokenized.
+
+    time := [ input do: [ :source | parser parse: source withContext: context ]] timeToRun asMilliSeconds.
+    
+    self reportInput: input time: time name: 'Tokenized LL1 Expression Grammar'.
+! !
+
 !PPCBenchmark methodsFor:'benchmarks - micro'!
 
 benchmarkAnyStar
@@ -237,6 +299,22 @@
 
 !PPCBenchmark methodsFor:'benchmarks-CalipeL'!
 
+benchmarkExpressionGrammarC
+    <setup: #setupExpressionGrammar>
+    <benchmark: 'Petit Expression Grammar - Standard'>
+    
+    input do: [ :source | parser parse: source withContext: context ]
+!
+
+benchmarkExpressionGrammarTokenizedC
+    <setup: #setupExpressionGrammarTokenized>
+    <teardown: #teardownExpressionGrammarTokenized>
+    <benchmark: 'Petit Expression Grammar - Tokenized'>
+    
+    
+    input do: [ :source | parser parse: source withContext: context ]
+!
+
 benchmarkJavaSyntaxC
     <setup: #setupJavaSyntax>
     <benchmark: 'Petit Java Parser - Standard'>
@@ -348,6 +426,34 @@
 
 !PPCBenchmark methodsFor:'setup & teardown'!
 
+setupExpressionGrammar
+    
+    parser := PPExpressionGrammar new.
+    context := PPCContext new.
+    context initializeFor: parser.
+    input := sources expressionSourcesMedium.
+!
+
+setupExpressionGrammarCompiled
+    
+    configuration := PPCConfiguration universal.
+    configuration arguments name: #PPCompiledExpressionGrammar.
+    parser := PPExpressionGrammar new compileWithConfiguration: configuration.
+    context := PPCContext new.
+    context initializeFor: parser.
+    input := sources expressionSourcesMedium.
+!
+
+setupExpressionGrammarTokenized
+    
+    configuration := PPCConfiguration LL1.
+    configuration arguments name: #PPTokenizedLL1ExpressionGrammar.
+    parser := PPLL1ExpressionGrammar new compileWithConfiguration: configuration.
+    context := PPCContext new.
+    context initializeFor: parser.
+    input := sources expressionSourcesMedium.
+!
+
 setupJavaSyntax
     
     parser := PPJavaSyntax new.
@@ -369,6 +475,34 @@
 "
 !
 
+setupLL1ExpressionGrammar
+    
+    parser := PPLL1ExpressionGrammar new.
+    context := PPCContext new.
+    context initializeFor: parser.
+    input := sources expressionSourcesBig.
+!
+
+setupLL1ExpressionGrammarCompiled
+    
+    configuration := PPCConfiguration universal.
+    configuration arguments name: #PPCompiledLL1ExpressionGrammar.
+    parser := PPLL1ExpressionGrammar new compileWithConfiguration: configuration.
+    context := PPCContext new.
+    context initializeFor: parser.
+    input := sources expressionSourcesBig.
+!
+
+setupLL1ExpressionGrammarTokenized
+    
+    configuration := PPCConfiguration universal.
+    configuration arguments name: #PPTokenizedLL1ExpressionGrammar.
+    parser := PPLL1ExpressionGrammar new compileWithConfiguration: configuration.
+    context := PPCContext new.
+    context initializeFor: parser.
+    input := sources expressionSourcesBig.
+!
+
 setupRBParser
     
     input := sources smalltalkSourcesBig.
@@ -428,6 +562,10 @@
     input := sources smalltalkSourcesBig.
 !
 
+teardownExpressionGrammarTokenized
+    parser class removeFromSystem.
+!
+
 teardownJavaSyntaxCompiled
     parser class removeFromSystem.
 "	
@@ -446,6 +584,10 @@
 "
 !
 
+teardownSmalltalkGrammarTokenized
+    parser class removeFromSystem.
+!
+
 teardownSmalltalkParserCompiled
     parser class removeFromSystem.
 "