Linked Questions
15 questions linked to/from Swift Beta performance: sorting arrays
60
votes
2
answers
16k
views
Why Swift is 100 times slower than C in this image processing test? [duplicate]
Like many other developers I have been very excited about the new Swift language from Apple. Apple has claimed its speed is faster than Objective C and can be used to write operating system. And from ...
97
votes
10
answers
49k
views
How to benchmark Swift code execution?
Is there a way/software to give precise time needed to execute a block of code written in Swift, other than the following?
let date_start = NSDate()
// Code to be executed
println("\(-date_start....
35
votes
2
answers
5k
views
Is Swift really slow at dealing with numbers?
As I was playing around with a swift tutorial, I started to write a custom isPrime method to check if a given Int is prime or not.
After writing it I realized it was working properly but found it a ...
12
votes
8
answers
1k
views
What is a fast way to convert a string of two characters to an array of booleans?
I have a long string (sometimes over 1000 characters) that I want to convert to an array of boolean values. And it needs to do this many times, very quickly.
let input: String = "001"
let output: [...
10
votes
2
answers
3k
views
XCode 6 Playground Measuring Code Performance
Is there any quick way of evaluating the performance / runtime of a certain code part written in the new XCode 6 playground?
I want to start learning Swift by comparing different coding styles for ...
13
votes
1
answer
6k
views
Swift vs Kotlin performance on sorting array
I tried sorting an array of size 100000000 in Swift and Kotlin and i can see a huge performance gap between them. For this number, Kotlin is almost 18 times faster than Swift(on my machine).
I ...
7
votes
4
answers
8k
views
How do I sort an array of objects in reverse order efficiently?
Suppose I have an array of dictionaries:
[ { "id": 2 }, { "id": 59 }, { "id": 31 } ... ]
How can I sort this so that it's in descending order, sorted by "id"?
My initial approach is something like:
...
3
votes
4
answers
5k
views
Swift's Dictionary is slow even with -Ofast
I'm implementing what is essentially a cache using a Dictionary in Swift. The performance is well short of what I would expect. I've read some of the other questions, for example this one about array ...
4
votes
1
answer
3k
views
Swift on Linux: how to specify compiler optimizations
Several threads on stackoverflow (e.g. this one) discuss the different optimization levels (Onone, O, Ounchecked...) when compiling Swift applications.
However, those postings are related to the ...
2
votes
1
answer
813
views
Swift inout parameter performance
I am having horrendous performance with Swift (low fps with only a few textures being drawn). In java on android I am executing the batch of code below between 30 and 40 times faster. I have some ...
0
votes
1
answer
275
views
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 ...
2
votes
2
answers
144
views
Sort Array and a Corresponding Array [duplicate]
Say I have and array [4, 1, 8, 5] and another array that corresponds to each object in the first array, say ["Four", "One", "Eight", "Five"]. How can I sort the first array in ascending order while ...
0
votes
2
answers
158
views
In swift, is there a way to only check part of an array in a for loop (with a set beginning and ending point)
So lets say we have an array a = [20,50,100,200,500,1000]
Generally speaking we could do for number in a { print(a) } if we wanted to check the entirety of a.
How can you limit what indexes are ...
-4
votes
1
answer
97
views
how to get result from last called in locationManager didUpdateToLocation function
I was doing gps location by using CLLocation. When i press submit button and start the process to get the coordinate. However the locationManager being called multiple times.
How can I get the value ...
1
vote
1
answer
57
views
Slower operations on Array<SomeStruct> than on Array<SomeClass>... Why?
I did some comparison here:
https://github.com/itchingpixels/structs-vs-classes
and it seems like inserting a struct into an array of structs is 10x slower than inserting a class to an array of ...