<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://performiq.com/kb/index.php?action=history&amp;feed=atom&amp;title=Python_-_timers</id>
	<title>Python - timers - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://performiq.com/kb/index.php?action=history&amp;feed=atom&amp;title=Python_-_timers"/>
	<link rel="alternate" type="text/html" href="https://performiq.com/kb/index.php?title=Python_-_timers&amp;action=history"/>
	<updated>2026-05-18T12:40:00Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.37.1</generator>
	<entry>
		<id>https://performiq.com/kb/index.php?title=Python_-_timers&amp;diff=3322&amp;oldid=prev</id>
		<title>PeterHarding at 10:54, 18 October 2010</title>
		<link rel="alternate" type="text/html" href="https://performiq.com/kb/index.php?title=Python_-_timers&amp;diff=3322&amp;oldid=prev"/>
		<updated>2010-10-18T10:54:17Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 20:54, 18 October 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=Timers=&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=Timers=&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Also see: http://pleac.sourceforge.net/pleac_python/datesandtimes.html&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>PeterHarding</name></author>
	</entry>
	<entry>
		<id>https://performiq.com/kb/index.php?title=Python_-_timers&amp;diff=3321&amp;oldid=prev</id>
		<title>PeterHarding: Created page with &#039;=Timers=  &lt;pre&gt; #-----------------------------  # High Resolution Timers  t1 = time.clock() # Do Stuff Here t2 = time.clock() print t2 - t1  # 2.27236813618 # Accuracy will depen...&#039;</title>
		<link rel="alternate" type="text/html" href="https://performiq.com/kb/index.php?title=Python_-_timers&amp;diff=3321&amp;oldid=prev"/>
		<updated>2010-10-18T10:53:55Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;#039;=Timers=  &amp;lt;pre&amp;gt; #-----------------------------  # High Resolution Timers  t1 = time.clock() # Do Stuff Here t2 = time.clock() print t2 - t1  # 2.27236813618 # Accuracy will depen...&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;=Timers=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#----------------------------- &lt;br /&gt;
# High Resolution Timers&lt;br /&gt;
&lt;br /&gt;
t1 = time.clock()&lt;br /&gt;
# Do Stuff Here&lt;br /&gt;
t2 = time.clock()&lt;br /&gt;
print t2 - t1&lt;br /&gt;
&lt;br /&gt;
# 2.27236813618&lt;br /&gt;
# Accuracy will depend on platform and OS,&lt;br /&gt;
# but time.clock() uses the most accurate timer it can&lt;br /&gt;
&lt;br /&gt;
time.clock(); time.clock()&lt;br /&gt;
# 174485.51365466841&lt;br /&gt;
# 174485.55702610247&lt;br /&gt;
&lt;br /&gt;
#----------------------------- &lt;br /&gt;
# Also useful;&lt;br /&gt;
import timeit&lt;br /&gt;
code = &amp;#039;[x for x in range(10) if x % 2 == 0]&amp;#039;&lt;br /&gt;
eval(code)&lt;br /&gt;
# [0, 2, 4, 6, 8]&lt;br /&gt;
&lt;br /&gt;
t = timeit.Timer(code)&lt;br /&gt;
print &amp;quot;10,000 repeats of that code takes:&amp;quot;, t.timeit(10000), &amp;quot;seconds&amp;quot; &lt;br /&gt;
print &amp;quot;1,000,000 repeats of that code takes:&amp;quot;, t.timeit(), &amp;quot;seconds&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# 10,000 repeats of that code takes: 0.128238644856 seconds&lt;br /&gt;
# 1,000,000 repeats of that code takes:  12.5396490336 seconds&lt;br /&gt;
&lt;br /&gt;
#----------------------------- &lt;br /&gt;
import timeit&lt;br /&gt;
code = &amp;#039;import random; l = random.sample(xrange(10000000), 1000); l.sort()&amp;#039; &lt;br /&gt;
t = timeit.Timer(code)&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Create a list of a thousand random numbers. Sort the list. Repeated a thousand times.&amp;quot; &lt;br /&gt;
print &amp;quot;Average Time:&amp;quot;, t.timeit(1000) / 1000&lt;br /&gt;
# Time taken: 5.24391507859&lt;br /&gt;
&lt;br /&gt;
Short Sleeps&lt;br /&gt;
&lt;br /&gt;
#----------------------------- &lt;br /&gt;
# Short Sleeps&lt;br /&gt;
&lt;br /&gt;
seconds = 3.1&lt;br /&gt;
time.sleep(seconds)&lt;br /&gt;
print &amp;quot;boo&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Python]]&lt;br /&gt;
[[Category:Examples]]&lt;/div&gt;</summary>
		<author><name>PeterHarding</name></author>
	</entry>
</feed>