From 506b979c97faaa8f7f7cc50f107e1aeed17e4d0c Mon Sep 17 00:00:00 2001 From: Andrew McKnight Date: Wed, 11 Oct 2023 17:36:26 -0800 Subject: [PATCH 1/2] feat: decode a large JSON on the main thread --- EmpowerPlant/Base.lproj/Main.storyboard | 290 ++++++++++++----------- EmpowerPlant/ListAppViewController.swift | 23 ++ 2 files changed, 179 insertions(+), 134 deletions(-) diff --git a/EmpowerPlant/Base.lproj/Main.storyboard b/EmpowerPlant/Base.lproj/Main.storyboard index 998cc56..03e65af 100644 --- a/EmpowerPlant/Base.lproj/Main.storyboard +++ b/EmpowerPlant/Base.lproj/Main.storyboard @@ -61,7 +61,7 @@ - + @@ -69,137 +69,153 @@ - + - - + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -208,17 +224,23 @@ - - - - + + + + + + - + + + + + diff --git a/EmpowerPlant/ListAppViewController.swift b/EmpowerPlant/ListAppViewController.swift index 475c26e..6fd0bd5 100644 --- a/EmpowerPlant/ListAppViewController.swift +++ b/EmpowerPlant/ListAppViewController.swift @@ -253,4 +253,27 @@ class ListAppViewController: UIViewController { @IBAction func close(_ sender: Any) { SentrySDK.close() } + + @IBOutlet weak var progressIndicator: UIProgressView! + @IBAction func jsonMainThread(_ sender: Any) { + // build up a huge JSON structure + progressIndicator.isHidden = false + DispatchQueue.global(qos: .utility).async { + var dict = [String: String]() + let limit = 10_000_000 + for i in 0.. Date: Wed, 11 Oct 2023 17:39:21 -0800 Subject: [PATCH 2/2] make it faster --- EmpowerPlant/ListAppViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EmpowerPlant/ListAppViewController.swift b/EmpowerPlant/ListAppViewController.swift index 6fd0bd5..620a031 100644 --- a/EmpowerPlant/ListAppViewController.swift +++ b/EmpowerPlant/ListAppViewController.swift @@ -260,7 +260,7 @@ class ListAppViewController: UIViewController { progressIndicator.isHidden = false DispatchQueue.global(qos: .utility).async { var dict = [String: String]() - let limit = 10_000_000 + let limit = 1_000_000 for i in 0..