Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A simple profiler that counts calls and records timing for grammar rules

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib Export via proto May 24, 2013
Octocat-spinner-32 t Make some tests May 23, 2013
Octocat-spinner-32 META.info Fix letter case in source-url April 26, 2012
Octocat-spinner-32 README.markdown Update README with correct code May 15, 2013
README.markdown

Grammar::Profiler::Simple

This module provides a simple profiler for Perl 6 gramamrs. 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.

This module exports two subroutines, each with 3 variants:

reset-timing()

Reset all time information collected since the start of the program or since the last call to reset-timing()

reset-timing($grammar)

Reset all time information only for the specified grammar.

reset-timing($grammar, $rule)

Reset all time information only for the specified rule within the specified grammar.

get-timing()

Retrieve the timing information collected so far or since the last call to reset-timing. Returned as a mult-level hash with the first level indexed by the name of the grammar and the second level indexed by the name of the rule within the grammar.

get-timing($grammar)

Retrieve the timing information collected for a particular grammar.

get-timing($grammar, $rule)

Retrieve the timing information collected for a particular rule within a particular grammar.

Timing information

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')} seconds";

Something went wrong with that request. Please try again.