forked from getsentry/sentry-cocoa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate-classes.sh
executable file
·84 lines (67 loc) · 2.01 KB
/
generate-classes.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
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 a$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