So my beautiful and talented wife got an 11″, Core i7 variant of the mid-2011 MacBook Air to write her dissertation on. (The purchase timing was pretty good as her white MacBook’s hard drive just died.) I played around with the Air for a bit and holy moly, it’s FAST!
To compare, the computer I do almost everything on (including software development) is a mid-2009 13″ MacBook Pro. It’s got 4GB of RAM, a 2.26Ghz Core 2 Duo processor, and a 80GB Intel X-25M (G2) solid-state hard drive. I love this laptop and it’s still in great shape more than two years into owning it.
The Air has 4GB RAM, 128GB Samsung SSD, and the upgrade 1.8Ghz Core i7 processor. I’m really impressed with Core i7 processor. This one has two cores but can handle two threads per core for a total of 4 threads. I’d heard about HyperThreading and have used computers whose processors had this feature, but I wanted to sit down and investigate this from a programming perspective. HyperThreading has its limitations but depending on the workload it can provide some pretty stunning benefits computationally.
I’ve blogged about NSOperation before, so you know I’m a fan of this class. While the child was taking his morning nap, i whipped up a little app that spawned 4 NSOperation objects either parallel or in series. The actual work that the NSOperation is doing is totally simple and shouldn’t be considered authoritative or particularly indicative. (I just adds the square root of [NSDate date] to a variable 20,000,000 times. I figured: we have some addition, some floating point math, and an Objective C call. That’s close enough for a ball park idea of what this thing can do.
When I run this on my 2.26Ghz Core 2 Duo MacBook Pro, I get this:
- Time to run all threads in parallel: 3.58 seconds
- Time to run a single thread: 1.78 seconds
- Total work (1.78 * 4 = 7.12) gets done in 3.58 seconds. This is a 2.0x multi-threading improvement.
When I run it on the 1.8Ghz Core i7 I get this:
- Time to run all threads in parallel: 1.74 seconds
- Time to run a single thread: 1.22 seconds
- Total work (1.22 * 4 = 4.88) gets done in 1.74 seconds. This is a 2.8x multi-threading improvement. (It’s almost like HyperThreading adds a third core to the processor.)
What do we learn from this little experiment? The Core i7 is a really fast processor. For my little contrived test we see that not only is the i7 45% faster than a 2.26Ghz Core 2 Duo for single threaded applications, it’s over twice as fast for multi-threaded applications!
One thing you should know about the Core i7: it doesn’t actually run at 1.8Ghz. AnandTech has a really cool chart to illustrate this but basically, the processor has a maximum TDP (thermal design power) and the processor can dynamically over clock itself depending on temperature and load. This is a really cool (har har) idea and it’s interesting and refreshing to see CPUs marketed with a lower clock speed than they are actually capable of.
If you want to download the Xcode project for the super hacked together and not very pretty Threads application, you should very gently click here and don’t make fun of me when you look at it.