On this page:
make-profile-point-factory
profile-point?
annotate-syn
profile-file
save-profile
run-with-profiling
load-profile
load-profile-look-up
load-profile-query-weight

2 API🔗ℹ

 (require pgmp) package: rackpgmp
 (require pgmp/api/exact)

This section describes the API provided by pgmp for meta-programmers to write their own profile-guided meta-programs.

procedure

(make-profile-point-factory prefix)

  (-> source-location? profile-point?)
  prefix : string?
Returns a function that, given a source-location? syn (such as a syntax? or srcloc?), generates a fresh profile point. The generated profile point will be based on prefix and syn to provide useful error messages.

procedure

(profile-point? expr)  boolean?

  expr : any/c
Return #t if expr is a profile points, and #f otherwise.

syntax

(annotate-syn profile-point template)

 
  profile-point : profile-point?
Like quasisyntax, but attaches profile-point to the syntax objects resulting from template.

procedure

(profile-file file-source)  path?

  file-source : (or/c source-location? path?  path-string?)
Generates a path? to the file represented by file-source, and appends ".profile" to it.

procedure

(save-profile file-source)  void?

  file-source : (or/c source-location? path? path-string?)
Saves the current profile execution counts to (profile-file file-source).

procedure

(run-with-profiling module)  void?

  module : module-path?
Instruments module to collect profiling information and runs it.

procedure

(load-profile file-source)

  
(-> (or/c syntax? profile-point?) (or/c natural-number/c #f))
(-> (or/c profile-point?) (or/c (real-in 0 1) #f))
  file-source : (or/c source-location? path? path-string?)
Loads the profile information (profile-file file-source) and returns two functions that can query that profile information.

The first function returns the exact execution count associated with a profile point, or #f if no profile information exists for that profile point.

The second function returns the profile weight associated with that profile point, or #f is no profile information exists for that profile point. A profile weight is the ratio of the exact execution count to the maximum execution count of any other profile point.

procedure

(load-profile-look-up file-source)

  (-> (or/c syntax? profile-point?) (or/c natural-number/c #f))
  file-source : (or/c source-location? path? path-string?)
Returns the first value returned by load-profile.

procedure

(load-profile-query-weight file-source)

  (-> (or/c syntax? profile-point?) (or/c natural-number/c #f))
  file-source : (or/c source-location? path? path-string?)
Returns the second value returned by load-profile.