Swift Open Api Thread
I parse open API from web to my app. and it takes 1 min 15 sec to phrase all. It is too long for my app.
My app's logic is 'Launching page' -> 'Searching Page'. At the 'Searching Page', user can select six option(color, shape etc.) for filtering open Api. so My app should filtering the according to selected option, whether the parsing is not finished.
My question,
1. Can I reduce the time for parsing, for example by using thread or any way?
If User select the option, before finishing phrasing open api,
how can i provide some data located at the end of the row of open api?Is there any best way to parsing and filtering by using multiple thread?
sorry my poor english 😥😥 please suggest the best solution thanks.
//viewDidload()
DispatchQueue.global(qos: .background).async {
for i in 1..<207 {
let url = "http://apis.data.go.kr/1470000/MdcinGrnIdntfcInfoService/getMdcinGrnIdntfcInfoList?serviceKey=VmiuEGJughm504SlGiaSfpQukd9mf27WJL2z2subLqfzG9DNUoYqKJ4KU6yHHdkrPuTo0CJwEZHGOhHqss9uFA%3D%3D&numOfRows=100&pageNo=(i)"
guard let xmlParser = XMLParser(contentsOf: URL(string: url)!) else { return }
xmlParser.delegate = self;
xmlParser.parse()
}
}
//parser delegate
public func parser(_ parser: XMLParser, didStartElement elementName: String, namespaceURI: String?, qualifiedName qName: String?, attributes attributeDict: [String : String] = [:]) {
currentElement = elementName
if (elementName == "item") {
pillItem = [String : String]()
pillName = ""
pillCompany = ""
pillImage = ""
pillFrontInprint = ""
pillBackInprint = ""
pillShape = ""
pillFrontScore = ""
pillBackScore = ""
pillFrontColor = ""
pillBackColor = ""
pillLongSize = ""
pillShortSize = ""
pillThick = ""
pillForm = ""
pillChart = ""
pillClassName = ""
pillClassNum = ""
pillEtcName = ""
}
}
public func parser(_ parser: XMLParser, didEndElement elementName: String, namespaceURI: String?, qualifiedName qName: String?) {
if (elementName == "item") {
let pill = MFTemporaryPillModel(pillName: pillName, pillCompany: pillCompany, pillImage: pillImage, pillFrontInprint: pillFrontInprint,
pillBackInprint: pillBackInprint, pillShape: pillShape, pillFrontScore: pillFrontScore, pillBackScore: pillBackScore,
pillFrontColor: pillFrontColor, pillBackColor: pillBackColor, pillLongSize: pillLongSize, pillShortSize: pillShortSize,
pillThick: pillThick, pillForm: pillForm, pillEfficacy: pillClassName, pillChart: pillChart, pillClassName: pillClassName,
pillClassNum: pillClassNum, pillEtcName: pillEtcName)
pillDataItems.append(pill)
}
}
public func parser(_ parser: XMLParser, foundCharacters string: String) {
if (currentElement == "ITEM_NAME") { //이름
if pillName == "" {
pillName = string
}
} else if (currentElement == "ENTP_NAME") { //회사이름
if pillCompany == "" {
pillCompany = string
}
} else if (currentElement == "CHART") { //성상
if pillChart == "" {
pillChart = string
}
} else if (currentElement == "ITEM_IMAGE") {//사진
if pillImage == "" {
pillImage = string
}
} else if (currentElement == "PRINT_FRONT") {
if pillFrontInprint == "" {
pillFrontInprint = string
}
} else if (currentElement == "PRINT_BACK") {
if pillBackInprint == "" {
pillBackInprint = string
}
} else if (currentElement == "DRUG_SHAPE") {
if pillShape == "" {
pillShape = string
}
} else if (currentElement == "COLOR_CLASS1") {
if pillFrontColor == "" {
pillFrontColor = string
}
} else if (currentElement == "COLOR_CLASS2") {
if pillBackColor == "" {
pillBackColor = string
}
} else if (currentElement == "LINE_FRONT") {
if pillFrontScore == "" {
pillFrontScore = string
}
} else if (currentElement == "LINE_BACK") {
if pillBackScore == "" {
pillBackScore = string
}
} else if (currentElement == "LENG_LONG") {
if pillLongSize == "" {
pillLongSize = string
}
} else if (currentElement == "LENG_SHORT") {
if pillShortSize == "" {
pillShortSize = string
}
} else if (currentElement == "THICK") {
if pillThick == "" {
pillThick = string
}
} else if (currentElement == "CLASS_NAME") { //분류번호에 있는거
if pillClassName == "" {
pillClassName = string
}
} else if (currentElement == "CLASS_NO") { //분류 번호
if pillClassNum == "" {
pillClassNum = string
}
} else if (currentElement == "FORM_CODE_NAME") {
if pillForm == "" {
pillForm = string
}
} else if (currentElement == "ETC_OTC_NAME") { //전문 기타 이런거
if pillEtcName == "" {
pillEtcName = string
}
}
}
}
//filtering func (when user select options)
func filteredPillData(filteredOption: [String : [String]]) {
DispatchQueue.global(qos: .userInitiated).async {
self.filteredData.removeAll()
for i in 0..<self.pillMap[1]!.count{
let data: MFTemporaryPillModel = self.pillMap[1]![i]
if (filteredOption["score"]?.contains(data.pillFrontScore))! && (filteredOption["color"]?.contains(data.pillFrontColor))! &&
(filteredOption["form"]?.contains(data.pillForm))! && (filteredOption["shape"]?.contains(data.pillShape))! {
self.filteredData.append(data)
self.mMFSearchPillMainView.mMFSearchPillView.mMFDisplayPillDataCollection.pillDataArray = self.filteredData
}
}
DispatchQueue.main.async {
self.mMFSearchPillMainView.mMFSearchPillView.mMFDisplayPillDataCollection.collectionView.reloadData()
}
}
swift multithreading parsing grand-central-dispatch
add a comment |
I parse open API from web to my app. and it takes 1 min 15 sec to phrase all. It is too long for my app.
My app's logic is 'Launching page' -> 'Searching Page'. At the 'Searching Page', user can select six option(color, shape etc.) for filtering open Api. so My app should filtering the according to selected option, whether the parsing is not finished.
My question,
1. Can I reduce the time for parsing, for example by using thread or any way?
If User select the option, before finishing phrasing open api,
how can i provide some data located at the end of the row of open api?Is there any best way to parsing and filtering by using multiple thread?
sorry my poor english 😥😥 please suggest the best solution thanks.
//viewDidload()
DispatchQueue.global(qos: .background).async {
for i in 1..<207 {
let url = "http://apis.data.go.kr/1470000/MdcinGrnIdntfcInfoService/getMdcinGrnIdntfcInfoList?serviceKey=VmiuEGJughm504SlGiaSfpQukd9mf27WJL2z2subLqfzG9DNUoYqKJ4KU6yHHdkrPuTo0CJwEZHGOhHqss9uFA%3D%3D&numOfRows=100&pageNo=(i)"
guard let xmlParser = XMLParser(contentsOf: URL(string: url)!) else { return }
xmlParser.delegate = self;
xmlParser.parse()
}
}
//parser delegate
public func parser(_ parser: XMLParser, didStartElement elementName: String, namespaceURI: String?, qualifiedName qName: String?, attributes attributeDict: [String : String] = [:]) {
currentElement = elementName
if (elementName == "item") {
pillItem = [String : String]()
pillName = ""
pillCompany = ""
pillImage = ""
pillFrontInprint = ""
pillBackInprint = ""
pillShape = ""
pillFrontScore = ""
pillBackScore = ""
pillFrontColor = ""
pillBackColor = ""
pillLongSize = ""
pillShortSize = ""
pillThick = ""
pillForm = ""
pillChart = ""
pillClassName = ""
pillClassNum = ""
pillEtcName = ""
}
}
public func parser(_ parser: XMLParser, didEndElement elementName: String, namespaceURI: String?, qualifiedName qName: String?) {
if (elementName == "item") {
let pill = MFTemporaryPillModel(pillName: pillName, pillCompany: pillCompany, pillImage: pillImage, pillFrontInprint: pillFrontInprint,
pillBackInprint: pillBackInprint, pillShape: pillShape, pillFrontScore: pillFrontScore, pillBackScore: pillBackScore,
pillFrontColor: pillFrontColor, pillBackColor: pillBackColor, pillLongSize: pillLongSize, pillShortSize: pillShortSize,
pillThick: pillThick, pillForm: pillForm, pillEfficacy: pillClassName, pillChart: pillChart, pillClassName: pillClassName,
pillClassNum: pillClassNum, pillEtcName: pillEtcName)
pillDataItems.append(pill)
}
}
public func parser(_ parser: XMLParser, foundCharacters string: String) {
if (currentElement == "ITEM_NAME") { //이름
if pillName == "" {
pillName = string
}
} else if (currentElement == "ENTP_NAME") { //회사이름
if pillCompany == "" {
pillCompany = string
}
} else if (currentElement == "CHART") { //성상
if pillChart == "" {
pillChart = string
}
} else if (currentElement == "ITEM_IMAGE") {//사진
if pillImage == "" {
pillImage = string
}
} else if (currentElement == "PRINT_FRONT") {
if pillFrontInprint == "" {
pillFrontInprint = string
}
} else if (currentElement == "PRINT_BACK") {
if pillBackInprint == "" {
pillBackInprint = string
}
} else if (currentElement == "DRUG_SHAPE") {
if pillShape == "" {
pillShape = string
}
} else if (currentElement == "COLOR_CLASS1") {
if pillFrontColor == "" {
pillFrontColor = string
}
} else if (currentElement == "COLOR_CLASS2") {
if pillBackColor == "" {
pillBackColor = string
}
} else if (currentElement == "LINE_FRONT") {
if pillFrontScore == "" {
pillFrontScore = string
}
} else if (currentElement == "LINE_BACK") {
if pillBackScore == "" {
pillBackScore = string
}
} else if (currentElement == "LENG_LONG") {
if pillLongSize == "" {
pillLongSize = string
}
} else if (currentElement == "LENG_SHORT") {
if pillShortSize == "" {
pillShortSize = string
}
} else if (currentElement == "THICK") {
if pillThick == "" {
pillThick = string
}
} else if (currentElement == "CLASS_NAME") { //분류번호에 있는거
if pillClassName == "" {
pillClassName = string
}
} else if (currentElement == "CLASS_NO") { //분류 번호
if pillClassNum == "" {
pillClassNum = string
}
} else if (currentElement == "FORM_CODE_NAME") {
if pillForm == "" {
pillForm = string
}
} else if (currentElement == "ETC_OTC_NAME") { //전문 기타 이런거
if pillEtcName == "" {
pillEtcName = string
}
}
}
}
//filtering func (when user select options)
func filteredPillData(filteredOption: [String : [String]]) {
DispatchQueue.global(qos: .userInitiated).async {
self.filteredData.removeAll()
for i in 0..<self.pillMap[1]!.count{
let data: MFTemporaryPillModel = self.pillMap[1]![i]
if (filteredOption["score"]?.contains(data.pillFrontScore))! && (filteredOption["color"]?.contains(data.pillFrontColor))! &&
(filteredOption["form"]?.contains(data.pillForm))! && (filteredOption["shape"]?.contains(data.pillShape))! {
self.filteredData.append(data)
self.mMFSearchPillMainView.mMFSearchPillView.mMFDisplayPillDataCollection.pillDataArray = self.filteredData
}
}
DispatchQueue.main.async {
self.mMFSearchPillMainView.mMFSearchPillView.mMFDisplayPillDataCollection.collectionView.reloadData()
}
}
swift multithreading parsing grand-central-dispatch
Sorry but this question is too vague and open ended. Focus on one specific issue and show relevant code about that one specific problem.
– rmaddy
Nov 12 '18 at 3:07
"Can I reduce the time for parsing" We don't know because you have not shown us any code at all. If you want help with your code, show it.
– matt
Nov 12 '18 at 3:17
add a comment |
I parse open API from web to my app. and it takes 1 min 15 sec to phrase all. It is too long for my app.
My app's logic is 'Launching page' -> 'Searching Page'. At the 'Searching Page', user can select six option(color, shape etc.) for filtering open Api. so My app should filtering the according to selected option, whether the parsing is not finished.
My question,
1. Can I reduce the time for parsing, for example by using thread or any way?
If User select the option, before finishing phrasing open api,
how can i provide some data located at the end of the row of open api?Is there any best way to parsing and filtering by using multiple thread?
sorry my poor english 😥😥 please suggest the best solution thanks.
//viewDidload()
DispatchQueue.global(qos: .background).async {
for i in 1..<207 {
let url = "http://apis.data.go.kr/1470000/MdcinGrnIdntfcInfoService/getMdcinGrnIdntfcInfoList?serviceKey=VmiuEGJughm504SlGiaSfpQukd9mf27WJL2z2subLqfzG9DNUoYqKJ4KU6yHHdkrPuTo0CJwEZHGOhHqss9uFA%3D%3D&numOfRows=100&pageNo=(i)"
guard let xmlParser = XMLParser(contentsOf: URL(string: url)!) else { return }
xmlParser.delegate = self;
xmlParser.parse()
}
}
//parser delegate
public func parser(_ parser: XMLParser, didStartElement elementName: String, namespaceURI: String?, qualifiedName qName: String?, attributes attributeDict: [String : String] = [:]) {
currentElement = elementName
if (elementName == "item") {
pillItem = [String : String]()
pillName = ""
pillCompany = ""
pillImage = ""
pillFrontInprint = ""
pillBackInprint = ""
pillShape = ""
pillFrontScore = ""
pillBackScore = ""
pillFrontColor = ""
pillBackColor = ""
pillLongSize = ""
pillShortSize = ""
pillThick = ""
pillForm = ""
pillChart = ""
pillClassName = ""
pillClassNum = ""
pillEtcName = ""
}
}
public func parser(_ parser: XMLParser, didEndElement elementName: String, namespaceURI: String?, qualifiedName qName: String?) {
if (elementName == "item") {
let pill = MFTemporaryPillModel(pillName: pillName, pillCompany: pillCompany, pillImage: pillImage, pillFrontInprint: pillFrontInprint,
pillBackInprint: pillBackInprint, pillShape: pillShape, pillFrontScore: pillFrontScore, pillBackScore: pillBackScore,
pillFrontColor: pillFrontColor, pillBackColor: pillBackColor, pillLongSize: pillLongSize, pillShortSize: pillShortSize,
pillThick: pillThick, pillForm: pillForm, pillEfficacy: pillClassName, pillChart: pillChart, pillClassName: pillClassName,
pillClassNum: pillClassNum, pillEtcName: pillEtcName)
pillDataItems.append(pill)
}
}
public func parser(_ parser: XMLParser, foundCharacters string: String) {
if (currentElement == "ITEM_NAME") { //이름
if pillName == "" {
pillName = string
}
} else if (currentElement == "ENTP_NAME") { //회사이름
if pillCompany == "" {
pillCompany = string
}
} else if (currentElement == "CHART") { //성상
if pillChart == "" {
pillChart = string
}
} else if (currentElement == "ITEM_IMAGE") {//사진
if pillImage == "" {
pillImage = string
}
} else if (currentElement == "PRINT_FRONT") {
if pillFrontInprint == "" {
pillFrontInprint = string
}
} else if (currentElement == "PRINT_BACK") {
if pillBackInprint == "" {
pillBackInprint = string
}
} else if (currentElement == "DRUG_SHAPE") {
if pillShape == "" {
pillShape = string
}
} else if (currentElement == "COLOR_CLASS1") {
if pillFrontColor == "" {
pillFrontColor = string
}
} else if (currentElement == "COLOR_CLASS2") {
if pillBackColor == "" {
pillBackColor = string
}
} else if (currentElement == "LINE_FRONT") {
if pillFrontScore == "" {
pillFrontScore = string
}
} else if (currentElement == "LINE_BACK") {
if pillBackScore == "" {
pillBackScore = string
}
} else if (currentElement == "LENG_LONG") {
if pillLongSize == "" {
pillLongSize = string
}
} else if (currentElement == "LENG_SHORT") {
if pillShortSize == "" {
pillShortSize = string
}
} else if (currentElement == "THICK") {
if pillThick == "" {
pillThick = string
}
} else if (currentElement == "CLASS_NAME") { //분류번호에 있는거
if pillClassName == "" {
pillClassName = string
}
} else if (currentElement == "CLASS_NO") { //분류 번호
if pillClassNum == "" {
pillClassNum = string
}
} else if (currentElement == "FORM_CODE_NAME") {
if pillForm == "" {
pillForm = string
}
} else if (currentElement == "ETC_OTC_NAME") { //전문 기타 이런거
if pillEtcName == "" {
pillEtcName = string
}
}
}
}
//filtering func (when user select options)
func filteredPillData(filteredOption: [String : [String]]) {
DispatchQueue.global(qos: .userInitiated).async {
self.filteredData.removeAll()
for i in 0..<self.pillMap[1]!.count{
let data: MFTemporaryPillModel = self.pillMap[1]![i]
if (filteredOption["score"]?.contains(data.pillFrontScore))! && (filteredOption["color"]?.contains(data.pillFrontColor))! &&
(filteredOption["form"]?.contains(data.pillForm))! && (filteredOption["shape"]?.contains(data.pillShape))! {
self.filteredData.append(data)
self.mMFSearchPillMainView.mMFSearchPillView.mMFDisplayPillDataCollection.pillDataArray = self.filteredData
}
}
DispatchQueue.main.async {
self.mMFSearchPillMainView.mMFSearchPillView.mMFDisplayPillDataCollection.collectionView.reloadData()
}
}
swift multithreading parsing grand-central-dispatch
I parse open API from web to my app. and it takes 1 min 15 sec to phrase all. It is too long for my app.
My app's logic is 'Launching page' -> 'Searching Page'. At the 'Searching Page', user can select six option(color, shape etc.) for filtering open Api. so My app should filtering the according to selected option, whether the parsing is not finished.
My question,
1. Can I reduce the time for parsing, for example by using thread or any way?
If User select the option, before finishing phrasing open api,
how can i provide some data located at the end of the row of open api?Is there any best way to parsing and filtering by using multiple thread?
sorry my poor english 😥😥 please suggest the best solution thanks.
//viewDidload()
DispatchQueue.global(qos: .background).async {
for i in 1..<207 {
let url = "http://apis.data.go.kr/1470000/MdcinGrnIdntfcInfoService/getMdcinGrnIdntfcInfoList?serviceKey=VmiuEGJughm504SlGiaSfpQukd9mf27WJL2z2subLqfzG9DNUoYqKJ4KU6yHHdkrPuTo0CJwEZHGOhHqss9uFA%3D%3D&numOfRows=100&pageNo=(i)"
guard let xmlParser = XMLParser(contentsOf: URL(string: url)!) else { return }
xmlParser.delegate = self;
xmlParser.parse()
}
}
//parser delegate
public func parser(_ parser: XMLParser, didStartElement elementName: String, namespaceURI: String?, qualifiedName qName: String?, attributes attributeDict: [String : String] = [:]) {
currentElement = elementName
if (elementName == "item") {
pillItem = [String : String]()
pillName = ""
pillCompany = ""
pillImage = ""
pillFrontInprint = ""
pillBackInprint = ""
pillShape = ""
pillFrontScore = ""
pillBackScore = ""
pillFrontColor = ""
pillBackColor = ""
pillLongSize = ""
pillShortSize = ""
pillThick = ""
pillForm = ""
pillChart = ""
pillClassName = ""
pillClassNum = ""
pillEtcName = ""
}
}
public func parser(_ parser: XMLParser, didEndElement elementName: String, namespaceURI: String?, qualifiedName qName: String?) {
if (elementName == "item") {
let pill = MFTemporaryPillModel(pillName: pillName, pillCompany: pillCompany, pillImage: pillImage, pillFrontInprint: pillFrontInprint,
pillBackInprint: pillBackInprint, pillShape: pillShape, pillFrontScore: pillFrontScore, pillBackScore: pillBackScore,
pillFrontColor: pillFrontColor, pillBackColor: pillBackColor, pillLongSize: pillLongSize, pillShortSize: pillShortSize,
pillThick: pillThick, pillForm: pillForm, pillEfficacy: pillClassName, pillChart: pillChart, pillClassName: pillClassName,
pillClassNum: pillClassNum, pillEtcName: pillEtcName)
pillDataItems.append(pill)
}
}
public func parser(_ parser: XMLParser, foundCharacters string: String) {
if (currentElement == "ITEM_NAME") { //이름
if pillName == "" {
pillName = string
}
} else if (currentElement == "ENTP_NAME") { //회사이름
if pillCompany == "" {
pillCompany = string
}
} else if (currentElement == "CHART") { //성상
if pillChart == "" {
pillChart = string
}
} else if (currentElement == "ITEM_IMAGE") {//사진
if pillImage == "" {
pillImage = string
}
} else if (currentElement == "PRINT_FRONT") {
if pillFrontInprint == "" {
pillFrontInprint = string
}
} else if (currentElement == "PRINT_BACK") {
if pillBackInprint == "" {
pillBackInprint = string
}
} else if (currentElement == "DRUG_SHAPE") {
if pillShape == "" {
pillShape = string
}
} else if (currentElement == "COLOR_CLASS1") {
if pillFrontColor == "" {
pillFrontColor = string
}
} else if (currentElement == "COLOR_CLASS2") {
if pillBackColor == "" {
pillBackColor = string
}
} else if (currentElement == "LINE_FRONT") {
if pillFrontScore == "" {
pillFrontScore = string
}
} else if (currentElement == "LINE_BACK") {
if pillBackScore == "" {
pillBackScore = string
}
} else if (currentElement == "LENG_LONG") {
if pillLongSize == "" {
pillLongSize = string
}
} else if (currentElement == "LENG_SHORT") {
if pillShortSize == "" {
pillShortSize = string
}
} else if (currentElement == "THICK") {
if pillThick == "" {
pillThick = string
}
} else if (currentElement == "CLASS_NAME") { //분류번호에 있는거
if pillClassName == "" {
pillClassName = string
}
} else if (currentElement == "CLASS_NO") { //분류 번호
if pillClassNum == "" {
pillClassNum = string
}
} else if (currentElement == "FORM_CODE_NAME") {
if pillForm == "" {
pillForm = string
}
} else if (currentElement == "ETC_OTC_NAME") { //전문 기타 이런거
if pillEtcName == "" {
pillEtcName = string
}
}
}
}
//filtering func (when user select options)
func filteredPillData(filteredOption: [String : [String]]) {
DispatchQueue.global(qos: .userInitiated).async {
self.filteredData.removeAll()
for i in 0..<self.pillMap[1]!.count{
let data: MFTemporaryPillModel = self.pillMap[1]![i]
if (filteredOption["score"]?.contains(data.pillFrontScore))! && (filteredOption["color"]?.contains(data.pillFrontColor))! &&
(filteredOption["form"]?.contains(data.pillForm))! && (filteredOption["shape"]?.contains(data.pillShape))! {
self.filteredData.append(data)
self.mMFSearchPillMainView.mMFSearchPillView.mMFDisplayPillDataCollection.pillDataArray = self.filteredData
}
}
DispatchQueue.main.async {
self.mMFSearchPillMainView.mMFSearchPillView.mMFDisplayPillDataCollection.collectionView.reloadData()
}
}
swift multithreading parsing grand-central-dispatch
swift multithreading parsing grand-central-dispatch
edited Nov 12 '18 at 4:03
asked Nov 12 '18 at 2:52
sooyeon park
62
62
Sorry but this question is too vague and open ended. Focus on one specific issue and show relevant code about that one specific problem.
– rmaddy
Nov 12 '18 at 3:07
"Can I reduce the time for parsing" We don't know because you have not shown us any code at all. If you want help with your code, show it.
– matt
Nov 12 '18 at 3:17
add a comment |
Sorry but this question is too vague and open ended. Focus on one specific issue and show relevant code about that one specific problem.
– rmaddy
Nov 12 '18 at 3:07
"Can I reduce the time for parsing" We don't know because you have not shown us any code at all. If you want help with your code, show it.
– matt
Nov 12 '18 at 3:17
Sorry but this question is too vague and open ended. Focus on one specific issue and show relevant code about that one specific problem.
– rmaddy
Nov 12 '18 at 3:07
Sorry but this question is too vague and open ended. Focus on one specific issue and show relevant code about that one specific problem.
– rmaddy
Nov 12 '18 at 3:07
"Can I reduce the time for parsing" We don't know because you have not shown us any code at all. If you want help with your code, show it.
– matt
Nov 12 '18 at 3:17
"Can I reduce the time for parsing" We don't know because you have not shown us any code at all. If you want help with your code, show it.
– matt
Nov 12 '18 at 3:17
add a comment |
2 Answers
2
active
oldest
votes
You're running this at the .background
level. That is the level that means "I don't care if this completes today, or possibly ever." There is no promise that .background
tasks will ever be scheduled, and they are given the least possible resources. If 1m15s is too slow, you didn't mean .background
. Move this to .utility
if the user is not waiting on it, and .userInitiated
if the user is waiting on it. Then, if it's still too slow, run it through Instruments and see which piece is taking the longest time. Only then should you consider how to improve performance.
add a comment |
You are doing it wrong, your server is supposed to be returning all the pages you need in a lump sum.
Change the way the server is responding with what you want otherwise you are going to be making the user wait for multiple little calls, instead of a bulk return.
Once you have a bulk return you should sort through it. Much faster...
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53255400%2fswift-open-api-thread%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You're running this at the .background
level. That is the level that means "I don't care if this completes today, or possibly ever." There is no promise that .background
tasks will ever be scheduled, and they are given the least possible resources. If 1m15s is too slow, you didn't mean .background
. Move this to .utility
if the user is not waiting on it, and .userInitiated
if the user is waiting on it. Then, if it's still too slow, run it through Instruments and see which piece is taking the longest time. Only then should you consider how to improve performance.
add a comment |
You're running this at the .background
level. That is the level that means "I don't care if this completes today, or possibly ever." There is no promise that .background
tasks will ever be scheduled, and they are given the least possible resources. If 1m15s is too slow, you didn't mean .background
. Move this to .utility
if the user is not waiting on it, and .userInitiated
if the user is waiting on it. Then, if it's still too slow, run it through Instruments and see which piece is taking the longest time. Only then should you consider how to improve performance.
add a comment |
You're running this at the .background
level. That is the level that means "I don't care if this completes today, or possibly ever." There is no promise that .background
tasks will ever be scheduled, and they are given the least possible resources. If 1m15s is too slow, you didn't mean .background
. Move this to .utility
if the user is not waiting on it, and .userInitiated
if the user is waiting on it. Then, if it's still too slow, run it through Instruments and see which piece is taking the longest time. Only then should you consider how to improve performance.
You're running this at the .background
level. That is the level that means "I don't care if this completes today, or possibly ever." There is no promise that .background
tasks will ever be scheduled, and they are given the least possible resources. If 1m15s is too slow, you didn't mean .background
. Move this to .utility
if the user is not waiting on it, and .userInitiated
if the user is waiting on it. Then, if it's still too slow, run it through Instruments and see which piece is taking the longest time. Only then should you consider how to improve performance.
answered Nov 12 '18 at 4:33
Rob Napier
199k28293419
199k28293419
add a comment |
add a comment |
You are doing it wrong, your server is supposed to be returning all the pages you need in a lump sum.
Change the way the server is responding with what you want otherwise you are going to be making the user wait for multiple little calls, instead of a bulk return.
Once you have a bulk return you should sort through it. Much faster...
add a comment |
You are doing it wrong, your server is supposed to be returning all the pages you need in a lump sum.
Change the way the server is responding with what you want otherwise you are going to be making the user wait for multiple little calls, instead of a bulk return.
Once you have a bulk return you should sort through it. Much faster...
add a comment |
You are doing it wrong, your server is supposed to be returning all the pages you need in a lump sum.
Change the way the server is responding with what you want otherwise you are going to be making the user wait for multiple little calls, instead of a bulk return.
Once you have a bulk return you should sort through it. Much faster...
You are doing it wrong, your server is supposed to be returning all the pages you need in a lump sum.
Change the way the server is responding with what you want otherwise you are going to be making the user wait for multiple little calls, instead of a bulk return.
Once you have a bulk return you should sort through it. Much faster...
answered Nov 12 '18 at 4:42
Kingsley Mitchell
585318
585318
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53255400%2fswift-open-api-thread%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Sorry but this question is too vague and open ended. Focus on one specific issue and show relevant code about that one specific problem.
– rmaddy
Nov 12 '18 at 3:07
"Can I reduce the time for parsing" We don't know because you have not shown us any code at all. If you want help with your code, show it.
– matt
Nov 12 '18 at 3:17