Python Performance Testing Tool

Source: Internet
Author: User

I haven't written python for a while, and I have studied. Net in my spare time and helped my friends solve some problems. In this way, Python has not been touched for nearly two months. (* ^__ ^ *), This articleArticleIt is also written for. NET as an internal chain. Record it by the way.
PythonCommunityThere is a saying: "Python has its own battery ." Do not write the timing framework by yourself. Python 2.3 and later have a perfect timing tool called timeit. Example in diveinto

>>> Import timeit >>> T = timeit. timer ("soundex. soundex ('pilgrim ')",... "Import soundex") >>> T. timeit () 8.21683733547 >>> T. repeat (3, 2000000) [16.48319309109, 16.46128984923, 16.44203948912]

This method has limitations. Sometimes I just want to count the timing of a certain section of the method. At this time, it is more convenient to use time. Clock. Similar to stopwatch in. net

Import timen = 100000st = time. clock () V = ('abcd', 100, 1.0, ['pumayd', 100, none]) for I in xrange (n): exec (dumps (v )) print 'pickle' usage', time. clock ()-St

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.