110 lines
4.9 KiB
HTML
110 lines
4.9 KiB
HTML
|
|
|
|
<!doctype html>
|
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
<title>Utilities — pyfundoc documentation</title>
|
|
<link rel="stylesheet" href="_static/bizstyle.css" type="text/css" />
|
|
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
|
<script type="text/javascript">
|
|
var DOCUMENTATION_OPTIONS = {
|
|
URL_ROOT: './',
|
|
VERSION: ' ',
|
|
COLLAPSE_INDEX: false,
|
|
FILE_SUFFIX: '.html',
|
|
HAS_SOURCE: true,
|
|
SOURCELINK_SUFFIX: '.txt'
|
|
};
|
|
</script>
|
|
<script type="text/javascript" src="_static/jquery.js"></script>
|
|
<script type="text/javascript" src="_static/underscore.js"></script>
|
|
<script type="text/javascript" src="_static/doctools.js"></script>
|
|
<script type="text/javascript" src="_static/bizstyle.js"></script>
|
|
<link rel="index" title="Index" href="genindex.html" />
|
|
<link rel="search" title="Search" href="search.html" />
|
|
<link rel="next" title="Coding standards" href="codingstandards.html" />
|
|
<link rel="prev" title="Technical an user documentation" href="documenting.html" />
|
|
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
|
<!--[if lt IE 9]>
|
|
<script type="text/javascript" src="_static/css3-mediaqueries.js"></script>
|
|
<![endif]-->
|
|
</head>
|
|
<body>
|
|
<div class="related" role="navigation" aria-label="related navigation">
|
|
<h3>Navigation</h3>
|
|
<ul>
|
|
<li class="right" style="margin-right: 10px">
|
|
<a href="genindex.html" title="General Index"
|
|
accesskey="I">index</a></li>
|
|
<li class="right" >
|
|
<a href="py-modindex.html" title="Python Module Index"
|
|
>modules</a> |</li>
|
|
<li class="right" >
|
|
<a href="codingstandards.html" title="Coding standards"
|
|
accesskey="N">next</a> |</li>
|
|
<li class="right" >
|
|
<a href="documenting.html" title="Technical an user documentation"
|
|
accesskey="P">previous</a> |</li>
|
|
<li class="nav-item nav-item-0"><a href="index.html">pyfundoc documentation</a> »</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<div class="document">
|
|
<div class="documentwrapper">
|
|
<div class="body" role="main">
|
|
|
|
<div class="section" id="utilities">
|
|
<h1>Utilities<a class="headerlink" href="#utilities" title="Permalink to this headline">¶</a></h1>
|
|
<div class="section" id="duration">
|
|
<h2>duration<a class="headerlink" href="#duration" title="Permalink to this headline">¶</a></h2>
|
|
<p>The <code class="xref py py-mod docutils literal"><span class="pre">timeit</span></code> module lets you measure the execution
|
|
time of small bits of Python code</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">timeit</span>
|
|
<span class="n">timeit</span><span class="o">.</span><span class="n">timeit</span><span class="p">(</span><span class="s1">'"-".join(str(n) for n in range(100))'</span><span class="p">,</span>
|
|
<span class="n">number</span><span class="o">=</span><span class="mi">10000</span><span class="p">)</span>
|
|
|
|
<span class="c1"># 0.3412662749997253</span>
|
|
|
|
<span class="n">timeit</span><span class="o">.</span><span class="n">timeit</span><span class="p">(</span><span class="s1">'"-".join([str(n) for n in range(100)])'</span><span class="p">,</span>
|
|
<span class="n">number</span><span class="o">=</span><span class="mi">10000</span><span class="p">)</span>
|
|
|
|
<span class="c1"># 0.2996307989997149</span>
|
|
|
|
<span class="n">timeit</span><span class="o">.</span><span class="n">timeit</span><span class="p">(</span><span class="s1">'"-".join(map(str, range(100)))'</span><span class="p">,</span>
|
|
<span class="n">number</span><span class="o">=</span><span class="mi">10000</span><span class="p">)</span>
|
|
|
|
<span class="c1"># 0.24581470699922647</span>
|
|
</pre></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="clearer"></div>
|
|
</div>
|
|
<div class="related" role="navigation" aria-label="related navigation">
|
|
<h3>Navigation</h3>
|
|
<ul>
|
|
<li class="right" style="margin-right: 10px">
|
|
<a href="genindex.html" title="General Index"
|
|
>index</a></li>
|
|
<li class="right" >
|
|
<a href="py-modindex.html" title="Python Module Index"
|
|
>modules</a> |</li>
|
|
<li class="right" >
|
|
<a href="codingstandards.html" title="Coding standards"
|
|
>next</a> |</li>
|
|
<li class="right" >
|
|
<a href="documenting.html" title="Technical an user documentation"
|
|
>previous</a> |</li>
|
|
<li class="nav-item nav-item-0"><a href="index.html">pyfundoc documentation</a> »</li>
|
|
</ul>
|
|
</div>
|
|
<div class="footer" role="contentinfo">
|
|
</div>
|
|
</body>
|
|
</html> |