A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2006-June/065570.html below:

[Python-Dev] Python Benchmarks

[Python-Dev] Python BenchmarksTim Peters tim.peters at gmail.com
Sat Jun 3 15:43:38 CEST 2006
[Fredrik Lundh]
> .... but it's always the thread that runs when the timer interrupt
> arrives that gets the entire jiffy time.  for example, this script runs
> for ten seconds, usually without using any process time at all:
>
>      import time
>      for i in range(1000):
>          for i in range(1000):
>              i+i+i+i
>          time.sleep(0.005)
>
> while the same program, without the sleep, will run for a second or two,
> most of which is assigned to the process.

Nice example!  On my desktop box (WinXP, 3.4GHz), I had to make it
nastier to see it consume any "time" without the sleep:

import time
for i in range(1000):
    for i in range(10000): # 10x bigger
        i+i+i+i*(i+i+i+i) # more work
    time.sleep(0.005)
raw_input("done")

The raw_input is there so I can see Task Manager's idea of elapsed
"CPU Time" (sum of process "user time" and "kernel time") when it's
done.

Without the sleep, it gets charged 6 CPU seconds.  With the sleep, 0
CPU seconds.

But life would be more boring if people believed you the first time ;-)
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4