开发者

Does Django tests run slower on the mac compared to linux?

开发者 https://www.devze.com 2022-12-22 07:20 出处:网络
I\'m currently developing my Django projects on both: Mac OS X 10.5, 32 bit Ubuntu Server 9.10 64 bits (1 CPU, 512MB RAM)

I'm currently developing my Django projects on both:

  1. Mac OS X 10.5, 32 bit
  2. Ubuntu Server 9.10 64 bits (1 CPU, 512MB RAM)

Both of the above OS are using:

  1. Python 2.6.4
  2. Django 1.1.1
  3. MySQL 5.1

Running 12 tests for one of my application take:

  1. Mac: 57.513s
  2. Linux: 30.935s

EDIT:

Mac Hardware Spec:

  • MacBook Pro
  • 2.2 GHz Intel Core 2 Duo
  • 3GB RAM

I'm running the Ubuntu OS on the same开发者_StackOverflow社区 mac above through VMware Fusion 2.0.6.

You might argue that Ubuntu Server 64 bits is faster but I have observed a similar speed difference on Ubuntu 8.10 32 bits desktop edition. Even if I turn off my linux VM and other mac applications, I still experience the slowness. Has anyone else experienced this Django test speed difference across those two OS?

Found the answer:

Thanks to the comment from istruble and the answer from DZPM (I've +1 to you since I can't accept an answer in expired bounty question). It looks like the MySQL database as a test database on the mac is causing the performance issue. Using sqlite3 for tests make the test run time comparable on both platforms.


It depends on your tests, but the bottleneck should be in the database. Could you benchmark MySQL 5.1 in both platforms?

If that's the case, you should set the database in another machine, then configure your project to use it.


So what else is running when you have OSX running? You have Ubuntu Server, which is normally stripped down to just the essentials, running against a desktop OS that's got all kinds of crap running for the "user experience". I'm surprised it did as well as your numbers show.

The only way to truly compare the same app under 2 OSes is to make sure that both OSes are set up in essentially the same way for what you are measuring for.


Some string operations in Python appear to be significantly slower under OS X than under Ubunutu running on a VM on the same machine. Try this in your shell and see what kind of results you come up with:

from timeit import Timer
def sx():
    for i in range(10000):
        s = "%d" % i

min(Timer(stmt=sx).repeat(number=100, repeat=10))

With Python 2.6.4 under OS X 10.6.2 and a 64-bit Ubuntu (unknown version) with kernel version 2.6.31 in a VMware Fusion 2.0.6 VM, the OS X test takes 1.4x as long as the Ubuntu test. OS X fairs better under Python 3.1 where it takes a little less than 1.1x as long.

This does not explain your ~2x speed difference but it does show that Python can run slower under OS X.

0

精彩评论

暂无评论...
验证码 换一张
取 消