#!/usr/bin/env swift

import Foundation

var num_steps: Int = 1000000000

if CommandLine.arguments.count == 2 {
    num_steps = Int(CommandLine.arguments[1])!;
}

print("Calculating PI with:")
print("  " + String(num_steps) + " slices")
print("  1 process")

var total_sim: Double = 0.0
var step: Double = 1.0/Double(num_steps)

// Get time.
let start = Date()

for i in 1...num_steps {
    var x: Double = (Double(i) - 0.5) * step
    total_sim += 4.0/(1.0+(x*x))
}

var pi: Double = total_sim * step

// Get time again.
let stop = Date()
let interval = stop.timeIntervalSince(start)

print("Obtained value of PI: " + String(pi))
print("Time taken: " + String(interval) + " seconds")

#!/usr/bin/env swift

import Foundation

var num_steps: Int = 1000000000

#if swift(>=3)
if CommandLine.arguments.count == 2 {
    num_steps = Int(CommandLine.arguments[1])!;
}
#else 
if Process.arguments.count == 2 {
    num_steps = Int(Process.arguments[1])!;
} 
#endif

print("Calculating PI with:")
print("  " + String(num_steps) + " slices")
print("  1 process")

var total_sim: Double = 0.0
var step: Double = 1.0/Double(num_steps)

// Get time.
let start = Date()

for i in 1...num_steps {
    var x: Double = (Double(i) - 0.5) * step
    total_sim += 4.0/(1.0+(x*x))
}

var pi: Double = total_sim * step

// Get time again.
let stop = Date()
let interval = stop.timeIntervalSince(start)

print("Obtained value of PI: " + String(pi))
print("Time taken: " + String(interval) + " seconds")

--- 
+++ 
@@ -4,15 +4,9 @@
 
 var num_steps: Int = 1000000000
 
-#if swift(>=3)
 if CommandLine.arguments.count == 2 {
     num_steps = Int(CommandLine.arguments[1])!;
 }
-#else 
-if Process.arguments.count == 2 {
-    num_steps = Int(Process.arguments[1])!;
-} 
-#endif
 
 print("Calculating PI with:")
 print("  " + String(num_steps) + " slices")
Revert "Use preprocessor directives to support Swift 2.x"

This reverts commit 1693f11c2ea1729d46b4a85bd5e40e6c1211a8a3.

There's no point as the interface to Date/NSDate has also changed.

Reverting.
