xcpretty-profiler-formatter 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +22 -0
- data/README.md +41 -0
- data/bin/xcpretty-profiler-formatter +3 -0
- data/lib/profiler_formatter.rb +91 -0
- metadata +78 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e6f15a0b4209845450e794c08e71942bc8e9cfdc
|
4
|
+
data.tar.gz: edc49b99c0ef5d31c2c1f8b8c6a1c7717e9e20be
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f6ed0e8a90af9820342cae72b2450b6b917fa71f2ce22b739c7e12ff3379ffd83ee9442247f80622a1ba2f6906227b44b117d0f8da7415e3ededa60cb8b108a3
|
7
|
+
data.tar.gz: 4728611654b91fb15a939fb7c49e414e994bc5c0482aa09975ac67873242b12f09b9bb5c6c19f5b2504d7ca58453cff0c5f1167f963fdc87527c35dbd3563d18
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Lars Lockefeer
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# XCPretty Profiler Formatter
|
2
|
+
|
3
|
+
Custom formatter for [xcpretty](https://github.com/supermarin/xcpretty) that calculates the compile time for files in Xcode projects and prints them to `stdout`.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Run:
|
8
|
+
|
9
|
+
```
|
10
|
+
gem install xcpretty-profiler-formatter
|
11
|
+
```
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
Specify `xcpretty-profiler-formatter` as a custom formatter to `xcpretty`:
|
16
|
+
|
17
|
+
```bash
|
18
|
+
#!/bin/bash
|
19
|
+
|
20
|
+
xcodebuild -project "Project.xcodeproj" clean build | xcpretty -f `xcpretty-profiler-formatter`
|
21
|
+
```
|
22
|
+
|
23
|
+
## Sample output
|
24
|
+
|
25
|
+
```
|
26
|
+
xcodebuild -workspace BrightFutures.xcworkspace -scheme BrightFutures-iOS clean build | xcpretty -f `xcpretty-profiler-formatter`
|
27
|
+
|
28
|
+
[...]
|
29
|
+
|
30
|
+
[0.2616] Source/BrightFutures/BrightFutures/Async.swift
|
31
|
+
[1.0931] Source/BrightFutures/Carthage/Checkouts/Result/Result/ResultType.swift
|
32
|
+
[1.1641] Source/BrightFutures/BrightFutures/Errors.swift
|
33
|
+
[1.1724] Source/BrightFutures/BrightFutures/Errors.swift
|
34
|
+
[1.7121] Source/BrightFutures/Carthage/Checkouts/Result/Result/ResultType.swift
|
35
|
+
-----
|
36
|
+
[7.4310] Total compilation time
|
37
|
+
```
|
38
|
+
|
39
|
+
## Author
|
40
|
+
|
41
|
+
* Lars Lockefeer ([@larslockefeer](https://twitter.com/larslockefeer))
|
@@ -0,0 +1,91 @@
|
|
1
|
+
class ProfilerFormatter < XCPretty::Formatter
|
2
|
+
|
3
|
+
def initialize(use_unicode, colorize)
|
4
|
+
super(use_unicode, colorize)
|
5
|
+
@compilation_phases = []
|
6
|
+
@current_compilation_phase = []
|
7
|
+
@compilation_phase_end_times = []
|
8
|
+
end
|
9
|
+
|
10
|
+
# For each file that we compile, track the current timestamp
|
11
|
+
def format_compile(file_name, file_path)
|
12
|
+
mark_compilation(file_path, file_name)
|
13
|
+
EMPTY;
|
14
|
+
end
|
15
|
+
|
16
|
+
def format_compile_command(compiler_command, file_path)
|
17
|
+
mark_compilation(file_path, nil)
|
18
|
+
EMPTY;
|
19
|
+
end
|
20
|
+
|
21
|
+
# Every time we enter the linking phase, we wrap up a compilation phase
|
22
|
+
# Store statistics for the current phase and set up for a new phase
|
23
|
+
def format_linking(file, build_variant, arch)
|
24
|
+
start_new_compilation_phase
|
25
|
+
EMPTY;
|
26
|
+
end
|
27
|
+
|
28
|
+
# When the build succeeded, we can generate our statistics and print them to the console
|
29
|
+
def format_phase_success(phase_name)
|
30
|
+
unless @current_compilation_phase.empty?
|
31
|
+
start_new_compilation_phase
|
32
|
+
end
|
33
|
+
|
34
|
+
if phase_name == "BUILD"
|
35
|
+
compile_times = calculate_compile_times
|
36
|
+
compile_times.sort_by { | compilation |
|
37
|
+
compilation[:compile_time]
|
38
|
+
}.each do | compilation |
|
39
|
+
puts "[#{format("%.4f", compilation[:compile_time])}] #{compilation[:file_path]}"
|
40
|
+
end
|
41
|
+
|
42
|
+
total_time = compile_times.reduce(0) { | acc, compilation |
|
43
|
+
acc + compilation[:compile_time]
|
44
|
+
}
|
45
|
+
puts "-----"
|
46
|
+
puts "[#{format("%.4f", total_time)}] Total compilation time"
|
47
|
+
end
|
48
|
+
EMPTY;
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def mark_compilation(file_path, file_name)
|
54
|
+
@current_compilation_phase.push({
|
55
|
+
:start_time => Time.now,
|
56
|
+
:file_path => file_path,
|
57
|
+
:file_name => file_name
|
58
|
+
})
|
59
|
+
end
|
60
|
+
|
61
|
+
def start_new_compilation_phase
|
62
|
+
@compilation_phase_end_times.push(Time.now)
|
63
|
+
@compilation_phases.push(@current_compilation_phase)
|
64
|
+
@current_compilation_phase = []
|
65
|
+
end
|
66
|
+
|
67
|
+
def calculate_compile_times
|
68
|
+
compile_times = []
|
69
|
+
@compilation_phases.each_with_index do | compilation_phase, i |
|
70
|
+
compilation_phase.each_with_index do | compilation, j |
|
71
|
+
if j < (compilation_phase.count - 1) && compilation[:file_name]
|
72
|
+
compile_times.push({
|
73
|
+
:file_path => compilation[:file_path],
|
74
|
+
:file_name => compilation[:file_name],
|
75
|
+
:compile_time => compilation_phase[j+1][:start_time].to_f - compilation[:start_time].to_f
|
76
|
+
})
|
77
|
+
elsif j == compilation_phase.count - 1 && compilation[:file_name]
|
78
|
+
compile_times.push({
|
79
|
+
:file_path => compilation[:file_path],
|
80
|
+
:file_name => compilation[:file_name],
|
81
|
+
:compile_time => @compilation_phase_end_times[i].to_f - compilation[:start_time].to_f
|
82
|
+
})
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
return compile_times
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
ProfilerFormatter
|
metadata
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: xcpretty-profiler-formatter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Lars Lockefeer
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-01-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: xcpretty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
description: "\n xcpretty formatter that profiles build times for Xcode projects\n
|
42
|
+
\ "
|
43
|
+
email:
|
44
|
+
- lars.lockefeer@teampicnic.com
|
45
|
+
executables:
|
46
|
+
- xcpretty-profiler-formatter
|
47
|
+
extensions: []
|
48
|
+
extra_rdoc_files: []
|
49
|
+
files:
|
50
|
+
- LICENSE
|
51
|
+
- README.md
|
52
|
+
- bin/xcpretty-profiler-formatter
|
53
|
+
- lib/profiler_formatter.rb
|
54
|
+
homepage: https://github.com/PicnicSupermarket/xcpretty-profiler-formatter
|
55
|
+
licenses:
|
56
|
+
- MIT
|
57
|
+
metadata: {}
|
58
|
+
post_install_message:
|
59
|
+
rdoc_options: []
|
60
|
+
require_paths:
|
61
|
+
- lib
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - "~>"
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '2.0'
|
67
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
requirements: []
|
73
|
+
rubyforge_project:
|
74
|
+
rubygems_version: 2.4.8
|
75
|
+
signing_key:
|
76
|
+
specification_version: 4
|
77
|
+
summary: xcpretty formatter that profiles build times for Xcode projects
|
78
|
+
test_files: []
|