NAME
Grammar::Profiler::Simple - Simple rule profiling for Raku grammars
SYNOPSIS
use Grammar::Profiler::Simple;
my grammar MyGrammar {
rule MyRule {
...
}
}
reset-timing;
MyGrammar.new.parse($string);
say "MyRule was called &get-timing(MyGrammar,MyRule)<calls> times";
say "The total time executing MyRule was &get-timing(MyGrammar,MyRule)<time> seconds";
DESCRIPTION
This module provides a simple profiler for Raku grammars. To enable profiling simply add
use Grammar::Profiler::Simple;
to your code. Any grammar in the lexical scope of the use
statement will automatically have profiling information collected when the grammar is used.
There are 2 bits of timing information collected: the number of times each rule was called and the cumulative time that was spent executing each rule. For example:
say "MyRule was called &get-timing(MyGrammar,MyRule)} times"; say "The total time executing MyRule was &get-timing(MyGrammar,MyRule)