Earlier quoted context omitted.
This is just speculation, but slowness might be because this is being run as a script via /usr/bin/swift, rather than being precompiled into a binary. Certainly I have found my own Swift scripts seem to be a lot slower than compiled programs. EDIT: from my own test with 1000 iterations, script version 17s, compiled version (release build) 5.4s
good stuff. tbh though, only ~3x slowdown in scripting imo is pretty damn good 8)
A Very Simple Genetic Algorithm Written in Swift 3
11–20 of 42 posts
Re: A Very Simple Genetic Algorithm Written in Swift 3
#12Re: A Very Simple Genetic Algorithm Written in Swift 3
#13Are we all just sharing everything we write on here now? Is this notable for some reason?
Re: A Very Simple Genetic Algorithm Written in Swift 3
#14Are we all just sharing everything we write on here now? Is this notable for some reason?
Re: A Very Simple Genetic Algorithm Written in Swift 3
#15> Note -- this is much slower than the python version Surprising. Swift, a compiled, static language, is slower than python in this use case?
stuff like this can't help var n = Double(arc4random_uniform(UInt32(weightTotal * 1000000.0))) / 1000000.0
Re: A Very Simple Genetic Algorithm Written in Swift 3
#16Are we all just sharing everything we write on here now? Is this notable for some reason?
That's why we vote articles up. Sometimes the comments alone in a basic post add a lot of value.
Re: A Very Simple Genetic Algorithm Written in Swift 3
#17Earlier quoted context omitted.
stuff like this can't help var n = Double(arc4random_uniform(UInt32(weightTotal * 1000000.0))) / 1000000.0
Out of curiosity, what's wrong with that line? Why is it slow?
Re: A Very Simple Genetic Algorithm Written in Swift 3
#18Are we all just sharing everything we write on here now? Is this notable for some reason?
Re: A Very Simple Genetic Algorithm Written in Swift 3
#19Earlier quoted context omitted.
This is just speculation, but slowness might be because this is being run as a script via /usr/bin/swift, rather than being precompiled into a binary. Certainly I have found my own Swift scripts seem to be a lot slower than compiled programs. EDIT: from my own test with 1000 iterations, script version 17s, compiled version (release build) 5.4s
good stuff. tbh though, only ~3x slowdown in scripting imo is pretty damn good 8)
Re: A Very Simple Genetic Algorithm Written in Swift 3
#20Are we all just sharing everything we write on here now? Is this notable for some reason?
Shouldn't people should feel free to share whatever they want that's HN material? That's why we vote articles up. Sometimes the comments alone in a basic post add a lot of value.