/usr/share/doc/racket/contract-profile/index.html is in racket-doc 6.7-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"/><title>Contract Profiling</title><link rel="stylesheet" type="text/css" href="../scribble.css" title="default"/><link rel="stylesheet" type="text/css" href="../racket.css" title="default"/><link rel="stylesheet" type="text/css" href="../manual-style.css" title="default"/><link rel="stylesheet" type="text/css" href="../manual-racket.css" title="default"/><link rel="stylesheet" type="text/css" href="../doc-site.css" title="default"/><script type="text/javascript" src="../scribble-common.js"></script><script type="text/javascript" src="../manual-racket.js"></script><script type="text/javascript" src="../doc-site.js"></script><script type="text/javascript" src="../local-redirect/local-redirect.js"></script><script type="text/javascript" src="../local-redirect/local-user-redirect.js"></script><!--[if IE 6]><style type="text/css">.SIEHidden { overflow: hidden; }</style><![endif]--></head><body id="doc-racket-lang-org"><div class="tocset"><div class="tocview"><div class="tocviewlist tocviewlisttopspace"><div class="tocviewtitle"><table cellspacing="0" cellpadding="0"><tr><td style="width: 1em;">•</td><td></td><td><a href="" class="tocviewselflink" data-pltdoc="x">Contract Profiling</a></td></tr></table></div></div></div><div class="tocsub"><table class="tocsublist" cellspacing="0"><tr><td><span class="tocsublinknumber"></span><a href="#%28part._top%29" class="tocsubseclink" data-pltdoc="x">Contract Profiling</a></td></tr><tr><td><a href="#%28form._%28%28lib._contract-profile%2Fmain..rkt%29._contract-profile%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym">contract-<wbr></wbr>profile</span></a></td></tr><tr><td><a href="#%28def._%28%28lib._contract-profile%2Fmain..rkt%29._contract-profile-thunk%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym">contract-<wbr></wbr>profile-<wbr></wbr>thunk</span></a></td></tr></table></div></div><div class="maincolumn"><div class="main"><div class="versionbox"><span class="version">6.7</span></div><div class="navsettop"><span class="navleft"><form class="searchform"><input class="searchbox" style="color: #888;" type="text" value="...search manuals..." title="Enter a search string to search the manuals" onkeypress="return DoSearchKey(event, this, "6.7", "../");" onfocus="this.style.color="black"; this.style.textAlign="left"; if (this.value == "...search manuals...") this.value="";" onblur="if (this.value.match(/^ *$/)) { this.style.color="#888"; this.style.textAlign="center"; this.value="...search manuals..."; }"/></form> <a href="../index.html" title="up to the documentation top" data-pltdoc="x" onclick="return GotoPLTRoot("6.7");">top</a></span><span class="navright"> <span class="nonavigation">← prev</span> <a href="../index.html" title="up to the documentation top" data-pltdoc="x" onclick="return GotoPLTRoot("6.7");">up</a> <span class="nonavigation">next →</span></span> </div><h2 x-source-module="(lib "contract-profile/scribblings/contract-profile.scrbl")" x-source-pkg="contract-profile" x-part-tag=""top""><a name="(part._top)"></a><a name="(part._contract-profiling)"></a><a name="(mod-path._contract-profile)"></a>Contract Profiling</h2><p>This package provides support for profiling the execution of
<a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=guide&rel=contracts.html&version=6.7" class="Sq" data-pltdoc="x">Contracts</a>.</p><p>Contracts are a great mechanism for enforcing invariants and producing good
error messages, but they introduce run-time checking which may impose
significant posts. The goal of the contract profiler is to identify where these
costs are, and provide information to help control them.</p><p><a name="(idx._(gentag._0._(lib._contract-profile/scribblings/contract-profile..scrbl)))"></a>The simplest way to use this tool is to use the <span class="stt">raco contract-profile</span>
command, which takes a file name as argument, and runs the contract profiler on
the <span class="RktSym">main</span> submodule of that file (if it exists), or on the module
itself (if there is no <span class="RktSym">main</span> submodule).
The tool’s output is decribed below.</p><p><table cellspacing="0" cellpadding="0" class="defmodule"><tr><td align="left"><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=require.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._require%2529%2529&version=6.7" class="RktStxLink Sq" data-pltdoc="x">require</a></span><span class="stt"> </span><a href="" class="RktModLink" data-pltdoc="x"><span class="RktSym">contract-profile</span></a><span class="RktPn">)</span></td><td align="right"><span class="RpackageSpec"><span class="Smaller"> package:</span> <span class="stt">contract-profile</span></span></td></tr></table></p><p>In addition to using <span class="stt">raco contract-profile</span>, it is possible to invoke the
contract profiler programmatically. This allows for profiling particular
portions of programs, and for controlling the output.</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>syntax</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(form._((lib._contract-profile/main..rkt)._contract-profile))"></a><span title="Provided from: contract-profile | Package: contract-profile"><span class="RktSym"><span class="RktSymDef RktSym">contract-profile</span></span></span><span class="hspace"> </span><span class="RktVar">option</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="hspace"> </span><span class="RktVar">body</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">)</span></p></blockquote></td></tr><tr><td><span class="stt"> </span></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="specgrammar"><tr><td align="right" valign="baseline"><span class="RktVar">option</span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="center" valign="baseline">=</td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="RktPn">#:module-graph-file</span><span class="hspace"> </span><span class="RktVar">module-graph-file</span></td></tr><tr><td align="right" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="center" valign="baseline">|</td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="RktPn">#:boundary-view-file</span><span class="hspace"> </span><span class="RktVar">boundary-view-file</span></td></tr><tr><td align="right" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="center" valign="baseline">|</td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="RktPn">#:boundary-view-key-file</span><span class="hspace"> </span><span class="RktVar">boundary-view-key-file</span></td></tr></table></td></tr></table></blockquote></div><div class="SIntrapara">Produces a report of the performance costs related to contract checking in
<span class="RktVar">body</span> on standard output.</div></p><p>Specifically, displays the proportion of <span class="RktVar">body</span>’s running time that was
spent checking contracts and breaks that time down by contract, and then breaks
down the cost of each contract between the different contracted values that use
it.</p><p>Additional visualizations are available on-demand, controlled by keyword
arguments which specify their destination files. An argument of <span class="RktVal">#f</span>
(the default) disables that visualization.</p><ul><li><p><span style="font-style: italic">Module Graph View</span>:
Shows a graph of modules (nodes) and the contract boundaries (edges) between
them that were crossed while running <span class="RktVar">body</span>.</p><p>The weight on each contract boundary edge corresponds to the time spent
checking contracts applied at this boundary.
Modules written in Typed Racket are displayed in green and untyped modules
are displayed in red.</p><p>These graphs are rendered using Graphviz, and are only available if the
contract profiler can locate a Graphviz install.</p><p>When using <span class="stt">raco contract-profile</span>, controlled using the
<span class="stt">--module-graph-file</span> flag.</p></li><li><p><span style="font-style: italic">Boundary View</span>:
Shows a detailed view of how contract checking costs are spread out across
contracted functions, broken down by contract boundary.</p><p>Contracted functions are shown as rectangular nodes colored according to the
cost of checking their contracts.
Edges represent function calls that cross contract boundaries and cause
contracts to be applied. These edges are extracted from profiling
information, and therefore represent incomplete information. Because of this,
the contract profiler sometimes cannot determine the callers of contracted
functions.
Non-contracted functions that call contracted functions across a boundary are
shown as gray ellipsoid nodes. Nodes are clustered by module.
Each node reports its (non-contract-related) self time. In addition,
contracted function nodes list the contract boundaries the function
participates in, as well as the cost of checking the contracts associated
with each boundary. For space reasons, full contracts are not displayed on
the graph and are instead numbered. The mapping from numbers to contracts is
found in <span class="RktVar">boundary-view-key-file</span>.</p><p>These graphs are rendered using Graphviz, and are only available if the
contract profiler can locate a Graphviz install.</p><p>When using <span class="stt">raco contract-profile</span>, controlled using the
<span class="stt">--boundary-view-file</span> and <span class="stt">--boundary-view-key-file</span> flags.</p></li></ul><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><table cellspacing="0" cellpadding="0" class="prototype RForeground"><tr><td valign="top" colspan="3"><span class="RktPn">(</span><a name="(def._((lib._contract-profile/main..rkt)._contract-profile-thunk))"></a><span title="Provided from: contract-profile | Package: contract-profile"><span class="RktSym"><span class="RktSymDef RktSym">contract-profile-thunk</span></span></span></td><td valign="top"><span class="hspace"> </span></td></tr><tr><td valign="top"><span class="hspace"> </span></td><td valign="top"><span class="hspace"> </span></td><td valign="top"><span class="RktVar">thunk</span></td><td valign="top"><span class="hspace"> </span></td></tr><tr><td valign="top"><span class="hspace"> </span></td><td valign="top"><span class="hspace"> </span>[</td><td valign="top"><span class="RktPn">#:module-graph-file</span><span class="hspace"> </span><span class="RktVar">module-graph-file</span></td><td valign="top"><span class="hspace"> </span></td></tr><tr><td valign="top"><span class="hspace"> </span></td><td valign="top"><span class="hspace"> </span></td><td valign="top"><span class="RktPn">#:boundary-view-file</span><span class="hspace"> </span><span class="RktVar">boundary-view-file</span></td><td valign="top"><span class="hspace"> </span></td></tr><tr><td valign="top"><span class="hspace"> </span></td><td valign="top"><span class="hspace"> </span></td><td valign="top"><span class="RktPn">#:boundary-view-key-file</span><span class="hspace"> </span><span class="RktVar">boundary-view-key-file</span>]<span class="RktPn">)</span></td><td valign="top"><span class="hspace"> </span></td></tr></table></blockquote></td></tr><tr><td><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528form._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._any%2529%2529&version=6.7" class="RktStxLink Sq" data-pltdoc="x">any</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">thunk</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=function-contracts.html%23%2528form._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._-%7E3e%2529%2529&version=6.7" class="RktStxLink Sq" data-pltdoc="x"><span class="nobreak">-></span></a></span><span class="hspace"> </span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528form._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._any%2529%2529&version=6.7" class="RktStxLink Sq" data-pltdoc="x">any</a></span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">module-graph-file</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._or%252Fc%2529%2529&version=6.7" class="RktValLink Sq" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktSym">path-string</span><span class="hspace"> </span><span class="RktVal">#f</span><span class="RktPn">)</span><span class="hspace"> </span>=<span class="hspace"> </span><span class="RktVal">#f</span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">boundary-view-file</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._or%252Fc%2529%2529&version=6.7" class="RktValLink Sq" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktSym">path-string</span><span class="hspace"> </span><span class="RktVal">#f</span><span class="RktPn">)</span><span class="hspace"> </span>=<span class="hspace"> </span><span class="RktVal">#f</span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">boundary-view-key-file</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._or%252Fc%2529%2529&version=6.7" class="RktValLink Sq" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktSym">path-string</span><span class="hspace"> </span><span class="RktVal">#f</span><span class="RktPn">)</span><span class="hspace"> </span>=<span class="hspace"> </span><span class="RktVal">#f</span></td></tr></table></blockquote></div><div class="SIntrapara">Like <span class="RktSym">contract-profile</span>, but as a function which takes a thunk to
profile as argument.</div></p><p><div class="SIntrapara">Examples:</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=attaching-contracts-to-values.html%23%2528form._%2528%2528lib._racket%252Fcontract%252Fregion..rkt%2529._define%252Fcontract%2529%2529&version=6.7" class="RktStxLink Sq" data-pltdoc="x">define/contract</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">sum*</span><span class="hspace"> </span><span class="RktSym">numbers</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=function-contracts.html%23%2528form._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._-%7E3e%2529%2529&version=6.7" class="RktStxLink Sq" data-pltdoc="x"><span class="nobreak">-></span></a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._listof%2529%2529&version=6.7" class="RktValLink Sq" data-pltdoc="x">listof</a></span><span class="hspace"> </span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=number-types.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._integer%7E3f%2529%2529&version=6.7" class="RktValLink Sq" data-pltdoc="x">integer?</a></span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=number-types.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._integer%7E3f%2529%2529&version=6.7" class="RktValLink Sq" data-pltdoc="x">integer?</a></span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=for.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._for%252Ffold%2529%2529&version=6.7" class="RktStxLink Sq" data-pltdoc="x">for/fold</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">total</span><span class="hspace"> </span><span class="RktVal">0</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">n</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=sequences.html%23%2528def._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._in-list%2529%2529&version=6.7" class="RktValLink Sq" data-pltdoc="x">in-list</a></span><span class="hspace"> </span><span class="RktSym">numbers</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=generic-numbers.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._%252B%2529%2529&version=6.7" class="RktValLink Sq" data-pltdoc="x">+</a></span><span class="hspace"> </span><span class="RktSym">total</span><span class="hspace"> </span><span class="RktSym">n</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym">contract-profile</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">sum*</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">range</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=generic-numbers.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._expt%2529%2529&version=6.7" class="RktValLink Sq" data-pltdoc="x">expt</a></span><span class="hspace"> </span><span class="RktVal">10</span><span class="hspace"> </span><span class="RktVal">6</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td><p><span class="RktOut">Running time is 35.31% contracts</span></p></td></tr><tr><td><p><span class="RktOut">322/912 ms</span></p></td></tr><tr><td><p><span class="RktOut"></span></p></td></tr><tr><td><p><span class="RktOut">(-> (listof integer?) integer?)</span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut">322 ms</span></p></td></tr><tr><td><p><span class="RktOut">#<blame>:1:0</span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span></p></td></tr><tr><td><p><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut">sum* </span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut">322 ms</span></p></td></tr><tr><td><p><span class="RktOut"></span></p></td></tr></table></td></tr><tr><td><p><span class="RktRes">499999500000</span></p></td></tr></table></blockquote></div></p><p>The example shows that a large proportion of the call to <span class="RktSym">sum*</span>
with a list of 1 million integers is spent validating the input list.</p><p>Note that the contract profiler is unlikely to detect fast-running contracts
that trigger other, slower contract checks.
In the following example, there is a higher chance that the profiler
samples a <span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._listof%2529%2529&version=6.7" class="RktValLink Sq" data-pltdoc="x">listof</a></span><span class="stt"> </span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=number-types.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._integer%7E3f%2529%2529&version=6.7" class="RktValLink Sq" data-pltdoc="x">integer?</a></span><span class="RktPn">)</span> contract than the underlying
<span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fvector..rkt%2529._vectorof%2529%2529&version=6.7" class="RktValLink Sq" data-pltdoc="x">vectorof</a></span><span class="stt"> </span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._list%7E3f%2529%2529&version=6.7" class="RktValLink Sq" data-pltdoc="x">list?</a></span><span class="RktPn">)</span> contract.</p><p><div class="SIntrapara">Examples:</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=attaching-contracts-to-values.html%23%2528form._%2528%2528lib._racket%252Fcontract%252Fregion..rkt%2529._define%252Fcontract%2529%2529&version=6.7" class="RktStxLink Sq" data-pltdoc="x">define/contract</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">vector-max*</span><span class="hspace"> </span><span class="RktSym">vec-of-numbers</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=function-contracts.html%23%2528form._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._-%7E3e%2529%2529&version=6.7" class="RktStxLink Sq" data-pltdoc="x"><span class="nobreak">-></span></a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fvector..rkt%2529._vectorof%2529%2529&version=6.7" class="RktValLink Sq" data-pltdoc="x">vectorof</a></span><span class="hspace"> </span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._list%7E3f%2529%2529&version=6.7" class="RktValLink Sq" data-pltdoc="x">list?</a></span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=number-types.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._integer%7E3f%2529%2529&version=6.7" class="RktValLink Sq" data-pltdoc="x">integer?</a></span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=for.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._for%252Ffold%2529%2529&version=6.7" class="RktStxLink Sq" data-pltdoc="x">for/fold</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">total</span><span class="hspace"> </span><span class="RktVal">0</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">numbers</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=sequences.html%23%2528def._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._in-vector%2529%2529&version=6.7" class="RktValLink Sq" data-pltdoc="x">in-vector</a></span><span class="hspace"> </span><span class="RktSym">vec-of-numbers</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=generic-numbers.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._%252B%2529%2529&version=6.7" class="RktValLink Sq" data-pltdoc="x">+</a></span><span class="hspace"> </span><span class="RktSym">total</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">sum*</span><span class="hspace"> </span><span class="RktSym">numbers</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym">contract-profile</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">vector-max*</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=vectors.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._make-vector%2529%2529&version=6.7" class="RktValLink Sq" data-pltdoc="x">make-vector</a></span><span class="hspace"> </span><span class="RktVal">10</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">range</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=generic-numbers.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._expt%2529%2529&version=6.7" class="RktValLink Sq" data-pltdoc="x">expt</a></span><span class="hspace"> </span><span class="RktVal">10</span><span class="hspace"> </span><span class="RktVal">6</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td><p><span class="RktOut">Running time is 60.67% contracts</span></p></td></tr><tr><td><p><span class="RktOut">2160/3560 ms</span></p></td></tr><tr><td><p><span class="RktOut"></span></p></td></tr><tr><td><p><span class="RktOut">(-> (listof integer?) integer?)</span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut">1128 ms</span></p></td></tr><tr><td><p><span class="RktOut">#<blame>:1:0</span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span></p></td></tr><tr><td><p><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut">sum* </span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut">1128 ms</span></p></td></tr><tr><td><p><span class="RktOut"></span></p></td></tr><tr><td><p><span class="RktOut">(-> (vectorof (listof any/c)) integer?)</span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut">1032 ms</span></p></td></tr><tr><td><p><span class="RktOut">#<blame>:3:0</span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span></p></td></tr><tr><td><p><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut">vector-max*</span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut"></span><span class="hspace"> </span><span class="RktOut">1032 ms</span></p></td></tr><tr><td><p><span class="RktOut"></span></p></td></tr></table></td></tr><tr><td><p><span class="RktRes">4999995000000</span></p></td></tr></table></blockquote></div></p><div class="navsetbottom"><span class="navleft"><form class="searchform"><input class="searchbox" style="color: #888;" type="text" value="...search manuals..." title="Enter a search string to search the manuals" onkeypress="return DoSearchKey(event, this, "6.7", "../");" onfocus="this.style.color="black"; this.style.textAlign="left"; if (this.value == "...search manuals...") this.value="";" onblur="if (this.value.match(/^ *$/)) { this.style.color="#888"; this.style.textAlign="center"; this.value="...search manuals..."; }"/></form> <a href="../index.html" title="up to the documentation top" data-pltdoc="x" onclick="return GotoPLTRoot("6.7");">top</a></span><span class="navright"> <span class="nonavigation">← prev</span> <a href="../index.html" title="up to the documentation top" data-pltdoc="x" onclick="return GotoPLTRoot("6.7");">up</a> <span class="nonavigation">next →</span></span> </div></div></div><div id="contextindicator"> </div></body></html>
|