Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 7ebd25ac536d248d499a3ce2acda963a > files > 4941

Macaulay2-1.3.1-8.fc15.i686.rpm

<?xml version="1.0" encoding="utf-8" ?>  <!-- for emacs: -*- coding: utf-8 -*- -->
<!-- Apache may like this line in the file .htaccess: AddCharset utf-8 .html -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"	 "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg-flat.dtd" >
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head><title>profile -- profile a function</title>
<link rel="stylesheet" type="text/css" href="../../../../Macaulay2/Style/doc.css"/>
</head>
<body>
<table class="buttons">
  <tr>
    <td><div><a href="_profile__Summary.html">next</a> | <a href="___Product__Order.html">previous</a> | <a href="_profile__Summary.html">forward</a> | <a href="___Product__Order.html">backward</a> | up | <a href="index.html">top</a> | <a href="master.html">index</a> | <a href="toc.html">toc</a> | <a href="http://www.math.uiuc.edu/Macaulay2/">Macaulay2 web site</a></div>

    </td>
  </tr>
</table>
<hr/>
<div><h1>profile -- profile a function</h1>
<div class="single"><h2>Description</h2>
<div><tt>f = profile f</tt> -- replace a global function <tt>f</tt> by a profiled version.<p/>
The new function is the same as the old one, except that when the new function is run, it will record the number of times it is called and the total execution time.  Use the command <a href="_profile__Summary.html" title="display profiling data">profileSummary</a> to display the data recorded so far.<table class="examples"><tr><td><pre>i1 : R = ZZ/31[x]

o1 = R

o1 : PolynomialRing</pre>
</td></tr>
<tr><td><pre>i2 : f = (x^110+1)*(x^13+1)

      123    110    13
o2 = x    + x    + x   + 1

o2 : R</pre>
</td></tr>
<tr><td><pre>i3 : time factor f
     -- used 0.016997 seconds

              2       2        2       2       2       4     3     2            4     3      2            4     3     2            10     8    6    4      2       10     8     6     4      2       10      8     6     4      2       10      8     6      4     2       10      8     6      4     2       10     8      6     4      2       10     8      6     4      2       10      8     6     4      2       10      8     6     4     2       10      8    6    4     2
o3 = (x + 1)(x  + 1)(x  - 15)(x  + 8)(x  + 4)(x  + 2)(x  + 9x  - 4x  + 9x + 1)(x  - 4x  + 11x  - 4x + 1)(x  - 6x  - 2x  - 6x + 1)(x   + 9x  - x  - x  - 10x  + 1)(x   - 5x  - 8x  - 4x  - 13x  + 1)(x   - 11x  - 8x  - 4x  + 11x  + 1)(x   + 13x  - 2x  + 15x  + 5x  + 1)(x   + 10x  - 2x  + 15x  - 9x  + 1)(x   - 9x  + 15x  - 2x  + 10x  + 1)(x   + 5x  + 15x  - 2x  + 13x  + 1)(x   + 11x  - 4x  - 8x  - 11x  + 1)(x   - 13x  - 4x  - 8x  - 5x  + 1)(x   - 10x  - x  - x  + 9x  + 1)

o3 : Expression of class Product</pre>
</td></tr>
<tr><td><pre>i4 : g = () -> factor f

o4 = g

o4 : FunctionClosure</pre>
</td></tr>
<tr><td><pre>i5 : g = profile g
--warning: function g redefined

o5 = g

o5 : FunctionClosure</pre>
</td></tr>
<tr><td><pre>i6 : h = profile("h", () -> factor f)

o6 = h

o6 : FunctionClosure</pre>
</td></tr>
<tr><td><pre>i7 : for i to 10 do (g();h();h())</pre>
</td></tr>
<tr><td><pre>i8 : profileSummary
g: 11 times, used .206968 seconds
h: 22 times, used .410939 seconds</pre>
</td></tr>
</table>
</div>
</div>
<div class="waystouse"><h2>Ways to use <tt>profile</tt> :</h2>
<ul><li>profile(Function)</li>
<li>profile(String,Function)</li>
</ul>
</div>
</div>
</body>
</html>