nico-s
6/7/2017 - 8:09 PM

ViewController.swift

func dispatchMonteCarlo() {

    for view in monteCarloGraph.subviews{
        view.removeFromSuperview()
    }

    nPointsInside = 0

    let background = DispatchQueue.global()

    let start = DispatchTime.now()
    background.async {
        self.computeMonteCarlo(iterations: self.nIterations)
    }
    let end = DispatchTime.now()

    let nanoTime = end.uptimeNanoseconds - start.uptimeNanoseconds
    let timeInterval = Double(nanoTime)
    print("Elapsed time: \(timeInterval) nanoseconds")
}