user11141180
user11141180

Reputation:

Recursive Algorithm Is Much Slower in Playgrounds (1 minute) Than Xcode (0.1 seconds)

I have code to solve a sudoku board using a recursive algorithm.

The problem is that, when this code is run in Xcode, it solves the algorithm in 0.1 seconds, and when it is run in playgrounds, where I need it, it takes almost one minute.

When run in iPad, it takes about 30 seconds, but still obviously nowhere near the time it takes in xcode.

Any help or ideas would be appreciated, thank you.

Upvotes: 0

Views: 259

Answers (1)

ManWithBear
ManWithBear

Reputation: 2875

  1. Playground try to get result of each your operation and print it out (repl style)
  2. It just slow and laggy by itself
  3. In Xcode you can compile your code with additional optimization that speedup your code a lot (e. g. Swift Beta performance: sorting arrays)

Source files compiles as separate module, so don't forget about public/open access modifiers.
To create source files: enter image description here

Upvotes: 1

Related Questions