Python--33 like a geek to think

Source: Internet
Author: User
Tags deprecated

Python comes with a battery

Battery: Python standard library

The Python standard library contains the modules required for general tasks

Python Documentation

timeit.__doc__

timeid__all__
timeit.__file__

Dir (Timeit)

Help (Timeit)

>>>ImportTimeit>>>Print(Timeit.__doc__) Tool formeasuring execution time of small code snippets. This module avoids a number of common traps formeasuring executiontimes. See also Tim Peters'Introduction to the algorithms chapter inThe Python Cookbook, published by O'Reilly.Library Usage:see the Timerclass. Command line Usage:python timeit.py [N-N] [-R N] [-S] [-t] [-c] [-p] [-h] [--] [statement]options:-n/--number N:how many times to execute'Statement'(Default:see below)-r/--repeat N:how many times to repeat the timer (default 3)  -s/--setup s:statement to be executed once initially (default'Pass'). Execution time of this setup statement isNot timed. -p/--process:use time.process_time () (Default istime.perf_counter ())-t/--time:use time.time () (deprecated)-c/--clock:use time.clock () (deprecated)-v/--verbose:PrintRaw timing results; Repeat forMore digits Precision-u/--unit:set The output Time unit (USEC, msec,orsec)-h/--help:PrintThis usage message andExit--: Separate options fromStatement, use if statement starts with-statement:statement to be timed (default'Pass') A Multi-Line statement is given by specifying each line as aseparate argument; indented lines is possible by enclosing an ArgumentinchQuotes andUsing leading spaces. Multiple-s Options aretreated similarly. If-N is  notGiven, a suitable number of loops iscalculated by tryingsuccessive powers ofTen until the total time isAt least 0.2seconds. Note:there isa certain baseline overhead associated with executing aPassStatement.  It differs between versions. The code here doesn'T Tryto hide it, and you should is aware of it. The baseline overhead can bemeasured by invoking the program without arguments. Classes:TimerFunctions:timeit (String, String)-float Repeat (string, string)-list Default_timer ()-float>>>dir (timeit) ['Timer','__all__','__builtins__','__cached__','__doc__','__file__','__loader__','__name__','__package__','__spec__','_globals','Default_number','default_repeat','Default_timer','Dummy_src_name','GC','Itertools','Main','reindent','Repeat','SYS','Template',' Time','Timeit']>>> Timeit.__all__['Timer','Timeit','Repeat','Default_timer']>>> fromTimeitImport*>>>Timer<class 'Timeit. Timer'>>>>ImportTimeit>>> Timeit.__file__'/usr/lib64/python3.6/timeit.py'>>> Help (Timeit)

Python--33 like a geek to think

Related Article

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.