giginet / xcprofiler

:chart_with_upwards_trend: CLI to profile compilation time of Swift project
MIT License
332 stars 13 forks source link

Add --per-file option #30

Open r-plus opened 6 years ago

r-plus commented 6 years ago

hi @giginet

I want to add --per-file option to sum time per file. It is useful to know total compile time for file is reduced when if we refactoring single function to split some small functions.

example

off(default)

$ ./bin/xcprofiler spec/fixtures/MyApp-xxxxxxxxxxx/Logs/Build/valid.xcactivitylog -l 5 -t 20
+--------------------------+------+----------------------+----------+
| File                     | Line | Method name          | Time(ms) |
+--------------------------+------+----------------------+----------+
| Interaction.swift        | 17   | get {}               | 69.9     |
| Matcher.swift            | 7    | get {}               | 68.9     |
| InteractionBuilder.swift | 87   | func clean()         | 49.8     |
| Session.swift            | 74   | public func run(c... | 49.6     |
| Session.swift            | 65   | @discardableResul... | 28.3     |
+--------------------------+------+----------------------+----------+

on

$ ./bin/xcprofiler spec/fixtures/MyApp-xxxxxxxxxxx/Logs/Build/valid.xcactivitylog -l 5 -t 20 --per-file
+--------------------------+------+-------------+----------+
| File                     | Line | Method name | Time(ms) |
+--------------------------+------+-------------+----------+
| Session.swift            | 0    |             | 83.4     |
| InteractionBuilder.swift | 0    |             | 81.5     |
| Interaction.swift        | 0    |             | 73.5     |
| Matcher.swift            | 0    |             | 70.9     |
| ServiceClient.swift      | 0    |             | 66.8     |
+--------------------------+------+-------------+----------+

thanks.

r-plus commented 6 years ago

oops, should I support Ruby 2.3 to pass CI? (Enumerable#sum method is added since 2.4.)

or drop support 2.3 and add 2.5 to CI matrix to support latest 2 minor versions of Ruby.

giginet commented 6 years ago

oops, should I support Ruby 2.3 to pass CI?

Yes. Because default Ruby on macOS is still Ruby 2.3...

I recommend you to use just call reduce instead of sum.

executions.map(:time).reduce(:+)
r-plus commented 6 years ago

okey, I understand support policy for this project. and thanks for your suggestion to do it, I'll fix it.

r-plus commented 6 years ago

Fixed to support Ruby 2.3. @giginet Could you review it?