Skip to content

Commit

Permalink
Revert "add File I/O perf issue (ui.load, manual action) (#71)"
Browse files Browse the repository at this point in the history
This reverts commit 0ad014b.
  • Loading branch information
kpujjigit authored Nov 30, 2023
1 parent 0ad014b commit ca563bc
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 37 deletions.
12 changes: 2 additions & 10 deletions EmpowerPlant/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
<rect key="frame" x="20" y="0.0" width="374" height="0.0"/>
</progressView>
<stackView opaque="NO" contentMode="scaleToFill" verticalCompressionResistancePriority="751" alignment="top" translatesAutoresizingMaskIntoConstraints="NO" id="CCo-Yo-I2U">
<rect key="frame" x="8" y="0.0" width="398" height="379.5"/>
<rect key="frame" x="8" y="0.0" width="398" height="345"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" alignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="99H-zP-cDK">
<rect key="frame" x="0.0" y="0.0" width="199" height="310.5"/>
Expand Down Expand Up @@ -157,7 +157,7 @@
</subviews>
</stackView>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" alignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="KlN-al-BhV">
<rect key="frame" x="199" y="0.0" width="199" height="379.5"/>
<rect key="frame" x="199" y="0.0" width="199" height="345"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="esb-g7-ouy">
<rect key="frame" x="34" y="0.0" width="131.5" height="34.5"/>
Expand Down Expand Up @@ -239,14 +239,6 @@
<action selector="jsonMainThread:" destination="VXN-aD-u60" eventType="touchUpInside" id="iM7-uu-pjl"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="nuh-js-Myu">
<rect key="frame" x="29.5" y="345" width="140.5" height="34.5"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="File I/O on main"/>
<connections>
<action selector="fileIoOnMainThread:" destination="VXN-aD-u60" eventType="touchUpInside" id="WuA-Fh-H1D"/>
</connections>
</button>
</subviews>
</stackView>
</subviews>
Expand Down
9 changes: 0 additions & 9 deletions EmpowerPlant/EmpowerPlantViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ class EmpowerPlantViewController: UIViewController {
getAllProductsFromServer()
getAllProductsFromDb()
readCurrentDirectory()
performLongFileOperation()

NotificationCenter.default.addObserver(forName: modifiedDBNotificationName, object: nil, queue: nil) { _ in
self.getAllProductsFromDb()
Expand All @@ -62,14 +61,6 @@ class EmpowerPlantViewController: UIViewController {
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 readCurrentDirectory() {
let path = FileManager.default.currentDirectoryPath
do {
Expand Down
18 changes: 0 additions & 18 deletions EmpowerPlant/ListAppViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -290,24 +290,6 @@ class ListAppViewController: UIViewController {
span.finish()
}

@IBAction func fileIoOnMainThread(_ sender: Any) {
progressIndicator.isHidden = false
DispatchQueue.global(qos: .utility).async {
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)
DispatchQueue.main.async {
let transaction = SentrySDK.startTransaction(name: "test", operation: "fileio-on-main", bindToScope: true)
try! data.write(to: filePath)
transaction.finish()
self.progressIndicator.isHidden = true
DispatchQueue.global(qos: .utility).async {
try! FileManager.default.removeItem(at: filePath)
}
}
}
}

// !!!: profiling doesn't correctly collect backtraces with this (armcknight 12 Oct 2023)
func factorialRecursive(int x: BigInt) -> BigInt {
if x == 0 { return 1 }
Expand Down

0 comments on commit ca563bc

Please sign in to comment.