209 time := [ input do: [ :source | parser parse: source withContext: context ]] timeToRun asMilliSeconds. |
209 time := [ input do: [ :source | parser parse: source withContext: context ]] timeToRun asMilliSeconds. |
210 |
210 |
211 self reportInput: input time: time name: 'Smalltalk Parser Compiled'. |
211 self reportInput: input time: time name: 'Smalltalk Parser Compiled'. |
212 ! ! |
212 ! ! |
213 |
213 |
|
214 !PPCBenchmark methodsFor:'benchmarks - expression grammar'! |
|
215 |
|
216 benchmarkExpressionGrammar |
|
217 | time | |
|
218 |
|
219 self setupExpressionGrammar. |
|
220 |
|
221 time := [ input do: [ :source | parser parse: source withContext: context ]] timeToRun asMilliSeconds. |
|
222 |
|
223 self reportInput: input time: time name: 'Expression Grammar'. |
|
224 ! |
|
225 |
|
226 benchmarkExpressionGrammarCompiled |
|
227 | time | |
|
228 |
|
229 self setupExpressionGrammarCompiled. |
|
230 |
|
231 time := [ input do: [ :source | parser parse: source withContext: context ]] timeToRun asMilliSeconds. |
|
232 |
|
233 self reportInput: input time: time name: 'Compiled Expression Grammar'. |
|
234 ! |
|
235 |
|
236 benchmarkExpressionGrammarTokenized |
|
237 | time | |
|
238 |
|
239 self setupExpressionGrammarTokenized. |
|
240 |
|
241 time := [ input do: [ :source | parser parse: source withContext: context ]] timeToRun asMilliSeconds. |
|
242 |
|
243 self reportInput: input time: time name: 'Tokenized Expression Grammar'. |
|
244 ! |
|
245 |
|
246 benchmarkLL1ExpressionGrammar |
|
247 | time | |
|
248 |
|
249 self setupLL1ExpressionGrammar. |
|
250 |
|
251 time := [ input do: [ :source | parser parse: source withContext: context ]] timeToRun asMilliSeconds. |
|
252 |
|
253 self reportInput: input time: time name: 'LL1 Expression Grammar'. |
|
254 ! |
|
255 |
|
256 benchmarkLL1ExpressionGrammarCompiled |
|
257 | time | |
|
258 |
|
259 self setupLL1ExpressionGrammarCompiled. |
|
260 |
|
261 time := [ input do: [ :source | parser parse: source withContext: context ]] timeToRun asMilliSeconds. |
|
262 |
|
263 self reportInput: input time: time name: 'Compiled LL1 Expression Grammar'. |
|
264 ! |
|
265 |
|
266 benchmarkLL1ExpressionGrammarTokenized |
|
267 | time | |
|
268 |
|
269 self setupLL1ExpressionGrammarTokenized. |
|
270 |
|
271 time := [ input do: [ :source | parser parse: source withContext: context ]] timeToRun asMilliSeconds. |
|
272 |
|
273 self reportInput: input time: time name: 'Tokenized LL1 Expression Grammar'. |
|
274 ! ! |
|
275 |
214 !PPCBenchmark methodsFor:'benchmarks - micro'! |
276 !PPCBenchmark methodsFor:'benchmarks - micro'! |
215 |
277 |
216 benchmarkAnyStar |
278 benchmarkAnyStar |
217 " |
279 " |
218 self measure: self anyStar on: sources petitParserPackage. |
280 self measure: self anyStar on: sources petitParserPackage. |
234 parser := (self tokenParser / #any asParser) star. |
296 parser := (self tokenParser / #any asParser) star. |
235 self measure: parser on: (sources changesSized: 1000*1000) name: #token. |
297 self measure: parser on: (sources changesSized: 1000*1000) name: #token. |
236 ! ! |
298 ! ! |
237 |
299 |
238 !PPCBenchmark methodsFor:'benchmarks-CalipeL'! |
300 !PPCBenchmark methodsFor:'benchmarks-CalipeL'! |
|
301 |
|
302 benchmarkExpressionGrammarC |
|
303 <setup: #setupExpressionGrammar> |
|
304 <benchmark: 'Petit Expression Grammar - Standard'> |
|
305 |
|
306 input do: [ :source | parser parse: source withContext: context ] |
|
307 ! |
|
308 |
|
309 benchmarkExpressionGrammarTokenizedC |
|
310 <setup: #setupExpressionGrammarTokenized> |
|
311 <teardown: #teardownExpressionGrammarTokenized> |
|
312 <benchmark: 'Petit Expression Grammar - Tokenized'> |
|
313 |
|
314 |
|
315 input do: [ :source | parser parse: source withContext: context ] |
|
316 ! |
239 |
317 |
240 benchmarkJavaSyntaxC |
318 benchmarkJavaSyntaxC |
241 <setup: #setupJavaSyntax> |
319 <setup: #setupJavaSyntax> |
242 <benchmark: 'Petit Java Parser - Standard'> |
320 <benchmark: 'Petit Java Parser - Standard'> |
243 |
321 |
346 ^ #letter asParser, (#letter asParser / #digit asParser) star trim |
424 ^ #letter asParser, (#letter asParser / #digit asParser) star trim |
347 ! ! |
425 ! ! |
348 |
426 |
349 !PPCBenchmark methodsFor:'setup & teardown'! |
427 !PPCBenchmark methodsFor:'setup & teardown'! |
350 |
428 |
|
429 setupExpressionGrammar |
|
430 |
|
431 parser := PPExpressionGrammar new. |
|
432 context := PPCContext new. |
|
433 context initializeFor: parser. |
|
434 input := sources expressionSourcesMedium. |
|
435 ! |
|
436 |
|
437 setupExpressionGrammarCompiled |
|
438 |
|
439 configuration := PPCConfiguration universal. |
|
440 configuration arguments name: #PPCompiledExpressionGrammar. |
|
441 parser := PPExpressionGrammar new compileWithConfiguration: configuration. |
|
442 context := PPCContext new. |
|
443 context initializeFor: parser. |
|
444 input := sources expressionSourcesMedium. |
|
445 ! |
|
446 |
|
447 setupExpressionGrammarTokenized |
|
448 |
|
449 configuration := PPCConfiguration LL1. |
|
450 configuration arguments name: #PPTokenizedLL1ExpressionGrammar. |
|
451 parser := PPLL1ExpressionGrammar new compileWithConfiguration: configuration. |
|
452 context := PPCContext new. |
|
453 context initializeFor: parser. |
|
454 input := sources expressionSourcesMedium. |
|
455 ! |
|
456 |
351 setupJavaSyntax |
457 setupJavaSyntax |
352 |
458 |
353 parser := PPJavaSyntax new. |
459 parser := PPJavaSyntax new. |
354 context := PPCContext new. |
460 context := PPCContext new. |
355 context initializeFor: parser. |
461 context initializeFor: parser. |
367 Transcript crShow: 'Compiled Grammar time: ', time asString. |
473 Transcript crShow: 'Compiled Grammar time: ', time asString. |
368 Transcript crShow: 'Time per character: ', (time / size * 1000.0) asString, ' microseconds'. |
474 Transcript crShow: 'Time per character: ', (time / size * 1000.0) asString, ' microseconds'. |
369 " |
475 " |
370 ! |
476 ! |
371 |
477 |
|
478 setupLL1ExpressionGrammar |
|
479 |
|
480 parser := PPLL1ExpressionGrammar new. |
|
481 context := PPCContext new. |
|
482 context initializeFor: parser. |
|
483 input := sources expressionSourcesBig. |
|
484 ! |
|
485 |
|
486 setupLL1ExpressionGrammarCompiled |
|
487 |
|
488 configuration := PPCConfiguration universal. |
|
489 configuration arguments name: #PPCompiledLL1ExpressionGrammar. |
|
490 parser := PPLL1ExpressionGrammar new compileWithConfiguration: configuration. |
|
491 context := PPCContext new. |
|
492 context initializeFor: parser. |
|
493 input := sources expressionSourcesBig. |
|
494 ! |
|
495 |
|
496 setupLL1ExpressionGrammarTokenized |
|
497 |
|
498 configuration := PPCConfiguration universal. |
|
499 configuration arguments name: #PPTokenizedLL1ExpressionGrammar. |
|
500 parser := PPLL1ExpressionGrammar new compileWithConfiguration: configuration. |
|
501 context := PPCContext new. |
|
502 context initializeFor: parser. |
|
503 input := sources expressionSourcesBig. |
|
504 ! |
|
505 |
372 setupRBParser |
506 setupRBParser |
373 |
507 |
374 input := sources smalltalkSourcesBig. |
508 input := sources smalltalkSourcesBig. |
375 ! |
509 ! |
376 |
510 |
426 context := PPCContext new. |
560 context := PPCContext new. |
427 context initializeFor: parser. |
561 context initializeFor: parser. |
428 input := sources smalltalkSourcesBig. |
562 input := sources smalltalkSourcesBig. |
429 ! |
563 ! |
430 |
564 |
|
565 teardownExpressionGrammarTokenized |
|
566 parser class removeFromSystem. |
|
567 ! |
|
568 |
431 teardownJavaSyntaxCompiled |
569 teardownJavaSyntaxCompiled |
432 parser class removeFromSystem. |
570 parser class removeFromSystem. |
433 " |
571 " |
434 size := input inject: 0 into: [:r :e | r + e size ]. |
572 size := input inject: 0 into: [:r :e | r + e size ]. |
435 Transcript crShow: 'Compiled Grammar time: ', time asString. |
573 Transcript crShow: 'Compiled Grammar time: ', time asString. |
444 Transcript crShow: 'Compiled Grammar time: ', time asString. |
582 Transcript crShow: 'Compiled Grammar time: ', time asString. |
445 Transcript crShow: 'Time per character: ', (time / size * 1000.0) asString, ' microseconds'. |
583 Transcript crShow: 'Time per character: ', (time / size * 1000.0) asString, ' microseconds'. |
446 " |
584 " |
447 ! |
585 ! |
448 |
586 |
|
587 teardownSmalltalkGrammarTokenized |
|
588 parser class removeFromSystem. |
|
589 ! |
|
590 |
449 teardownSmalltalkParserCompiled |
591 teardownSmalltalkParserCompiled |
450 parser class removeFromSystem. |
592 parser class removeFromSystem. |
451 " |
593 " |
452 size := input inject: 0 into: [:r :e | r + e size ]. |
594 size := input inject: 0 into: [:r :e | r + e size ]. |
453 Transcript crShow: 'Compiled Grammar time: ', time asString. |
595 Transcript crShow: 'Compiled Grammar time: ', time asString. |