215 time := [ input do: [ :source | parser parse: source withContext: context ]] timeToRun asMilliSeconds. |
215 time := [ input do: [ :source | parser parse: source withContext: context ]] timeToRun asMilliSeconds. |
216 |
216 |
217 self reportInput: input time: time name: 'Smalltalk Parser Compiled'. |
217 self reportInput: input time: time name: 'Smalltalk Parser Compiled'. |
218 ! ! |
218 ! ! |
219 |
219 |
|
220 !PPCBenchmark methodsFor:'benchmarks - expression grammar'! |
|
221 |
|
222 benchmarkExpressionGrammar |
|
223 | time | |
|
224 |
|
225 self setupExpressionGrammar. |
|
226 |
|
227 time := [ input do: [ :source | parser parse: source withContext: context ]] timeToRun asMilliSeconds. |
|
228 |
|
229 self reportInput: input time: time name: 'Expression Grammar'. |
|
230 ! |
|
231 |
|
232 benchmarkExpressionGrammarCompiled |
|
233 | time | |
|
234 |
|
235 self setupExpressionGrammarCompiled. |
|
236 |
|
237 time := [ input do: [ :source | parser parse: source withContext: context ]] timeToRun asMilliSeconds. |
|
238 |
|
239 self reportInput: input time: time name: 'Compiled Expression Grammar'. |
|
240 ! |
|
241 |
|
242 benchmarkExpressionGrammarTokenized |
|
243 | time | |
|
244 |
|
245 self setupExpressionGrammarTokenized. |
|
246 |
|
247 time := [ input do: [ :source | parser parse: source withContext: context ]] timeToRun asMilliSeconds. |
|
248 |
|
249 self reportInput: input time: time name: 'Tokenized Expression Grammar'. |
|
250 ! |
|
251 |
|
252 benchmarkLL1ExpressionGrammar |
|
253 | time | |
|
254 |
|
255 self setupLL1ExpressionGrammar. |
|
256 |
|
257 time := [ input do: [ :source | parser parse: source withContext: context ]] timeToRun asMilliSeconds. |
|
258 |
|
259 self reportInput: input time: time name: 'LL1 Expression Grammar'. |
|
260 ! |
|
261 |
|
262 benchmarkLL1ExpressionGrammarCompiled |
|
263 | time | |
|
264 |
|
265 self setupLL1ExpressionGrammarCompiled. |
|
266 |
|
267 time := [ input do: [ :source | parser parse: source withContext: context ]] timeToRun asMilliSeconds. |
|
268 |
|
269 self reportInput: input time: time name: 'Compiled LL1 Expression Grammar'. |
|
270 ! |
|
271 |
|
272 benchmarkLL1ExpressionGrammarTokenized |
|
273 | time | |
|
274 |
|
275 self setupLL1ExpressionGrammarTokenized. |
|
276 |
|
277 time := [ input do: [ :source | parser parse: source withContext: context ]] timeToRun asMilliSeconds. |
|
278 |
|
279 self reportInput: input time: time name: 'Tokenized LL1 Expression Grammar'. |
|
280 ! ! |
|
281 |
220 !PPCBenchmark methodsFor:'benchmarks - micro'! |
282 !PPCBenchmark methodsFor:'benchmarks - micro'! |
221 |
283 |
222 benchmarkAnyStar |
284 benchmarkAnyStar |
223 " |
285 " |
224 self measure: self anyStar on: sources petitParserPackage. |
286 self measure: self anyStar on: sources petitParserPackage. |
240 parser := (self tokenParser / #any asParser) star. |
302 parser := (self tokenParser / #any asParser) star. |
241 self measure: parser on: (sources changesSized: 1000*1000) name: #token. |
303 self measure: parser on: (sources changesSized: 1000*1000) name: #token. |
242 ! ! |
304 ! ! |
243 |
305 |
244 !PPCBenchmark methodsFor:'benchmarks-CalipeL'! |
306 !PPCBenchmark methodsFor:'benchmarks-CalipeL'! |
|
307 |
|
308 benchmarkExpressionGrammarC |
|
309 <setup: #setupExpressionGrammar> |
|
310 <benchmark: 'Petit Expression Grammar - Standard'> |
|
311 |
|
312 input do: [ :source | parser parse: source withContext: context ] |
|
313 ! |
|
314 |
|
315 benchmarkExpressionGrammarTokenizedC |
|
316 <setup: #setupExpressionGrammarTokenized> |
|
317 <teardown: #teardownExpressionGrammarTokenized> |
|
318 <benchmark: 'Petit Expression Grammar - Tokenized'> |
|
319 |
|
320 |
|
321 input do: [ :source | parser parse: source withContext: context ] |
|
322 ! |
245 |
323 |
246 benchmarkJavaSyntaxC |
324 benchmarkJavaSyntaxC |
247 <setup: #setupJavaSyntax> |
325 <setup: #setupJavaSyntax> |
248 <benchmark: 'Petit Java Parser - Standard'> |
326 <benchmark: 'Petit Java Parser - Standard'> |
249 |
327 |
352 ^ #letter asParser, (#letter asParser / #digit asParser) star trim |
430 ^ #letter asParser, (#letter asParser / #digit asParser) star trim |
353 ! ! |
431 ! ! |
354 |
432 |
355 !PPCBenchmark methodsFor:'setup & teardown'! |
433 !PPCBenchmark methodsFor:'setup & teardown'! |
356 |
434 |
|
435 setupExpressionGrammar |
|
436 |
|
437 parser := PPExpressionGrammar new. |
|
438 context := PPCContext new. |
|
439 context initializeFor: parser. |
|
440 input := sources expressionSourcesMedium. |
|
441 ! |
|
442 |
|
443 setupExpressionGrammarCompiled |
|
444 |
|
445 configuration := PPCConfiguration universal. |
|
446 configuration arguments name: #PPCompiledExpressionGrammar. |
|
447 parser := PPExpressionGrammar new compileWithConfiguration: configuration. |
|
448 context := PPCContext new. |
|
449 context initializeFor: parser. |
|
450 input := sources expressionSourcesMedium. |
|
451 ! |
|
452 |
|
453 setupExpressionGrammarTokenized |
|
454 |
|
455 configuration := PPCConfiguration LL1. |
|
456 configuration arguments name: #PPTokenizedLL1ExpressionGrammar. |
|
457 parser := PPLL1ExpressionGrammar new compileWithConfiguration: configuration. |
|
458 context := PPCContext new. |
|
459 context initializeFor: parser. |
|
460 input := sources expressionSourcesMedium. |
|
461 ! |
|
462 |
357 setupJavaSyntax |
463 setupJavaSyntax |
358 |
464 |
359 parser := PPJavaSyntax new. |
465 parser := PPJavaSyntax new. |
360 context := PPCContext new. |
466 context := PPCContext new. |
361 context initializeFor: parser. |
467 context initializeFor: parser. |
371 " |
477 " |
372 size := input inject: 0 into: [:r :e | r + e size ]. |
478 size := input inject: 0 into: [:r :e | r + e size ]. |
373 Transcript crShow: 'Compiled Grammar time: ', time asString. |
479 Transcript crShow: 'Compiled Grammar time: ', time asString. |
374 Transcript crShow: 'Time per character: ', (time / size * 1000.0) asString, ' microseconds'. |
480 Transcript crShow: 'Time per character: ', (time / size * 1000.0) asString, ' microseconds'. |
375 " |
481 " |
|
482 ! |
|
483 |
|
484 setupLL1ExpressionGrammar |
|
485 |
|
486 parser := PPLL1ExpressionGrammar new. |
|
487 context := PPCContext new. |
|
488 context initializeFor: parser. |
|
489 input := sources expressionSourcesBig. |
|
490 ! |
|
491 |
|
492 setupLL1ExpressionGrammarCompiled |
|
493 |
|
494 configuration := PPCConfiguration universal. |
|
495 configuration arguments name: #PPCompiledLL1ExpressionGrammar. |
|
496 parser := PPLL1ExpressionGrammar new compileWithConfiguration: configuration. |
|
497 context := PPCContext new. |
|
498 context initializeFor: parser. |
|
499 input := sources expressionSourcesBig. |
|
500 ! |
|
501 |
|
502 setupLL1ExpressionGrammarTokenized |
|
503 |
|
504 configuration := PPCConfiguration universal. |
|
505 configuration arguments name: #PPTokenizedLL1ExpressionGrammar. |
|
506 parser := PPLL1ExpressionGrammar new compileWithConfiguration: configuration. |
|
507 context := PPCContext new. |
|
508 context initializeFor: parser. |
|
509 input := sources expressionSourcesBig. |
376 ! |
510 ! |
377 |
511 |
378 setupRBParser |
512 setupRBParser |
379 |
513 |
380 input := sources smalltalkSourcesBig. |
514 input := sources smalltalkSourcesBig. |
432 context := PPCContext new. |
566 context := PPCContext new. |
433 context initializeFor: parser. |
567 context initializeFor: parser. |
434 input := sources smalltalkSourcesBig. |
568 input := sources smalltalkSourcesBig. |
435 ! |
569 ! |
436 |
570 |
|
571 teardownExpressionGrammarTokenized |
|
572 parser class removeFromSystem. |
|
573 ! |
|
574 |
437 teardownJavaSyntaxCompiled |
575 teardownJavaSyntaxCompiled |
438 parser class removeFromSystem. |
576 parser class removeFromSystem. |
439 " |
577 " |
440 size := input inject: 0 into: [:r :e | r + e size ]. |
578 size := input inject: 0 into: [:r :e | r + e size ]. |
441 Transcript crShow: 'Compiled Grammar time: ', time asString. |
579 Transcript crShow: 'Compiled Grammar time: ', time asString. |