compiler/benchmarks/PPCBenchmark.st
changeset 462 89464ab03518
parent 460 87a3d30ab570
child 465 f729f6cd3c76
equal deleted inserted replaced
461:5986bf6d7d60 462:89464ab03518
    48     PPCBenchmark run: #benchmarkRBParserC
    48     PPCBenchmark run: #benchmarkRBParserC
    49     "
    49     "
    50 !
    50 !
    51 
    51 
    52 spy: benchmark
    52 spy: benchmark
    53     ^ (BenchmarkInstance class:self selector:benchmark) spy
    53     | benchmarkInstanceClass |
       
    54 
       
    55     benchmarkInstanceClass := Smalltalk at: #BenchmarkInstance.
       
    56     benchmarkInstanceClass isNil ifTrue:[
       
    57         self error: 'CalipeL is not loaded.'
       
    58     ].   
       
    59 
       
    60     ^ (benchmarkInstanceClass class:self selector:benchmark) spy
    54 
    61 
    55     "Created: / 11-05-2015 / 16:31:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    62     "Created: / 11-05-2015 / 16:31:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    63     "Modified: / 16-05-2015 / 19:19:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    56 ! !
    64 ! !
    57 
    65 
    58 !PPCBenchmark methodsFor:'benchmark support'!
    66 !PPCBenchmark methodsFor:'benchmark support'!
    59 
    67 
    60 compile: value
    68 compile: value
   367     
   375     
   368     
   376     
   369     input do: [ :source | parser parse: source withContext: context ]
   377     input do: [ :source | parser parse: source withContext: context ]
   370 !
   378 !
   371 
   379 
       
   380 benchmarkSmalltalkNoopParserCompiledC
       
   381     <setup: #setupSmalltalkNoopParserCompiled>
       
   382     <teardown: #teardownSmalltalkNoopParserCompiled>
       
   383     <benchmark: 'Petit Smalltalk Parser (noop)- Compiled'>
       
   384     
       
   385     input do: [ :source | parser parse: source withContext: context ]
       
   386 
       
   387     "Created: / 16-05-2015 / 09:45:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   388 !
       
   389 
       
   390 benchmarkSmalltalkNoopParserTokenizedC
       
   391     <setup: #setupSmalltalkNoopParserTokenized>
       
   392     <teardown: #teardownSmalltalkNoopParserTokenized>
       
   393     <benchmark: 'Petit Smalltalk Parser (noop) - Tokenized'>
       
   394     
       
   395     input do: [ :source | parser parse: source withContext: context ]
       
   396 
       
   397     "Created: / 16-05-2015 / 09:46:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   398 !
       
   399 
   372 benchmarkSmalltalkParserC
   400 benchmarkSmalltalkParserC
   373     <setup: #setupSmalltalkParser>
   401     <setup: #setupSmalltalkParser>
   374     <benchmark: 'Petit Smalltalk Parser - Standard'>
   402     <benchmark: 'Petit Smalltalk Parser - Standard'>
   375     
   403     
   376     input do: [ :source | parser parse: source withContext: context ]
   404     input do: [ :source | parser parse: source withContext: context ]
   381     <teardown: #teardownSmalltalkParserCompiled>
   409     <teardown: #teardownSmalltalkParserCompiled>
   382     <benchmark: 'Petit Smalltalk Parser - Compiled'>
   410     <benchmark: 'Petit Smalltalk Parser - Compiled'>
   383     
   411     
   384     input do: [ :source | parser parse: source withContext: context ]
   412     input do: [ :source | parser parse: source withContext: context ]
   385     
   413     
       
   414 !
       
   415 
       
   416 benchmarkSmalltalkParserTokenizedC
       
   417     <setup: #setupSmalltalkParserTokenized>
       
   418     <teardown: #teardownSmalltalkParserTokenized>
       
   419     <benchmark: 'Petit Smalltalk Parser - Tokenized'>
       
   420     
       
   421     input do: [ :source | parser parse: source withContext: context ]
       
   422 
       
   423     "Created: / 16-05-2015 / 09:45:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   386 ! !
   424 ! !
   387 
   425 
   388 !PPCBenchmark methodsFor:'intitialization'!
   426 !PPCBenchmark methodsFor:'intitialization'!
   389 
   427 
   390 createContext
   428 createContext
   540     context := PPCContext new.
   578     context := PPCContext new.
   541     context initializeFor: parser.
   579     context initializeFor: parser.
   542     input := sources smalltalkSourcesBig.
   580     input := sources smalltalkSourcesBig.
   543 !
   581 !
   544 
   582 
       
   583 setupSmalltalkNoopParserCompiled
       
   584 
       
   585     configuration := PPCConfiguration universal.
       
   586     parser := PPCSmalltalkNoopParser new compileWithConfiguration: configuration.
       
   587     context := PPCContext new.
       
   588     context initializeFor: parser.
       
   589     input := sources smalltalkSourcesBig.
       
   590 
       
   591     "Created: / 16-05-2015 / 09:44:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   592 !
       
   593 
       
   594 setupSmalltalkNoopParserTokenized
       
   595 
       
   596     configuration := PPCConfiguration LL1.
       
   597     parser := PPCSmalltalkNoopParser new compileWithConfiguration: configuration.
       
   598     context := PPCContext new.
       
   599     context initializeFor: parser.
       
   600     input := sources smalltalkSourcesBig.
       
   601 
       
   602     "Created: / 16-05-2015 / 09:44:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   603 !
       
   604 
   545 setupSmalltalkParser
   605 setupSmalltalkParser
   546     
   606     
   547     parser := PPSmalltalkParser new.
   607     parser := PPSmalltalkParser new.
   548     context := PPCContext new.
   608     context := PPCContext new.
   549     context initializeFor: parser.
   609     context initializeFor: parser.
   599 "
   659 "
   600 
   660 
   601     "Created: / 11-05-2015 / 16:33:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   661     "Created: / 11-05-2015 / 16:33:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   602 !
   662 !
   603 
   663 
       
   664 teardownSmalltalkNoopParserCompiled
       
   665     parser class removeFromSystem.
       
   666 "       
       
   667     size := input inject: 0 into: [:r :e | r + e size  ].
       
   668     Transcript crShow: 'Compiled Grammar time: ', time asString.
       
   669     Transcript crShow: 'Time per character: ', (time / size * 1000.0) asString, ' microseconds'.
       
   670 "
       
   671 
       
   672     "Created: / 16-05-2015 / 09:44:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   673 !
       
   674 
       
   675 teardownSmalltalkNoopParserTokenized
       
   676     parser class removeFromSystem.
       
   677 "       
       
   678     size := input inject: 0 into: [:r :e | r + e size  ].
       
   679     Transcript crShow: 'Compiled Grammar time: ', time asString.
       
   680     Transcript crShow: 'Time per character: ', (time / size * 1000.0) asString, ' microseconds'.
       
   681 "
       
   682 
       
   683     "Created: / 16-05-2015 / 09:44:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   684 !
       
   685 
   604 teardownSmalltalkParserCompiled
   686 teardownSmalltalkParserCompiled
   605     parser class removeFromSystem.
   687     parser class removeFromSystem.
   606 "	
   688 "	
   607     size := input inject: 0 into: [:r :e | r + e size  ].
   689     size := input inject: 0 into: [:r :e | r + e size  ].
   608     Transcript crShow: 'Compiled Grammar time: ', time asString.
   690     Transcript crShow: 'Compiled Grammar time: ', time asString.
   609     Transcript crShow: 'Time per character: ', (time / size * 1000.0) asString, ' microseconds'.
   691     Transcript crShow: 'Time per character: ', (time / size * 1000.0) asString, ' microseconds'.
   610 "
   692 "
       
   693 !
       
   694 
       
   695 teardownSmalltalkParserTokenized
       
   696     parser class removeFromSystem.
       
   697 "       
       
   698     size := input inject: 0 into: [:r :e | r + e size  ].
       
   699     Transcript crShow: 'Compiled Grammar time: ', time asString.
       
   700     Transcript crShow: 'Time per character: ', (time / size * 1000.0) asString, ' microseconds'.
       
   701 "
       
   702 
       
   703     "Created: / 16-05-2015 / 09:47:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   611 ! !
   704 ! !
   612 
   705 
   613 !PPCBenchmark class methodsFor:'documentation'!
   706 !PPCBenchmark class methodsFor:'documentation'!
   614 
   707 
   615 version_HG
   708 version_HG