title: Performance of Swift vs Objective-C
body: <p>I am just comparing the performance of <a href="https://en.wikipedia.org/wiki/Swift_%28Apple_programming_language%29">Swift</a> and <a href="http://en.wikipedia.org/wiki/Objective-C">Objective-C</a>. For that, I am using NSDate to measure the time taken, but I am getting a big difference between Swift and Objective-C. I just ran an empty <code>for</code> loop 100,000 times. Here is my code,</p>
  
  <p>In Objective-C,</p>
  
  <pre><code>NSDate * start = [NSDate date];
  
  for (int i=0; i&lt;=100000; i++) {
  
  }
  
  NSDate * end = [NSDate date];
  
  double timeTaken = [end timeIntervalSinceDate:start] * 1000;
  </code></pre>
  
  <p>timeTaken is 0.24 milliseconds</p>
  
  <p>In Swift,</p>
  
  <pre><code>var start = NSDate()
  
      for i in 0...100000
  
      {
  
      }
  
      var end = NSDate()
  
      var timeTaken = end.timeIntervalSinceDate(start) * 1000
  </code></pre>
  
  <p><code>timeTaken</code> is 74 milliseconds in Swift, which is a big difference when compared to Objective-C.</p>
  
  <p>Am I doing anything wrong here in the measurement?</p>