diff --git a/EmpowerPlant.xcodeproj/project.pbxproj b/EmpowerPlant.xcodeproj/project.pbxproj index 9c9d9ba..eaea8d6 100644 --- a/EmpowerPlant.xcodeproj/project.pbxproj +++ b/EmpowerPlant.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 843226DB2E29E12C000311A4 /* SlowOperations.swift in Sources */ = {isa = PBXBuildFile; fileRef = 843226DA2E29E12C000311A4 /* SlowOperations.swift */; }; 843BD60F2AD08CE900B0098F /* Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 843BD60E2AD08CE900B0098F /* Utils.swift */; }; 843BD6272AD7798C00B0098F /* jwt-deep-field.png in Resources */ = {isa = PBXBuildFile; fileRef = 843BD6262AD7798C00B0098F /* jwt-deep-field.png */; }; 846BEA1C2ABE611A0032F77F /* mobydick.txt in Resources */ = {isa = PBXBuildFile; fileRef = 846BEA1B2ABE611A0032F77F /* mobydick.txt */; }; @@ -40,6 +41,7 @@ /* Begin PBXFileReference section */ 840B7EF12BBF3C70008B8120 /* .slather.yml */ = {isa = PBXFileReference; lastKnownFileType = text.yaml; path = .slather.yml; sourceTree = ""; }; + 843226DA2E29E12C000311A4 /* SlowOperations.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SlowOperations.swift; sourceTree = ""; }; 843BD60E2AD08CE900B0098F /* Utils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Utils.swift; sourceTree = ""; }; 843BD6262AD7798C00B0098F /* jwt-deep-field.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "jwt-deep-field.png"; sourceTree = ""; }; 846BEA1A2ABE46880032F77F /* upload-symbols.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "upload-symbols.sh"; sourceTree = ""; }; @@ -130,6 +132,7 @@ 843BD60E2AD08CE900B0098F /* Utils.swift */, D15FCDA727E00F0D00258BF3 /* Model.xcdatamodeld */, D17C73CB27D82EB8006650AF /* EmpowerPlantViewController.swift */, + 843226DA2E29E12C000311A4 /* SlowOperations.swift */, 846BEA1B2ABE611A0032F77F /* mobydick.txt */, D19EBE6E2805ED52007022DC /* ShoppingCart.swift */, D17C73CE27D82ED1006650AF /* CartViewController.swift */, @@ -283,6 +286,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 843226DB2E29E12C000311A4 /* SlowOperations.swift in Sources */, D17C73CC27D82EB8006650AF /* EmpowerPlantViewController.swift in Sources */, D17C73D227D83321006650AF /* ListAppViewController.swift in Sources */, D15EDF14282BF80400FC13D6 /* Product+CoreDataClass.swift in Sources */, diff --git a/EmpowerPlant.xcodeproj/xcshareddata/xcschemes/EmpowerPlant.xcscheme b/EmpowerPlant.xcodeproj/xcshareddata/xcschemes/EmpowerPlant.xcscheme index 58887b7..6a2a419 100644 --- a/EmpowerPlant.xcodeproj/xcshareddata/xcschemes/EmpowerPlant.xcscheme +++ b/EmpowerPlant.xcodeproj/xcshareddata/xcschemes/EmpowerPlant.xcscheme @@ -72,6 +72,10 @@ argument = "--wipe-db" isEnabled = "NO"> + + diff --git a/EmpowerPlant/EmpowerPlantViewController.swift b/EmpowerPlant/EmpowerPlantViewController.swift index 9056e79..a2f6870 100644 --- a/EmpowerPlant/EmpowerPlantViewController.swift +++ b/EmpowerPlant/EmpowerPlantViewController.swift @@ -49,12 +49,9 @@ class EmpowerPlantViewController: UIViewController { getAllProductsFromServer() getAllProductsFromDb() - readCurrentDirectory() - performLongFileOperation() processProducts() checkRelease() - - + NotificationCenter.default.addObserver(forName: modifiedDBNotificationName, object: nil, queue: nil) { _ in self.getAllProductsFromDb() } @@ -62,86 +59,21 @@ class EmpowerPlantViewController: UIViewController { override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) + + if !ProcessInfo.processInfo.arguments.contains("--skip-slow-launch-work") { + SlowOperation.fileRead() + SlowOperation.fileWrite() + } + SentrySDK.reportFullyDisplayed() } - - func performLongFileOperation() { - let longString = String(repeating: UUID().uuidString, count: 5_000_000) - let data = longString.data(using: .utf8)! - let filePath = FileManager.default.temporaryDirectory.appendingPathComponent("tmp" + UUID().uuidString) - try! data.write(to: filePath) - try! FileManager.default.removeItem(at: filePath) - } func processProducts() { let span = SentrySDK.span?.startChild(operation: "product_processing") - _ = getIterator(42); - sleep(50 / 1000) - span?.finish() - } - - func getIterator(_ n: Int) -> Int { - if (n <= 0) { - return 0; - } - if (n == 1 || n == 2) { - return 1; - } - return getIterator(n - 1) + getIterator(n - 2); - } - - - func readCurrentDirectory() { - let path = FileManager.default.currentDirectoryPath - do { - let items = try FileManager.default.contentsOfDirectory(atPath: path) - let loop = fibonacciSeries(num: items.count) - for i in 1...loop { - readDirectory(path: path) - } - } catch { - // TODO: error - } - } - - func readDirectory(path: String) { - let fm = FileManager.default - - do { - let items = try fm.contentsOfDirectory(atPath: path) - - for item in items { - var isDirectory: ObjCBool = false - if fm.fileExists(atPath: item, isDirectory: &isDirectory) { - readDirectory(path: item) - } else { - return - } - } - } catch { - // TODO: error + if !ProcessInfo.processInfo.arguments.contains("--skip-slow-launch-work") { + SlowOperation.computation() } - - } - - func fibonacciSeries(num: Int) -> Int{ - // The value of 0th and 1st number of the fibonacci series are 0 and 1 - var n1 = 0 - var n2 = 1 - - // To store the result - var nR = 0 - // Adding two previous numbers to find ith number of the series - for _ in 0.. Int{ + // The value of 0th and 1st number of the fibonacci series are 0 and 1 + var n1 = 0 + var n2 = 1 + + // To store the result + var nR = 0 + // Adding two previous numbers to find ith number of the series + for _ in 0.. Int { + if (n <= 0) { + return 0; + } + if (n == 1 || n == 2) { + return 1; + } + return getIterator(n - 1) + getIterator(n - 2); + } +}