<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'>
hi, <BR>
&nbsp;<BR>
i would like to know the time taken to execute a certain task in python. i used time.time and time.clock and i see the time taken is different? what is the right method to use? <BR>
&nbsp;<BR>
import time<BR>
def testtime(num):<BR>&nbsp;&nbsp;&nbsp; start=time.time()<BR>&nbsp;&nbsp;&nbsp; #print start<BR>&nbsp;&nbsp;&nbsp; for n in range(num):<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #print n<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print time.time()-start<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>testtime(101) <BR>
<BR>start = time.clock()<BR>for x in range(101):<BR>&nbsp; y = x&nbsp; # do something<BR>end = time.clock()<BR>print "Time clock elapsed = ", end - start, "seconds"<BR>
&nbsp;<BR>
thanks<BR>
tcl<BR>
&nbsp;<BR>
&nbsp;<BR>                                               </body>
</html>