Skip to content

Commit

Permalink
feat: Regex on Main Thread profiling issue (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
armcknight authored Oct 12, 2023
1 parent fc2965f commit 3576aac
Show file tree
Hide file tree
Showing 4 changed files with 22,337 additions and 8 deletions.
4 changes: 4 additions & 0 deletions EmpowerPlant.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

/* Begin PBXBuildFile section */
674899180B469D888700A555 /* Pods_EmpowerPlant.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 74014747DE857D26E9BD7B24 /* Pods_EmpowerPlant.framework */; };
846BEA1C2ABE611A0032F77F /* mobydick.txt in Resources */ = {isa = PBXBuildFile; fileRef = 846BEA1B2ABE611A0032F77F /* mobydick.txt */; };
843BD60F2AD08CE900B0098F /* Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 843BD60E2AD08CE900B0098F /* Utils.swift */; };
8B21663C29D3F8C80009C890 /* RandomErrors.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8B21663B29D3F8C80009C890 /* RandomErrors.swift */; };
8BA3AB382A20212C00BE1EA8 /* CartViewControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8BA3AB372A20212C00BE1EA8 /* CartViewControllerTests.swift */; };
Expand Down Expand Up @@ -41,6 +42,7 @@
843BD60E2AD08CE900B0098F /* Utils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Utils.swift; sourceTree = "<group>"; };
846BEA1A2ABE46880032F77F /* upload-symbols.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "upload-symbols.sh"; sourceTree = "<group>"; };
8474F0482ACCE2D800F21E06 /* deploy_project.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = deploy_project.sh; sourceTree = "<group>"; };
846BEA1B2ABE611A0032F77F /* mobydick.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = mobydick.txt; sourceTree = "<group>"; };
8474F04D2ACE54F300F21E06 /* .github */ = {isa = PBXFileReference; lastKnownFileType = folder; path = .github; sourceTree = "<group>"; };
84A264182AA9155800A62A88 /* Makefile */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = "<group>"; };
84A264192AA915B100A62A88 /* Brewfile */ = {isa = PBXFileReference; lastKnownFileType = text; path = Brewfile; sourceTree = "<group>"; };
Expand Down Expand Up @@ -135,6 +137,7 @@
843BD60E2AD08CE900B0098F /* Utils.swift */,
D15FCDA727E00F0D00258BF3 /* Model.xcdatamodeld */,
D17C73CB27D82EB8006650AF /* EmpowerPlantViewController.swift */,
846BEA1B2ABE611A0032F77F /* mobydick.txt */,
D19EBE6E2805ED52007022DC /* ShoppingCart.swift */,
D17C73CE27D82ED1006650AF /* CartViewController.swift */,
D17C73BB27D8291D006650AF /* Assets.xcassets */,
Expand Down Expand Up @@ -243,6 +246,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
846BEA1C2ABE611A0032F77F /* mobydick.txt in Resources */,
D17C73BF27D8291D006650AF /* LaunchScreen.storyboard in Resources */,
D17C73BC27D8291D006650AF /* Assets.xcassets in Resources */,
D17C73BA27D8291D006650AF /* Main.storyboard in Resources */,
Expand Down
18 changes: 10 additions & 8 deletions EmpowerPlant/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,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="276"/>
<rect key="frame" x="199" y="0.0" width="199" height="310.5"/>
<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 @@ -199,8 +199,16 @@
<action selector="unwrapCrash:" destination="VXN-aD-u60" eventType="touchUpInside" id="1ao-hi-gPI"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Yrg-wG-isT">
<rect key="frame" x="5" y="241.5" width="189.5" height="34.5"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="Regex on main thread"/>
<connections>
<action selector="regexOnMainThread:" destination="VXN-aD-u60" eventType="touchUpInside" id="abO-hY-sPP"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="YJc-z6-Cm2">
<rect key="frame" x="6.5" y="241.5" width="186.5" height="34.5"/>
<rect key="frame" x="6.5" y="276" width="186.5" height="34.5"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="JSON on main thread"/>
<connections>
Expand Down Expand Up @@ -269,11 +277,5 @@
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
<systemColor name="systemGreenColor">
<color red="0.20392156859999999" green="0.78039215689999997" blue="0.34901960780000002" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
<systemColor name="systemYellowColor">
<color red="1" green="0.80000000000000004" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
</resources>
</document>
8 changes: 8 additions & 0 deletions EmpowerPlant/ListAppViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -277,4 +277,12 @@ class ListAppViewController: UIViewController {
}
}
}

@IBAction func regexOnMainThread(_ sender: Any) {
let string = try! String(contentsOf: Bundle.main.url(forResource: "mobydick", withExtension: "txt")!)
let regex = try! NSRegularExpression(pattern: "([Tt]he)?.*([Ww]hale)")
let span = SentrySDK.startTransaction(name: "test", operation: "regex-on-main")
regex.matches(in: string, range: NSMakeRange(0, string.count))
span.finish()
}
}
Loading

0 comments on commit 3576aac

Please sign in to comment.