Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 50 lines (29 sloc) 1.567 kB
ae50fe0 @perlpilot Record the grammar that the info came from
authored
1 # Grammar::Profiler::Simple
2 This module provides a simple profiler for Perl 6 gramamrs. To enable
3 profiling simply add
4
5 use Grammar::Profiler::Simple;
6
7 to your code. Any grammar in the lexical scope of the use statement
8 will automatically have profiling information collected when the
9 grammar is used.
10
595b405 @perlpilot Updates
authored
11 This module exports two subroutines, each with 3 variants:
ae50fe0 @perlpilot Record the grammar that the info came from
authored
12
595b405 @perlpilot Updates
authored
13 ### `reset-timing()`
ae50fe0 @perlpilot Record the grammar that the info came from
authored
14
595b405 @perlpilot Updates
authored
15 Reset all time information collected since the start of the program or since the last call to
16 `reset-timing()`
17
18 ### `reset-timing($grammar)`
19
20 Reset all time information only for the specified grammar.
21
22 ### `reset-timing($grammar, $rule)`
23
24 Reset all time information only for the specified rule within the specified grammar.
25
26 ### `get-timing()`
27
28 Retrieve the timing information collected so far or since the last call
29 to `reset-timing`. Returned as a mult-level hash with the first level
30 indexed by the name of the grammar and the second level indexed by the
31 name of the rule within the grammar.
32
33 ### `get-timing($grammar)`
34
35 Retrieve the timing information collected for a particular grammar.
36
37 ### `get-timing($grammar, $rule)`
38
39 Retrieve the timing information collected for a particular rule within a particular grammar.
40
41 ## Timing information
42
43 There are 2 bits of timing information collected: the number of times each rule was called
44 and the cumulative time that was spent executing each rule. For example
45
39fddfb @perlpilot Update README with correct code
authored
46 say "MyRule was called {get-timing('MyGrammar','MyRule')<calls>} times";
47 say "The total time executing MyRule was {get-timing('MyGrammar','MyRule')<time>} seconds";
ae50fe0 @perlpilot Record the grammar that the info came from
authored
48
49
Something went wrong with that request. Please try again.