quetion about "+=" and "runtime"

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • gagaguy@gmail.com

    quetion about "+=" and "runtime"

    1.i saw "+=" in a program code,but i haven't see it before,neither can
    i find it in a cook,who can tell me the usage of "python0"

    2.how can i know how long does a program run?

  • Terry Reedy

    #2
    Re: quetion about "+=&quo t; and "runtime&q uot;


    <gagaguy@gmail. com> wrote in message
    news:1123123359 .768132.112990@ g47g2000cwa.goo glegroups.com.. .[color=blue]
    > 1.i saw "+=" in a program code,but i haven't see it before,neither can
    > i find it in a cook,who can tell me the usage of "python0"[/color]

    It probably is in the tutorial and certainly is in the reference manual.
    I don't understand "usage of 'python0'".
    [color=blue]
    > 2.how can i know how long does a program run?[/color]

    time module

    tjr



    Comment

    • gagaguy@gmail.com

      #3
      Re: quetion about &quot;+=&quo t; and &quot;runtime&q uot;

      1.i have look " += " up,but i can't find it.is it ofthen used?
      2.i saq a result like this in a web page:


      $ time python permute2.py 56789 3
      Got 120 items.
      Maximum at 87596 ,product 84000

      real 0m0.057s
      user 0m0.050s
      sys 0m0.000s

      $ time python permute3.py 56789 3
      Got 120 items.
      Maximum at 87596 ,product 84000

      real 0m0.040s
      user 0m0.030s
      sys 0m0.010s

      i wanna know how to call out this

      Comment

      • Robert Kern

        #4
        Re: quetion about &quot;+=&quo t; and &quot;runtime&q uot;

        gagaguy@gmail.c om wrote:[color=blue]
        > 1.i have look " += " up,but i can't find it.[/color]


        [color=blue]
        > is it ofthen used?[/color]

        Reasonably so.
        [color=blue]
        > 2.i saq a result like this in a web page:
        >
        >
        > $ time python permute2.py 56789 3
        > Got 120 items.
        > Maximum at 87596 ,product 84000
        >
        > real 0m0.057s
        > user 0m0.050s
        > sys 0m0.000s
        >
        > $ time python permute3.py 56789 3
        > Got 120 items.
        > Maximum at 87596 ,product 84000
        >
        > real 0m0.040s
        > user 0m0.030s
        > sys 0m0.010s
        >
        > i wanna know how to call out this[/color]

        As Terry said, look at the "time" module. Don't use the "time" program
        (a standard program on UNIX-like systems) unless you actually want to
        time the startup of the interpreter too rather than just the code itself.

        --
        Robert Kern
        rkern@ucsd.edu

        "In the fields of hell where the grass grows high
        Are the graves of dreams allowed to die."
        -- Richard Harter

        Comment

        Working...