$> python
Python 2.6.6 (r266:84292, Sep 12 2011, 14:03:14)
[GCC 4.4.5 20110214 (Red Hat 4.4.5-6)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import time
>>> def tryit():
... tin=time.time()
... a="97757589545391667"
... for x in range(1,10000001):
... try:
... b=a
... except:
... pass
... tout=time.time()
... print tout-tin
...
>>> tryit()
1.29326200485
>>> tryit()
0.987454891205
>>> tryit()
0.976771116257
>>> tryit()
0.977509975433
>>> tryit()
1.36146092415
$> php -v
PHP 5.3.3 (cli) (built: May 3 2012 17:33:17)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
$> php -r '$in=microtime();$a = "97757589545391667";for ($x=0;$x++;$x<10000001) { $b=(int)$a;} $out=microtime();echo number_format($out-$in,8);'
0.00006000
$> php -r '$in=microtime();$a = "97757589545391667";for ($x=0;$x++;$x<10000001) { $b=(int)$a;} $out=microtime();echo number_format($out-$in,8);'
0.00006700
$> php -r '$in=microtime();$a = "97757589545391667";for ($x=0;$x++;$x<10000001) { $b=(int)$a;} $out=microtime();echo number_format($out-$in,8);'
0.00008900
$> php -r '$in=microtime();$a = "97757589545391667";for ($x=0;$x++;$x<10000001) { $b=(int)$a;} $out=microtime();echo number_format($out-$in,8);'
0.00006000
$> php -r '$in=microtime();$a = "97757589545391667";for ($x=0;$x++;$x<10000001) { $b=(int)$a;} $out=microtime();echo number_format($out-$in,8);'
0.00005900
$> php -r '$in=microtime();$a = "97757589545391667";for ($x=0;$x++;$x<10000001) { $b=(int)$a;} $out=microtime();echo number_format($out-$in,8);'
0.00006000
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.
Our community of experts have been thoroughly vetted for their expertise and industry experience.