Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #58849
| Date | 2013-11-08 18:48 +0100 |
|---|---|
| From | Pascal Bit <pascalbit@hotmail.com> |
| Subject | Code with random module faster on the vm than the vm host... |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2249.1383942084.18130.python-list@python.org> (permalink) |
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 | Next — Next in thread | Find similar | Unroll 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