Answer the question
In order to leave comments, you need to log in
Why is an OS X application on Swift so slow?
I want to make a text processing soft for myself, so for the test I started writing numbers from 1 to a given number (textCount) in the NSTextView field. So, if you request a miserable 5000 iterations, then the program thinks for 15 seconds. When you specify 10,000 iterations, it generally hangs. And in monitoring the system loads percent by 99%.
It seems that turbo pascal rustled much faster 10 years ago.
Is this some kind of slow development mod, or did I not include something, or why can't the last macbook on a seemingly good Java program count up to 5,000 in 15 seconds? How will he then pick text files of hundreds of megabytes for me?
Code below.
import Cocoa
class ViewController: NSViewController {
@IBOutlet var outcomeText: NSTextView!
@IBOutlet var textCount: NSTextField!
@IBAction func TextGenGo(sender: AnyObject) {
var i:int_least32_t;
for (i=1;i<=textCount.intValue;i++) {
outcomeText.string = outcomeText.string! + String(i) + " ";
}
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override var representedObject: AnyObject? {
didSet {
// Update the view, if already loaded.
}
}
}
Answer the question
In order to leave comments, you need to log in
We open the profiler and run it at 5000.
We see that out of the 26 seconds it takes for the program to execute the function, almost all of them go to finish editing the NSTextView.
pikucha.ru/iedeV
Now we do a feint with our ears and display the creation of a line separately, the display for it separately. (I apologize in advance for any errors in the code, this is my first time on Swift)
@IBAction func TextGenGo(sender: AnyObject) {
var i:int_least32_t;
var string = outcomeText.string;
for (i=1;i<=textCount.intValue;i++) {
string = string! + String(i) + " ";
}
outcomeText.string = string;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question