giginet / xcprofiler

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

Report file compilation time #19

Closed delannoyk closed 7 years ago

delannoyk commented 7 years ago

Hi @giginet

Thanks for this! I've been trying to set it up with your danger plugin and it looks promising!

I was wondering if there was a way to add a threshold for files instead of function bodies and maybe to report the compilation time on the whole file?

giginet commented 7 years ago

Hi @delannoyk thanks for using xcprofiler 😄

In default, you can't profile build times per files. However, you can implement custom reporter to gather and group logs.

require 'xcprofiler'

profiler = Xcprofiler::Profiler.by_product_name("MyApp")
profiler.reporters = [
    Xcprofiler::BlockReporter.new do |executions|
        puts executions.group_by { |execution| execution.filename }.map { |file, executions| [file, executions.sum { |e| e.time }] }.to_h
    end
]
profiler.report!

How about this solution?

delannoyk commented 7 years ago

Perfect, thanks!