-
-
Notifications
You must be signed in to change notification settings - Fork 313
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
48728b0
commit ecf222a
Showing
2 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
# Generates classes useful for testing of the performance of swizzling ViewControllers | ||
# with plenty of code and view controllers. | ||
# You can move the generated classes to a sample project and use the profiler to analyze | ||
# how long the swizzling takes. | ||
|
||
viewControllers="ViewControllers.swift" | ||
dsnStorage="DSNStorage.swift" | ||
|
||
if [ -f "$viewControllers" ] ; then | ||
rm "$viewControllers" | ||
fi | ||
|
||
if [ -f "$dsnStorage" ] ; then | ||
rm "$dsnStorage" | ||
fi | ||
|
||
for i in {1..1000} | ||
do | ||
echo "class ViewController$i: UIViewController { | ||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
} | ||
func$i() -> Bool { | ||
return true | ||
} | ||
}" >> $viewControllers | ||
done | ||
|
||
for i in {1..2000} | ||
do | ||
echo "class DSNStorage$i { | ||
static let shared = DSNStorage$i() | ||
private let dsnFile: URL | ||
private init() { | ||
// swiftlint:disable force_unwrapping | ||
let cachesDirectory = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask).first! | ||
// swiftlint:enable force_unwrapping | ||
dsnFile = cachesDirectory.appendingPathComponent(\"dsn\") | ||
} | ||
func saveDSN$i(dsn: String) { | ||
do { | ||
deleteDSN$i() | ||
try dsn.write(to: dsnFile, atomically: true, encoding: .utf8) | ||
} catch { | ||
SentrySDK.capture(error: error) | ||
} | ||
} | ||
func getDSN$i() -> String? { | ||
let fileManager = FileManager.default | ||
do { | ||
if fileManager.fileExists(atPath: dsnFile.path) { | ||
return try String(contentsOfFile: dsnFile.path) | ||
} | ||
} catch { | ||
SentrySDK.capture(error: error) | ||
} | ||
return nil | ||
} | ||
func deleteDSN$i() { | ||
let fileManager = FileManager.default | ||
do { | ||
if fileManager.fileExists(atPath: dsnFile.path) { | ||
try fileManager.removeItem(at: dsnFile) | ||
} | ||
} catch { | ||
SentrySDK.capture(error: error) | ||
} | ||
} | ||
}" >> $dsnStorage | ||
done | ||
|
||
|