I recently started working with a fairly large iOS/Swift code base--one which takes several minutes to complete a full build from a clean folder. Since I have several macOS workstations on-hand, I naturally was curious how they compare in my most common use case--developing Swift iOS applications. Is there one that would give me less time to fetch a cup of coffee during a full build?
The code base
The code base I'm working with for these tests has the following profile:
Swift files: 223
Objective-C files: 6
Xcode version: 8.3.2
Arrangement: One primary target, with two embedded projects.
The methodology I used was quite simple, and designed around "real life use" of my computers for Xcode development:
- Clean the project, manually delete the entire DerivedData folder.
- Shut down the computer
- Turn the computer back on
- Open the project
- Select the "generic ios device" target OS, and build the project (measurement #1)
- Clean the project, close Xcode, manually delete DerivedData (again)
- Launch Xcode, build the project again (measurement #2)
I planned the two trials to record the experience of building a project that isn't currently in a disk cache, then building it again after macOS had the opportunity to keep files in disk cache. As the numbers below bear out, this made virtually no difference for the two SSD-based computers, but made a huge difference for the iMac with the Fusion disk.
For all trials, I made sure the computers were on AC power, no other applications were running--in fact I had done nothing since booting each machine except run XCode to time the tests.
I ran the test with three different computers, described below.
2015 15-inch (Retina) MacBook Pro Core i7
Test subject #1 is a 2015 MacBook Pro with a Core i7 CPU, SSD and 16GB RAM. This is a pretty standard "developer workstation" that many serious developers would select. Indeed my tests do support this is probably the best balance of power and portability for a developer (of the three test subjects).
2015 27-inch (5K) iMac Core i5
Test subject #2 is a 2015 iMac with a Core i5 CPU, Spinning Fusion drive and 32GB RAM. This is my "daily driver" development workstation. While a Core i5 machine with a spinning disk may not sound like a natural choice for a developer, the numbers below bear out that this is actually the most performant machine of the three by a decent margin--for this use case. Of course while it has the most RAM, largest screen and most storage, it has zero portability. Trade-offs...
2016 13-inch MacBook Pro (no touch bar) Core i7
I purchased this machine as a "travel laptop". I love the portability of it, and it's more than adequate for me as a mobile development workstation for short stints. It's especially awesome for use on airplanes and giving presentations. However, I had wondered whether the 2-core i7 made any difference for Xcode builds vs. the 4-core i5 in my "daily driver" iMac, or the 4-core i7 in the 15" MBP. Spoiler alert: it does. It really, really does.
Here's a summary of the system configurations, configuration costs and build timings using each machine with an identical set of code and the same build process.
One note: the fourth row is a computer I didn't test because I don't have one. I included it because that's the system I would need buy if I wanted to trade in my current iMac+13" MacBook pairing. I could make due with a base model upgraded to 1TB storage.
Note: the prices are what I paid for this equipment (or in the case of the 2015 15" which I don't own, its cost new from Apple as of this date).
- Intuitively, I would have expected the 2015 MBP with the Core i7 to beat the 2015 iMac with the Core i5--but the i5 iMac was the fastest. It's only a difference of 12 seconds, but it's still better performance for lower cost.
- I didn't necessarily expect the Fusion featured iMac spinning disk to catch up with the SSD machines (after it had a chance to cache the project)--but it did. In my use case of repetitive compiles in Xcode, I perceive no benefit to an SSD-based iMac vs the much less expensive Fusion drive.
- It's unfortunate that the 13" MBP can only be ordered with 2 cores. Both the 4-Core iMac and 4-Core 15" MBP blow right past the 2-core 13" MacBook Pro.
- The biggest determinant of performance seems to be how many CPU cores area available to the build process.
- The i5/i7 architecture seems to make no difference--for this use case, at least.
What will I buy next time?
Since I primarily work in my office, and travel for business only occasionally, the iMac plus lower end MacBook for the road still works the best for me. A 5K iMac ($2,499) plus a basic 13" MBP for travel ($1,699) costs less than a mid-range 2016 15" MBP ($3,199) plus the 5K UltraFine display ($1,299). Your mileage may vary, but for my purposes the speed of the iMac and the lightest, most coach-class friendly travel machine is the best of both worlds. Plus my livelihood depends on a working computer every day, so having a backup to my primary machine gives me peace of mind.