Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #58849

Code with random module faster on the vm than the vm host...

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <pascalbit@hotmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.011
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'subject:module': 0.09; 'runs': 0.10; 'python': 0.11; '2.7': 0.14; 'random': 0.14; 'windows': 0.15; '(1,': 0.16; 'subject:random': 0.16; 'vmware': 0.16; 'win7': 0.16; 'bit': 0.19; 'import': 0.22; 'print': 0.22; 'this?': 0.23; 'header:User-Agent:1': 0.23; 'received:65.55.116': 0.24; 'subject:Code': 0.24; 'code:': 0.26; 'code': 0.31; 'received:10.0.0': 0.31; 'clock': 0.31; 'running': 0.33; 'subject:the': 0.34; 'subject:with': 0.35; 'version': 0.36; 'received:10.0': 0.36; 'seconds': 0.37; 'received:10': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'times': 0.62; 'faster...': 0.84; 'seconds!': 0.84
X-TMN [FMHsObKeyBfNBfNImm2DLwAcThqweB87]
X-Originating-Email [pascalbit@hotmail.com]
Date Fri, 8 Nov 2013 18:48:04 +0100
From Pascal Bit <pascalbit@hotmail.com>
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0
MIME-Version 1.0
To python-list@python.org
Subject Code with random module faster on the vm than the vm host...
Content-Type text/plain; charset="ISO-8859-1"; format=flowed
Content-Transfer-Encoding 7bit
X-OriginalArrivalTime 08 Nov 2013 17:48:10.0647 (UTC) FILETIME=[B0A4E270:01CEDCAA]
X-Mailman-Approved-At Fri, 08 Nov 2013 21:21:23 +0100
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2249.1383942084.18130.python-list@python.org> (permalink)
Lines 27
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1383942084 news.xs4all.nl 15935 [2001:888:2000:d::a6]:50408
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:58849

Show key headers only | View raw


Here's the code:

from random import random
from time import clock

s = clock()

for i in (1, 2, 3, 6, 8):
     M = 0
     N = 10**i

     for n in xrange(N):
         r = random()
         if 0.5 < r < 0.6:
             M += 1

     k = (N, float(M)/N)

print (clock()-s)

Running on win7 python 2.7 32 bit it uses around 30 seconds avg.
Running on xubuntu, 32 bit, on vmware on windows 7: 20 seconds!
The code runs faster on vm, than the computer itself...
The python version in this case is 1.5 times faster...
I don't understand.

What causes this?

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Code with random module faster on the vm than the vm host... Pascal Bit <pascalbit@hotmail.com> - 2013-11-08 18:48 +0100
  Re: Code with random module faster on the vm than the vm host... alex23 <wuwei23@gmail.com> - 2013-11-11 10:49 +1000
    Re: Code with random module faster on the vm than the vm host... Robert Kern <robert.kern@gmail.com> - 2013-11-11 01:19 +0000
      Re: Code with random module faster on the vm than the vm host... alex23 <wuwei23@gmail.com> - 2013-11-11 12:16 +1000
  Re: Code with random module faster on the vm than the vm host... Ned Batchelder <ned@nedbatchelder.com> - 2013-11-10 17:15 -0800
    Re: Code with random module faster on the vm than the vm host... Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-11-11 01:31 +0000

csiph-web