title: Swift vs Java - speed at filling big array
body: <p>I just did a small speed comparison between Java and Swift on filling a big array.
  I came up with following results:</p>
  <hr />
  <h2>Swift</h2>
  <pre><code>import Foundation
  
  let start = CFAbsoluteTimeGetCurrent()
  var intArray = Int[]()
  for var i = 0; i &lt;= 300000; ++i {
      intArray.append(0)
  }
  let timeTaken = CFAbsoluteTimeGetCurrent() - start
  println(timeTaken)
  </code></pre>
  <p>Result: 1.66182696819305</p>
  <hr />
  <h2>Java</h2>
  <pre><code>long start = System.currentTimeMillis();
  int[] intArray;
  int i = 0;
  intArray = new int[300000];
  for (i = 0; i &lt; 300000; i++) {
      intArray[i]=0;
  }
  System.out.println(&quot;Time: &quot;+(System.currentTimeMillis()-start)+&quot;ms&quot;);
  </code></pre>
  <p>Result: Time: 3ms</p>
  <hr />
  <p>This was kind of shocking me;</p>
  <ul>
  <li>is Swift 550x slower then Java.. or am I using some not-optimized code?</li>
  </ul>