Why is it faster the second time ?

Discussion in 'Python' started by jalanb3, Jan 23, 2009.

  1. jalanb3

    jalanb3 Guest

    Hello the group,

    I am wondering why doctests run slower the first time.
    In the transcript below "try" is a script which finds and runs
    doctests in the current directory. It also shows how long it takes to
    run these tests.

    I added a new test which searches recursively for files given a path,
    and it took (approx) 3 seconds to run. But all subsequent runs take
    less than half a second.

    Am I right in thinking that the extra time on the first run is the
    time it takes to compile .py -> .pyc ?

    Transcript follows

    $ try paths.test

    try ./paths.test; 10 tests passed in 3 seconds
    10 tests passed, 0 failed, in 3 seconds

    $ try paths.test

    try ./paths.test; 10 tests passed very quickly
    10 tests passed, 0 failed, in 0 seconds

    $ try paths.test

    try ./paths.test; 10 tests passed very quickly
    10 tests passed, 0 failed, in 0 seconds

    --
    Alan
     
    jalanb3, Jan 23, 2009
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mr. SweatyFinger

    why why why why why

    Mr. SweatyFinger, Nov 28, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    938
    Mark Rae
    Dec 21, 2006
  2. Mr. SweatyFinger
    Replies:
    2
    Views:
    2,137
    Smokey Grindel
    Dec 2, 2006
  3. David Segall
    Replies:
    2
    Views:
    457
    Thomas Kellerer
    Jan 2, 2007
  4. http://links.i6networks.com

    Why '' Is Matched First Time, Not Second Time

    http://links.i6networks.com, Aug 21, 2004, in forum: Perl Misc
    Replies:
    10
    Views:
    175
    Sherm Pendley
    Aug 22, 2004
  5. yelipolok
    Replies:
    4
    Views:
    282
    John W. Krahn
    Jan 27, 2010
Loading...

Share This Page