xcpretty-travis-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 +42 -0
- data/bin/xcpretty-travis-profiler-formatter +3 -0
- data/lib/travis_profiler_formatter.rb +136 -0
- metadata +84 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: eed1be6c6fe81977a21ab56e023838b86f769de9
|
4
|
+
data.tar.gz: 886ef24d20a6d02808fe1cb99b3711d01575e058
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 10bbff30e631b277bd964200c57ba642343183e5166998cf241078f229404f5da1630809de64363cb22c4a66ed725906835143808f9eef785037f30f2fd067f1
|
7
|
+
data.tar.gz: e8a27465114ec78f0adbe488286f0b2ec8adaf2accc82bc8212adc62f336655bfcea878367e65385876b659adc0b244fd2c26ab88331ed0bae8d0c7772cb2e14
|
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,42 @@
|
|
1
|
+
# XCPretty Travis 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` formatted for Travis.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Run:
|
8
|
+
|
9
|
+
```
|
10
|
+
gem install xcpretty-travis-profiler-formatter
|
11
|
+
```
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
Specify `xcpretty-travis-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-travis-profiler-formatter`
|
21
|
+
```
|
22
|
+
|
23
|
+
## Sample output
|
24
|
+
|
25
|
+
```
|
26
|
+
xcodebuild -workspace BrightFutures.xcworkspace -scheme BrightFutures-iOS clean build | xcpretty -f `xcpretty-travis-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))
|
42
|
+
* Modified by Daniel Miedema ([@no_good_ones](https://twitter.com/no_good_ones))
|
@@ -0,0 +1,136 @@
|
|
1
|
+
class TravisProfilerFormatter < 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
|
+
|
90
|
+
###
|
91
|
+
### Travis Formatting
|
92
|
+
###
|
93
|
+
# from https://github.com/kattrali/xcpretty-travis-formatter
|
94
|
+
def open_fold(text)
|
95
|
+
return if text == @open_fold
|
96
|
+
close_fold(@open_fold) if @open_fold
|
97
|
+
print "travis_fold:start:#{text}\r"
|
98
|
+
@open_fold = text
|
99
|
+
end
|
100
|
+
|
101
|
+
def close_fold(text)
|
102
|
+
print "travis_fold:end:#{text}\r"
|
103
|
+
@open_fold = nil
|
104
|
+
end
|
105
|
+
|
106
|
+
def format_build_target(target, project, configuration)
|
107
|
+
open_fold("Build")
|
108
|
+
super
|
109
|
+
end
|
110
|
+
|
111
|
+
def format_analyze_target(target, project, configuration)
|
112
|
+
open_fold("Analyze")
|
113
|
+
super
|
114
|
+
end
|
115
|
+
|
116
|
+
def format_clean_target(target, project, configuration)
|
117
|
+
open_fold("Clean")
|
118
|
+
super
|
119
|
+
end
|
120
|
+
|
121
|
+
def format_test_run_started(name)
|
122
|
+
open_fold("Tests-#{scrub(name)}")
|
123
|
+
super
|
124
|
+
end
|
125
|
+
|
126
|
+
def format_test_run_finished(name, time)
|
127
|
+
close_fold("Tests-#{scrub(name)}")
|
128
|
+
super
|
129
|
+
end
|
130
|
+
|
131
|
+
def scrub(text)
|
132
|
+
text.gsub(/\s/,"_").split(".").first
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
TravisProfilerFormatter
|
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: xcpretty-travis-profiler-formatter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Lars Lockefeer
|
8
|
+
- Delisa Mason
|
9
|
+
- Daniel Miedema
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2016-04-25 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: xcpretty
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - "~>"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0.2'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - "~>"
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '0.2'
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: bundler
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - "~>"
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '1.3'
|
36
|
+
type: :development
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - "~>"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '1.3'
|
43
|
+
description: "\n A combination of https://github.com/kattrali/xcpretty-travis-formatter\n
|
44
|
+
\ and https://github.com/larslockefeer/xcpretty-profiler-formatter\n so that compilation
|
45
|
+
times are shown and its formatted for Travis.\n "
|
46
|
+
email:
|
47
|
+
- lars.lockefeer@teampicnic.com
|
48
|
+
- iskanamagus@gmail.com
|
49
|
+
- daniel@dmiedema.com
|
50
|
+
executables:
|
51
|
+
- xcpretty-travis-profiler-formatter
|
52
|
+
extensions: []
|
53
|
+
extra_rdoc_files: []
|
54
|
+
files:
|
55
|
+
- LICENSE
|
56
|
+
- README.md
|
57
|
+
- bin/xcpretty-travis-profiler-formatter
|
58
|
+
- lib/travis_profiler_formatter.rb
|
59
|
+
homepage: https://github.com/dmiedema/xcpretty-travis-profiler-formatter
|
60
|
+
licenses:
|
61
|
+
- MIT
|
62
|
+
metadata: {}
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options: []
|
65
|
+
require_paths:
|
66
|
+
- lib
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - "~>"
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '2.0'
|
72
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
requirements: []
|
78
|
+
rubyforge_project:
|
79
|
+
rubygems_version: 2.5.1
|
80
|
+
signing_key:
|
81
|
+
specification_version: 4
|
82
|
+
summary: xcpretty formatter that profiles build times for Xcode projects with travis
|
83
|
+
supported output
|
84
|
+
test_files: []
|