Skip to content

Commit 82ff9eb

Browse files
committed
Adding all the files
1 parent f010b9f commit 82ff9eb

File tree

3 files changed

+397
-0
lines changed

3 files changed

+397
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,328 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>AMApplicationBuild</key>
6+
<string>419</string>
7+
<key>AMApplicationVersion</key>
8+
<string>2.6</string>
9+
<key>AMDocumentVersion</key>
10+
<string>2</string>
11+
<key>actions</key>
12+
<array>
13+
<dict>
14+
<key>action</key>
15+
<dict>
16+
<key>AMAccepts</key>
17+
<dict>
18+
<key>Container</key>
19+
<string>List</string>
20+
<key>Optional</key>
21+
<true/>
22+
<key>Types</key>
23+
<array>
24+
<string>com.apple.cocoa.path</string>
25+
</array>
26+
</dict>
27+
<key>AMActionVersion</key>
28+
<string>2.1.1</string>
29+
<key>AMApplication</key>
30+
<array>
31+
<string>Finder</string>
32+
</array>
33+
<key>AMParameterProperties</key>
34+
<dict/>
35+
<key>AMProvides</key>
36+
<dict>
37+
<key>Container</key>
38+
<string>List</string>
39+
<key>Types</key>
40+
<array>
41+
<string>com.apple.cocoa.path</string>
42+
</array>
43+
</dict>
44+
<key>AMRequiredResources</key>
45+
<array/>
46+
<key>ActionBundlePath</key>
47+
<string>/System/Library/Automator/Get Selected Finder Items 2.action</string>
48+
<key>ActionName</key>
49+
<string>Get Selected Finder Items</string>
50+
<key>ActionParameters</key>
51+
<dict/>
52+
<key>BundleIdentifier</key>
53+
<string>com.apple.Automator.Get_Selected_Finder_Items_2</string>
54+
<key>CFBundleVersion</key>
55+
<string>2.1.1</string>
56+
<key>CanShowSelectedItemsWhenRun</key>
57+
<false/>
58+
<key>CanShowWhenRun</key>
59+
<true/>
60+
<key>Category</key>
61+
<array>
62+
<string>AMCategoryFilesAndFolders</string>
63+
</array>
64+
<key>Class Name</key>
65+
<string>AMGetSelectedFinderItemsAction</string>
66+
<key>Disabled</key>
67+
<false/>
68+
<key>InputUUID</key>
69+
<string>EBF69AF3-F295-47F3-8F5E-E66800D7D149</string>
70+
<key>Keywords</key>
71+
<array/>
72+
<key>OutputUUID</key>
73+
<string>4D0DE121-C9BC-485B-A790-C5731E533647</string>
74+
<key>UUID</key>
75+
<string>92B86DD3-B5B0-45B2-995B-201516A165E2</string>
76+
<key>UnlocalizedApplications</key>
77+
<array>
78+
<string>Finder</string>
79+
</array>
80+
<key>arguments</key>
81+
<dict/>
82+
</dict>
83+
</dict>
84+
<dict>
85+
<key>action</key>
86+
<dict>
87+
<key>AMAccepts</key>
88+
<dict>
89+
<key>Container</key>
90+
<string>List</string>
91+
<key>Optional</key>
92+
<true/>
93+
<key>Types</key>
94+
<array>
95+
<string>com.apple.cocoa.string</string>
96+
</array>
97+
</dict>
98+
<key>AMActionVersion</key>
99+
<string>2.0.3</string>
100+
<key>AMApplication</key>
101+
<array>
102+
<string>Automator</string>
103+
</array>
104+
<key>AMParameterProperties</key>
105+
<dict>
106+
<key>COMMAND_STRING</key>
107+
<dict/>
108+
<key>CheckedForUserDefaultShell</key>
109+
<dict/>
110+
<key>inputMethod</key>
111+
<dict/>
112+
<key>shell</key>
113+
<dict/>
114+
<key>source</key>
115+
<dict/>
116+
</dict>
117+
<key>AMProvides</key>
118+
<dict>
119+
<key>Container</key>
120+
<string>List</string>
121+
<key>Types</key>
122+
<array>
123+
<string>com.apple.cocoa.string</string>
124+
</array>
125+
</dict>
126+
<key>ActionBundlePath</key>
127+
<string>/System/Library/Automator/Run Shell Script.action</string>
128+
<key>ActionName</key>
129+
<string>Run Shell Script</string>
130+
<key>ActionParameters</key>
131+
<dict>
132+
<key>COMMAND_STRING</key>
133+
<string>#!/usr/bin/env ruby
134+
require 'pathname'
135+
136+
exit 1 unless ARGV[0]
137+
138+
full_file_path = File.expand_path("#{ARGV[0]}")
139+
140+
puts "got file path: #{full_file_path}"
141+
142+
exit 1 unless File.extname(full_file_path) == '.xcactivitylog'
143+
144+
puts "it's an activity log!"
145+
146+
basename = Pathname.new("#{full_file_path}").basename.to_s
147+
148+
puts "base: #{basename}"
149+
150+
gzipped_file_name = basename + '.gz'
151+
152+
puts "gzipped: #{gzipped_file_name}"
153+
154+
tmp_gzipped_file_name = "/tmp/#{gzipped_file_name}"
155+
156+
puts "tmp: #{tmp_gzipped_file_name}"
157+
158+
# Create base file name and translated base file name
159+
unzipped_base_file_name = "/tmp/#{basename}"
160+
unzipped_translated_base_file_name = "/tmp/#{basename}-translated"
161+
162+
# Create base analyze file name and path
163+
analyzed_file_name = "#{basename}-swift-analysis.txt"
164+
analyzed_tmp_file_name = "/tmp/#{analyzed_file_name}"
165+
166+
# Make a copy of the file with the gzip extension
167+
copy_status = `cp "#{full_file_path}" "#{tmp_gzipped_file_name}"`
168+
unzip_status = `gzip -d #{tmp_gzipped_file_name}`
169+
translate_status = `tr '\r' '\n' &lt;#{unzipped_base_file_name} &gt;#{unzipped_translated_base_file_name}`
170+
analysis_status = `cat #{unzipped_translated_base_file_name} | grep '[1-9].[0-9]ms' | sort -nr &gt; "#{analyzed_tmp_file_name}"`
171+
172+
copy_desktop_status = `cp #{analyzed_tmp_file_name} ~/Desktop/#{analyzed_file_name}`
173+
174+
removal_status = `rm #{unzipped_base_file_name} #{unzipped_translated_base_file_name} #{analyzed_tmp_file_name}`
175+
176+
puts "Swift Analysis Complete!"
177+
</string>
178+
<key>CheckedForUserDefaultShell</key>
179+
<true/>
180+
<key>inputMethod</key>
181+
<integer>1</integer>
182+
<key>shell</key>
183+
<string>/usr/bin/ruby</string>
184+
<key>source</key>
185+
<string></string>
186+
</dict>
187+
<key>BundleIdentifier</key>
188+
<string>com.apple.RunShellScript</string>
189+
<key>CFBundleVersion</key>
190+
<string>2.0.3</string>
191+
<key>CanShowSelectedItemsWhenRun</key>
192+
<false/>
193+
<key>CanShowWhenRun</key>
194+
<true/>
195+
<key>Category</key>
196+
<array>
197+
<string>AMCategoryUtilities</string>
198+
</array>
199+
<key>Class Name</key>
200+
<string>RunShellScriptAction</string>
201+
<key>InputUUID</key>
202+
<string>4C5A842D-5895-4DCE-AD9E-87C5E8813A12</string>
203+
<key>Keywords</key>
204+
<array>
205+
<string>Shell</string>
206+
<string>Script</string>
207+
<string>Command</string>
208+
<string>Run</string>
209+
<string>Unix</string>
210+
</array>
211+
<key>OutputUUID</key>
212+
<string>8DAB5B01-F298-432B-AF72-D78227A0A5D6</string>
213+
<key>ShowWhenRun</key>
214+
<false/>
215+
<key>StartAction</key>
216+
<false/>
217+
<key>UUID</key>
218+
<string>98900C5A-FEB9-4E85-90CC-644B4674EDFA</string>
219+
<key>UnlocalizedApplications</key>
220+
<array>
221+
<string>Automator</string>
222+
</array>
223+
<key>arguments</key>
224+
<dict>
225+
<key>0</key>
226+
<dict>
227+
<key>default value</key>
228+
<integer>0</integer>
229+
<key>name</key>
230+
<string>inputMethod</string>
231+
<key>required</key>
232+
<string>0</string>
233+
<key>type</key>
234+
<string>0</string>
235+
<key>uuid</key>
236+
<string>0</string>
237+
</dict>
238+
<key>1</key>
239+
<dict>
240+
<key>default value</key>
241+
<string></string>
242+
<key>name</key>
243+
<string>source</string>
244+
<key>required</key>
245+
<string>0</string>
246+
<key>type</key>
247+
<string>0</string>
248+
<key>uuid</key>
249+
<string>1</string>
250+
</dict>
251+
<key>2</key>
252+
<dict>
253+
<key>default value</key>
254+
<false/>
255+
<key>name</key>
256+
<string>CheckedForUserDefaultShell</string>
257+
<key>required</key>
258+
<string>0</string>
259+
<key>type</key>
260+
<string>0</string>
261+
<key>uuid</key>
262+
<string>2</string>
263+
</dict>
264+
<key>3</key>
265+
<dict>
266+
<key>default value</key>
267+
<string></string>
268+
<key>name</key>
269+
<string>COMMAND_STRING</string>
270+
<key>required</key>
271+
<string>0</string>
272+
<key>type</key>
273+
<string>0</string>
274+
<key>uuid</key>
275+
<string>3</string>
276+
</dict>
277+
<key>4</key>
278+
<dict>
279+
<key>default value</key>
280+
<string>/bin/sh</string>
281+
<key>name</key>
282+
<string>shell</string>
283+
<key>required</key>
284+
<string>0</string>
285+
<key>type</key>
286+
<string>0</string>
287+
<key>uuid</key>
288+
<string>4</string>
289+
</dict>
290+
</dict>
291+
<key>isViewVisible</key>
292+
<true/>
293+
<key>location</key>
294+
<string>581.000000:805.000000</string>
295+
<key>nibPath</key>
296+
<string>/System/Library/Automator/Run Shell Script.action/Contents/Resources/English.lproj/main.nib</string>
297+
</dict>
298+
<key>isViewVisible</key>
299+
<true/>
300+
</dict>
301+
</array>
302+
<key>connectors</key>
303+
<dict>
304+
<key>4D18A5F0-A2E2-40C2-ADD7-AA433DB9B7EA</key>
305+
<dict>
306+
<key>from</key>
307+
<string>92B86DD3-B5B0-45B2-995B-201516A165E2 - 92B86DD3-B5B0-45B2-995B-201516A165E2</string>
308+
<key>to</key>
309+
<string>98900C5A-FEB9-4E85-90CC-644B4674EDFA - 98900C5A-FEB9-4E85-90CC-644B4674EDFA</string>
310+
</dict>
311+
</dict>
312+
<key>workflowMetaData</key>
313+
<dict>
314+
<key>serviceApplicationBundleID</key>
315+
<string>com.apple.finder</string>
316+
<key>serviceApplicationPath</key>
317+
<string>/System/Library/CoreServices/Finder.app</string>
318+
<key>serviceInputTypeIdentifier</key>
319+
<string>com.apple.Automator.fileSystemObject</string>
320+
<key>serviceOutputTypeIdentifier</key>
321+
<string>com.apple.Automator.nothing</string>
322+
<key>serviceProcessesInput</key>
323+
<integer>0</integer>
324+
<key>workflowTypeIdentifier</key>
325+
<string>com.apple.Automator.servicesMenu</string>
326+
</dict>
327+
</dict>
328+
</plist>

README.md

+25
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,27 @@
11
# Swift-Analysis-Workflow
22
Make it easier to see what's making your build slow.
3+
4+
You can add flags to the Swift compiler to add new build output to track down slow functions, however browsing this output in Xcode sucks, this workflow will produce a file sorted by time to compile on your Desktop.
5+
6+
# Prerequisites
7+
You need to have the Swift profiling code turned on for your targets in order to produce the desired output. If you need help doing that, please check out Bryan Irace's fantastic [post](http://irace.me/swift-profiling/) to learn how to turn it on!
8+
9+
# How To Use
10+
1. Double click on the `Analyze Swift Performance.workflow` file.
11+
2. Choose "Install"
12+
3. Find an `.xcactivitylog` file, mine are in `~/Developer/Xcode/DerivedData/<project>`
13+
4. Right click on the file and in the Services menu, click "Analyze Swift Performance"
14+
15+
A file will eventually show up on you Desktop ending in `-analysis.txt`
16+
17+
# Caveats
18+
* This thing is slow (it's doing crude analysis on large text files)
19+
* Automator is pretty crappy, maybe I'm doing something wrong, please help!
20+
* If you select things that aren't `.xcactivitylog` it will bail early
21+
* It would be really cool to embed the Ruby script in the workflow as a different file, would _REALLY_ like someone to show me if that's possible.
22+
* This relies on `.xcactivitylog` files being the input as they are structured in a unique way for processing.
23+
24+
# Thanks
25+
Big thanks to [@irace](https://www.twitter.com/irace) as he and I were talking about this very problem recently and he helped with some of the shell scripts!
26+
27+
If you have any questions about contributing or whatever, please feel free to drop me a line on Twitter I'm just [@brianmichel](https://www.twitter.com/brianmichel).

0 commit comments

Comments
 (0)