鱼C论坛

 找回密码
 立即注册
查看: 2742|回复: 7

[已解决]计时器

[复制链接]
发表于 2015-11-24 11:10:02 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
有没有大神用PYthon写过  计时器。发个源代码学习学习
最佳答案
2015-12-26 12:46:53
Python is batteries included~
  1. #! /usr/bin/env python3

  2. """Tool for measuring execution time of small code snippets.

  3. This module avoids a number of common traps for measuring execution
  4. times.  See also Tim Peters' introduction to the Algorithms chapter in
  5. the Python Cookbook, published by O'Reilly.

  6. Library usage: see the Timer class.

  7. Command line usage:
  8.     python timeit.py [-n N] [-r N] [-s S] [-t] [-c] [-p] [-h] [--] [statement]

  9. Options:
  10.   -n/--number N: how many times to execute 'statement' (default: see below)
  11.   -r/--repeat N: how many times to repeat the timer (default 3)
  12.   -s/--setup S: statement to be executed once initially (default 'pass')
  13.   -p/--process: use time.process_time() (default is time.perf_counter())
  14.   -t/--time: use time.time() (deprecated)
  15.   -c/--clock: use time.clock() (deprecated)
  16.   -v/--verbose: print raw timing results; repeat for more digits precision
  17.   -h/--help: print this usage message and exit
  18.   --: separate options from statement, use when statement starts with -
  19.   statement: statement to be timed (default 'pass')

  20. A multi-line statement may be given by specifying each line as a
  21. separate argument; indented lines are possible by enclosing an
  22. argument in quotes and using leading spaces.  Multiple -s options are
  23. treated similarly.

  24. If -n is not given, a suitable number of loops is calculated by trying
  25. successive powers of 10 until the total time is at least 0.2 seconds.

  26. Note: there is a certain baseline overhead associated with executing a
  27. pass statement.  It differs between versions.  The code here doesn't try
  28. to hide it, but you should be aware of it.  The baseline overhead can be
  29. measured by invoking the program without arguments.

  30. Classes:

  31.     Timer

  32. Functions:

  33.     timeit(string, string) -> float
  34.     repeat(string, string) -> list
  35.     default_timer() -> float

  36. """

  37. import gc
  38. import sys
  39. import time
  40. import itertools

  41. __all__ = ["Timer", "timeit", "repeat", "default_timer"]

  42. dummy_src_name = "<timeit-src>"
  43. default_number = 1000000
  44. default_repeat = 3
  45. default_timer = time.perf_counter

  46. # Don't change the indentation of the template; the reindent() calls
  47. # in Timer.__init__() depend on setup being indented 4 spaces and stmt
  48. # being indented 8 spaces.
  49. template = """
  50. def inner(_it, _timer):
  51.     {setup}
  52.     _t0 = _timer()
  53.     for _i in _it:
  54.         {stmt}
  55.     _t1 = _timer()
  56.     return _t1 - _t0
  57. """

  58. def reindent(src, indent):
  59.     """Helper to reindent a multi-line statement."""
  60.     return src.replace("\n", "\n" + " "*indent)

  61. def _template_func(setup, func):
  62.     """Create a timer function. Used if the "statement" is a callable."""
  63.     def inner(_it, _timer, _func=func):
  64.         setup()
  65.         _t0 = _timer()
  66.         for _i in _it:
  67.             _func()
  68.         _t1 = _timer()
  69.         return _t1 - _t0
  70.     return inner

  71. class Timer:
  72.     """Class for timing execution speed of small code snippets.

  73.     The constructor takes a statement to be timed, an additional
  74.     statement used for setup, and a timer function.  Both statements
  75.     default to 'pass'; the timer function is platform-dependent (see
  76.     module doc string).

  77.     To measure the execution time of the first statement, use the
  78.     timeit() method.  The repeat() method is a convenience to call
  79.     timeit() multiple times and return a list of results.

  80.     The statements may contain newlines, as long as they don't contain
  81.     multi-line string literals.
  82.     """

  83.     def __init__(self, stmt="pass", setup="pass", timer=default_timer):
  84.         """Constructor.  See class doc string."""
  85.         self.timer = timer
  86.         ns = {}
  87.         if isinstance(stmt, str):
  88.             # Check that the code can be compiled outside a function
  89.             if isinstance(setup, str):
  90.                 compile(setup, dummy_src_name, "exec")
  91.                 compile(setup + '\n' + stmt, dummy_src_name, "exec")
  92.             else:
  93.                 compile(stmt, dummy_src_name, "exec")
  94.             stmt = reindent(stmt, 8)
  95.             if isinstance(setup, str):
  96.                 setup = reindent(setup, 4)
  97.                 src = template.format(stmt=stmt, setup=setup)
  98.             elif callable(setup):
  99.                 src = template.format(stmt=stmt, setup='_setup()')
  100.                 ns['_setup'] = setup
  101.             else:
  102.                 raise ValueError("setup is neither a string nor callable")
  103.             self.src = src # Save for traceback display
  104.             code = compile(src, dummy_src_name, "exec")
  105.             exec(code, globals(), ns)
  106.             self.inner = ns["inner"]
  107.         elif callable(stmt):
  108.             self.src = None
  109.             if isinstance(setup, str):
  110.                 _setup = setup
  111.                 def setup():
  112.                     exec(_setup, globals(), ns)
  113.             elif not callable(setup):
  114.                 raise ValueError("setup is neither a string nor callable")
  115.             self.inner = _template_func(setup, stmt)
  116.         else:
  117.             raise ValueError("stmt is neither a string nor callable")

  118.     def print_exc(self, file=None):
  119.         """Helper to print a traceback from the timed code.

  120.         Typical use:

  121.             t = Timer(...)       # outside the try/except
  122.             try:
  123.                 t.timeit(...)    # or t.repeat(...)
  124.             except:
  125.                 t.print_exc()

  126.         The advantage over the standard traceback is that source lines
  127.         in the compiled template will be displayed.

  128.         The optional file argument directs where the traceback is
  129.         sent; it defaults to sys.stderr.
  130.         """
  131.         import linecache, traceback
  132.         if self.src is not None:
  133.             linecache.cache[dummy_src_name] = (len(self.src),
  134.                                                None,
  135.                                                self.src.split("\n"),
  136.                                                dummy_src_name)
  137.         # else the source is already stored somewhere else

  138.         traceback.print_exc(file=file)

  139.     def timeit(self, number=default_number):
  140.         """Time 'number' executions of the main statement.

  141.         To be precise, this executes the setup statement once, and
  142.         then returns the time it takes to execute the main statement
  143.         a number of times, as a float measured in seconds.  The
  144.         argument is the number of times through the loop, defaulting
  145.         to one million.  The main statement, the setup statement and
  146.         the timer function to be used are passed to the constructor.
  147.         """
  148.         it = itertools.repeat(None, number)
  149.         gcold = gc.isenabled()
  150.         gc.disable()
  151.         try:
  152.             timing = self.inner(it, self.timer)
  153.         finally:
  154.             if gcold:
  155.                 gc.enable()
  156.         return timing

  157.     def repeat(self, repeat=default_repeat, number=default_number):
  158.         """Call timeit() a few times.

  159.         This is a convenience function that calls the timeit()
  160.         repeatedly, returning a list of results.  The first argument
  161.         specifies how many times to call timeit(), defaulting to 3;
  162.         the second argument specifies the timer argument, defaulting
  163.         to one million.

  164.         Note: it's tempting to calculate mean and standard deviation
  165.         from the result vector and report these.  However, this is not
  166.         very useful.  In a typical case, the lowest value gives a
  167.         lower bound for how fast your machine can run the given code
  168.         snippet; higher values in the result vector are typically not
  169.         caused by variability in Python's speed, but by other
  170.         processes interfering with your timing accuracy.  So the min()
  171.         of the result is probably the only number you should be
  172.         interested in.  After that, you should look at the entire
  173.         vector and apply common sense rather than statistics.
  174.         """
  175.         r = []
  176.         for i in range(repeat):
  177.             t = self.timeit(number)
  178.             r.append(t)
  179.         return r

  180. def timeit(stmt="pass", setup="pass", timer=default_timer,
  181.            number=default_number):
  182.     """Convenience function to create Timer object and call timeit method."""
  183.     return Timer(stmt, setup, timer).timeit(number)

  184. def repeat(stmt="pass", setup="pass", timer=default_timer,
  185.            repeat=default_repeat, number=default_number):
  186.     """Convenience function to create Timer object and call repeat method."""
  187.     return Timer(stmt, setup, timer).repeat(repeat, number)

  188. def main(args=None, *, _wrap_timer=None):
  189.     """Main program, used when run as a script.

  190.     The optional 'args' argument specifies the command line to be parsed,
  191.     defaulting to sys.argv[1:].

  192.     The return value is an exit code to be passed to sys.exit(); it
  193.     may be None to indicate success.

  194.     When an exception happens during timing, a traceback is printed to
  195.     stderr and the return value is 1.  Exceptions at other times
  196.     (including the template compilation) are not caught.

  197.     '_wrap_timer' is an internal interface used for unit testing.  If it
  198.     is not None, it must be a callable that accepts a timer function
  199.     and returns another timer function (used for unit testing).
  200.     """
  201.     if args is None:
  202.         args = sys.argv[1:]
  203.     import getopt
  204.     try:
  205.         opts, args = getopt.getopt(args, "n:s:r:tcpvh",
  206.                                    ["number=", "setup=", "repeat=",
  207.                                     "time", "clock", "process",
  208.                                     "verbose", "help"])
  209.     except getopt.error as err:
  210.         print(err)
  211.         print("use -h/--help for command line help")
  212.         return 2
  213.     timer = default_timer
  214.     stmt = "\n".join(args) or "pass"
  215.     number = 0 # auto-determine
  216.     setup = []
  217.     repeat = default_repeat
  218.     verbose = 0
  219.     precision = 3
  220.     for o, a in opts:
  221.         if o in ("-n", "--number"):
  222.             number = int(a)
  223.         if o in ("-s", "--setup"):
  224.             setup.append(a)
  225.         if o in ("-r", "--repeat"):
  226.             repeat = int(a)
  227.             if repeat <= 0:
  228.                 repeat = 1
  229.         if o in ("-t", "--time"):
  230.             timer = time.time
  231.         if o in ("-c", "--clock"):
  232.             timer = time.clock
  233.         if o in ("-p", "--process"):
  234.             timer = time.process_time
  235.         if o in ("-v", "--verbose"):
  236.             if verbose:
  237.                 precision += 1
  238.             verbose += 1
  239.         if o in ("-h", "--help"):
  240.             print(__doc__, end=' ')
  241.             return 0
  242.     setup = "\n".join(setup) or "pass"
  243.     # Include the current directory, so that local imports work (sys.path
  244.     # contains the directory of this script, rather than the current
  245.     # directory)
  246.     import os
  247.     sys.path.insert(0, os.curdir)
  248.     if _wrap_timer is not None:
  249.         timer = _wrap_timer(timer)
  250.     t = Timer(stmt, setup, timer)
  251.     if number == 0:
  252.         # determine number so that 0.2 <= total time < 2.0
  253.         for i in range(1, 10):
  254.             number = 10**i
  255.             try:
  256.                 x = t.timeit(number)
  257.             except:
  258.                 t.print_exc()
  259.                 return 1
  260.             if verbose:
  261.                 print("%d loops -> %.*g secs" % (number, precision, x))
  262.             if x >= 0.2:
  263.                 break
  264.     try:
  265.         r = t.repeat(repeat, number)
  266.     except:
  267.         t.print_exc()
  268.         return 1
  269.     best = min(r)
  270.     if verbose:
  271.         print("raw times:", " ".join(["%.*g" % (precision, x) for x in r]))
  272.     print("%d loops," % number, end=' ')
  273.     usec = best * 1e6 / number
  274.     if usec < 1000:
  275.         print("best of %d: %.*g usec per loop" % (repeat, precision, usec))
  276.     else:
  277.         msec = usec / 1000
  278.         if msec < 1000:
  279.             print("best of %d: %.*g msec per loop" % (repeat, precision, msec))
  280.         else:
  281.             sec = msec / 1000
  282.             print("best of %d: %.*g sec per loop" % (repeat, precision, sec))
  283.     return None

  284. if __name__ == "__main__":
  285.     sys.exit(main())
复制代码
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2015-12-26 09:47:29 | 显示全部楼层

回帖奖励 +5 鱼币

帮暖贴,顺便赚钱学习
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2015-12-26 12:46:53 | 显示全部楼层    本楼为最佳答案   
Python is batteries included~
  1. #! /usr/bin/env python3

  2. """Tool for measuring execution time of small code snippets.

  3. This module avoids a number of common traps for measuring execution
  4. times.  See also Tim Peters' introduction to the Algorithms chapter in
  5. the Python Cookbook, published by O'Reilly.

  6. Library usage: see the Timer class.

  7. Command line usage:
  8.     python timeit.py [-n N] [-r N] [-s S] [-t] [-c] [-p] [-h] [--] [statement]

  9. Options:
  10.   -n/--number N: how many times to execute 'statement' (default: see below)
  11.   -r/--repeat N: how many times to repeat the timer (default 3)
  12.   -s/--setup S: statement to be executed once initially (default 'pass')
  13.   -p/--process: use time.process_time() (default is time.perf_counter())
  14.   -t/--time: use time.time() (deprecated)
  15.   -c/--clock: use time.clock() (deprecated)
  16.   -v/--verbose: print raw timing results; repeat for more digits precision
  17.   -h/--help: print this usage message and exit
  18.   --: separate options from statement, use when statement starts with -
  19.   statement: statement to be timed (default 'pass')

  20. A multi-line statement may be given by specifying each line as a
  21. separate argument; indented lines are possible by enclosing an
  22. argument in quotes and using leading spaces.  Multiple -s options are
  23. treated similarly.

  24. If -n is not given, a suitable number of loops is calculated by trying
  25. successive powers of 10 until the total time is at least 0.2 seconds.

  26. Note: there is a certain baseline overhead associated with executing a
  27. pass statement.  It differs between versions.  The code here doesn't try
  28. to hide it, but you should be aware of it.  The baseline overhead can be
  29. measured by invoking the program without arguments.

  30. Classes:

  31.     Timer

  32. Functions:

  33.     timeit(string, string) -> float
  34.     repeat(string, string) -> list
  35.     default_timer() -> float

  36. """

  37. import gc
  38. import sys
  39. import time
  40. import itertools

  41. __all__ = ["Timer", "timeit", "repeat", "default_timer"]

  42. dummy_src_name = "<timeit-src>"
  43. default_number = 1000000
  44. default_repeat = 3
  45. default_timer = time.perf_counter

  46. # Don't change the indentation of the template; the reindent() calls
  47. # in Timer.__init__() depend on setup being indented 4 spaces and stmt
  48. # being indented 8 spaces.
  49. template = """
  50. def inner(_it, _timer):
  51.     {setup}
  52.     _t0 = _timer()
  53.     for _i in _it:
  54.         {stmt}
  55.     _t1 = _timer()
  56.     return _t1 - _t0
  57. """

  58. def reindent(src, indent):
  59.     """Helper to reindent a multi-line statement."""
  60.     return src.replace("\n", "\n" + " "*indent)

  61. def _template_func(setup, func):
  62.     """Create a timer function. Used if the "statement" is a callable."""
  63.     def inner(_it, _timer, _func=func):
  64.         setup()
  65.         _t0 = _timer()
  66.         for _i in _it:
  67.             _func()
  68.         _t1 = _timer()
  69.         return _t1 - _t0
  70.     return inner

  71. class Timer:
  72.     """Class for timing execution speed of small code snippets.

  73.     The constructor takes a statement to be timed, an additional
  74.     statement used for setup, and a timer function.  Both statements
  75.     default to 'pass'; the timer function is platform-dependent (see
  76.     module doc string).

  77.     To measure the execution time of the first statement, use the
  78.     timeit() method.  The repeat() method is a convenience to call
  79.     timeit() multiple times and return a list of results.

  80.     The statements may contain newlines, as long as they don't contain
  81.     multi-line string literals.
  82.     """

  83.     def __init__(self, stmt="pass", setup="pass", timer=default_timer):
  84.         """Constructor.  See class doc string."""
  85.         self.timer = timer
  86.         ns = {}
  87.         if isinstance(stmt, str):
  88.             # Check that the code can be compiled outside a function
  89.             if isinstance(setup, str):
  90.                 compile(setup, dummy_src_name, "exec")
  91.                 compile(setup + '\n' + stmt, dummy_src_name, "exec")
  92.             else:
  93.                 compile(stmt, dummy_src_name, "exec")
  94.             stmt = reindent(stmt, 8)
  95.             if isinstance(setup, str):
  96.                 setup = reindent(setup, 4)
  97.                 src = template.format(stmt=stmt, setup=setup)
  98.             elif callable(setup):
  99.                 src = template.format(stmt=stmt, setup='_setup()')
  100.                 ns['_setup'] = setup
  101.             else:
  102.                 raise ValueError("setup is neither a string nor callable")
  103.             self.src = src # Save for traceback display
  104.             code = compile(src, dummy_src_name, "exec")
  105.             exec(code, globals(), ns)
  106.             self.inner = ns["inner"]
  107.         elif callable(stmt):
  108.             self.src = None
  109.             if isinstance(setup, str):
  110.                 _setup = setup
  111.                 def setup():
  112.                     exec(_setup, globals(), ns)
  113.             elif not callable(setup):
  114.                 raise ValueError("setup is neither a string nor callable")
  115.             self.inner = _template_func(setup, stmt)
  116.         else:
  117.             raise ValueError("stmt is neither a string nor callable")

  118.     def print_exc(self, file=None):
  119.         """Helper to print a traceback from the timed code.

  120.         Typical use:

  121.             t = Timer(...)       # outside the try/except
  122.             try:
  123.                 t.timeit(...)    # or t.repeat(...)
  124.             except:
  125.                 t.print_exc()

  126.         The advantage over the standard traceback is that source lines
  127.         in the compiled template will be displayed.

  128.         The optional file argument directs where the traceback is
  129.         sent; it defaults to sys.stderr.
  130.         """
  131.         import linecache, traceback
  132.         if self.src is not None:
  133.             linecache.cache[dummy_src_name] = (len(self.src),
  134.                                                None,
  135.                                                self.src.split("\n"),
  136.                                                dummy_src_name)
  137.         # else the source is already stored somewhere else

  138.         traceback.print_exc(file=file)

  139.     def timeit(self, number=default_number):
  140.         """Time 'number' executions of the main statement.

  141.         To be precise, this executes the setup statement once, and
  142.         then returns the time it takes to execute the main statement
  143.         a number of times, as a float measured in seconds.  The
  144.         argument is the number of times through the loop, defaulting
  145.         to one million.  The main statement, the setup statement and
  146.         the timer function to be used are passed to the constructor.
  147.         """
  148.         it = itertools.repeat(None, number)
  149.         gcold = gc.isenabled()
  150.         gc.disable()
  151.         try:
  152.             timing = self.inner(it, self.timer)
  153.         finally:
  154.             if gcold:
  155.                 gc.enable()
  156.         return timing

  157.     def repeat(self, repeat=default_repeat, number=default_number):
  158.         """Call timeit() a few times.

  159.         This is a convenience function that calls the timeit()
  160.         repeatedly, returning a list of results.  The first argument
  161.         specifies how many times to call timeit(), defaulting to 3;
  162.         the second argument specifies the timer argument, defaulting
  163.         to one million.

  164.         Note: it's tempting to calculate mean and standard deviation
  165.         from the result vector and report these.  However, this is not
  166.         very useful.  In a typical case, the lowest value gives a
  167.         lower bound for how fast your machine can run the given code
  168.         snippet; higher values in the result vector are typically not
  169.         caused by variability in Python's speed, but by other
  170.         processes interfering with your timing accuracy.  So the min()
  171.         of the result is probably the only number you should be
  172.         interested in.  After that, you should look at the entire
  173.         vector and apply common sense rather than statistics.
  174.         """
  175.         r = []
  176.         for i in range(repeat):
  177.             t = self.timeit(number)
  178.             r.append(t)
  179.         return r

  180. def timeit(stmt="pass", setup="pass", timer=default_timer,
  181.            number=default_number):
  182.     """Convenience function to create Timer object and call timeit method."""
  183.     return Timer(stmt, setup, timer).timeit(number)

  184. def repeat(stmt="pass", setup="pass", timer=default_timer,
  185.            repeat=default_repeat, number=default_number):
  186.     """Convenience function to create Timer object and call repeat method."""
  187.     return Timer(stmt, setup, timer).repeat(repeat, number)

  188. def main(args=None, *, _wrap_timer=None):
  189.     """Main program, used when run as a script.

  190.     The optional 'args' argument specifies the command line to be parsed,
  191.     defaulting to sys.argv[1:].

  192.     The return value is an exit code to be passed to sys.exit(); it
  193.     may be None to indicate success.

  194.     When an exception happens during timing, a traceback is printed to
  195.     stderr and the return value is 1.  Exceptions at other times
  196.     (including the template compilation) are not caught.

  197.     '_wrap_timer' is an internal interface used for unit testing.  If it
  198.     is not None, it must be a callable that accepts a timer function
  199.     and returns another timer function (used for unit testing).
  200.     """
  201.     if args is None:
  202.         args = sys.argv[1:]
  203.     import getopt
  204.     try:
  205.         opts, args = getopt.getopt(args, "n:s:r:tcpvh",
  206.                                    ["number=", "setup=", "repeat=",
  207.                                     "time", "clock", "process",
  208.                                     "verbose", "help"])
  209.     except getopt.error as err:
  210.         print(err)
  211.         print("use -h/--help for command line help")
  212.         return 2
  213.     timer = default_timer
  214.     stmt = "\n".join(args) or "pass"
  215.     number = 0 # auto-determine
  216.     setup = []
  217.     repeat = default_repeat
  218.     verbose = 0
  219.     precision = 3
  220.     for o, a in opts:
  221.         if o in ("-n", "--number"):
  222.             number = int(a)
  223.         if o in ("-s", "--setup"):
  224.             setup.append(a)
  225.         if o in ("-r", "--repeat"):
  226.             repeat = int(a)
  227.             if repeat <= 0:
  228.                 repeat = 1
  229.         if o in ("-t", "--time"):
  230.             timer = time.time
  231.         if o in ("-c", "--clock"):
  232.             timer = time.clock
  233.         if o in ("-p", "--process"):
  234.             timer = time.process_time
  235.         if o in ("-v", "--verbose"):
  236.             if verbose:
  237.                 precision += 1
  238.             verbose += 1
  239.         if o in ("-h", "--help"):
  240.             print(__doc__, end=' ')
  241.             return 0
  242.     setup = "\n".join(setup) or "pass"
  243.     # Include the current directory, so that local imports work (sys.path
  244.     # contains the directory of this script, rather than the current
  245.     # directory)
  246.     import os
  247.     sys.path.insert(0, os.curdir)
  248.     if _wrap_timer is not None:
  249.         timer = _wrap_timer(timer)
  250.     t = Timer(stmt, setup, timer)
  251.     if number == 0:
  252.         # determine number so that 0.2 <= total time < 2.0
  253.         for i in range(1, 10):
  254.             number = 10**i
  255.             try:
  256.                 x = t.timeit(number)
  257.             except:
  258.                 t.print_exc()
  259.                 return 1
  260.             if verbose:
  261.                 print("%d loops -> %.*g secs" % (number, precision, x))
  262.             if x >= 0.2:
  263.                 break
  264.     try:
  265.         r = t.repeat(repeat, number)
  266.     except:
  267.         t.print_exc()
  268.         return 1
  269.     best = min(r)
  270.     if verbose:
  271.         print("raw times:", " ".join(["%.*g" % (precision, x) for x in r]))
  272.     print("%d loops," % number, end=' ')
  273.     usec = best * 1e6 / number
  274.     if usec < 1000:
  275.         print("best of %d: %.*g usec per loop" % (repeat, precision, usec))
  276.     else:
  277.         msec = usec / 1000
  278.         if msec < 1000:
  279.             print("best of %d: %.*g msec per loop" % (repeat, precision, msec))
  280.         else:
  281.             sec = msec / 1000
  282.             print("best of %d: %.*g sec per loop" % (repeat, precision, sec))
  283.     return None

  284. if __name__ == "__main__":
  285.     sys.exit(main())
复制代码
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2015-12-26 13:29:35 | 显示全部楼层
帮暖贴,顺便赚钱学习
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2015-12-26 18:38:39 | 显示全部楼层
hldh214 发表于 2015-12-26 12:46
Python is batteries included~

  这个怎么用???
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2015-12-26 18:52:39 | 显示全部楼层

在idle里面import timeit
接着help(timeit)
即可
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2017-4-6 09:45:07 | 显示全部楼层
学习了,正需要呢
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2017-11-1 15:29:00 | 显示全部楼层
学习了
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-3-29 15:21

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表