Generate automated reports for slow Swift compilation paths in specific targets

Overview

SwiftCompilationPerformanceReporter

Inspired by Brian and Bryan's prior work, we've decided to develop a Swift Package and script to generate automated reports for slow Swift compilation paths in specific targets!

SwiftCompilationPerformanceReporter (nicknamed SwiftCPR) can be configured to build a specific target, output raw debug times to a specific location, and clean those logs to rank the slowest parts to compile.

Requirements

Configuration

SwiftCompilationPerformanceReporter can be configured via the config.json file. Below is a description of the options available and a sample configuration:

{
    // Note: either a project or workspace file can be specified, _but not both_
    "workspacePath": "/Users/jasdev/orangina/Orangina.xcworkspace",
    "projectPath": "/Users/jasdev/orangina/Orangina.xcodeproj",

    "scheme": "Orangina",
    "buildOutputDirectory": "/Users/jasdev/Desktop/CompilationLogs/",
    "reportOutputDirectory": "/Users/jasdev/Desktop/ProcessedLogs/",
    "limit": 10
}

workspacePath: The absolute path to the workspace file to use.

projectPath: The absolute path to the project file to use.

scheme: The scheme to use

buildOutputDirectory: The directory to store the raw build output files with Swift compilation times.

reportOutputDirectory: The directory to store the processed logs derived from the raw log output.

limit: The number of compilation paths to include in the final results (i.e. the slowest limit paths that compiler handled).

Installation

  • Simply clone this repository on the machine that will be generating these reports.
  • Run swift build in the root directory
  • Make sure all directories used in config.json are set properly and exist.
  • If your desired scheme is built with a pre-3.x version of Swift, you'll want to xcode-select back to a stable version (i.e. sudo xcode-select -s /Applications/Xcode.app)
  • To kick off the script, run .build/debug/SwiftCompilationPerformanceReporter in the root directory!
  • If there are any errors, the script will output them.
  • The processed logs will be outputted as timestamped files in reportOutputDirectory.

Output

The processed logs will be outputted as a tab separated file with 3 columns after the first line (which holds the total build time). All time units are in seconds.

[Build Time]\t[Path and Line]\t[Detailed Description]

Sample output file:

Total build time: 1214.91016298532
17.0409	/Users/jasdev/orangina/Classes/PerformanceLoggingEvent.swift:278:37	final get {}
7.9331	/Users/jasdev/orangina/Components/ComposeUI/Classes/Election/LeaderboardTableView.swift:71:17	@objc final class func totalHeight(candidates: UInt, allowsLeaderboard: Bool) -> CGFloat
6.2961	/Users/jasdev/orangina/Classes/UniversalLink.swift:127:25	private final class func dictionaryOfAppArgumentsFromQueryString(string: String) -> [NSObject : AnyObject]?
4.2116	/Users/jasdev/orangina/Classes/ActivityViewController.swift:56:22	final get {}
You might also like...
Telegram iOS Source Code Compilation Guide

Telegram iOS Source Code Compilation Guide We welcome all developers to use our API and source code to create applications on our platform. There are

Telegram iOS Source Code Compilation Guide

Telegram iOS Source Code Compilation Guide We welcome all developers to use our API and source code to create applications on our platform. There are

πŸ“Έ iOS Media Capture – features touch-to-record video, slow motion, and photography
πŸ“Έ iOS Media Capture – features touch-to-record video, slow motion, and photography

PBJVision PBJVision is a camera library for iOS that enables easy integration of special capture features and camera interface customizations in your

iOS camera engine with Vine-like tap to record, animatable filters, slow motion, segments editing
iOS camera engine with Vine-like tap to record, animatable filters, slow motion, segments editing

SCRecorder A Vine/Instagram like audio/video recorder and filter framework in Objective-C. In short, here is a short list of the cool things you can d

Measure Swift code metrics and get reports in Xcode, Jenkins and other CI platforms.
Measure Swift code metrics and get reports in Xcode, Jenkins and other CI platforms.

Taylor ⚠️ Taylor is DEPRECATED. Use SwiftLint instead. A tool aimed to increase Swift code quality, by checking for conformance to code metrics. Taylo

A Mac command-line tool that generates kick-ass Jamf Pro reports.
A Mac command-line tool that generates kick-ass Jamf Pro reports.

KMART - Kick-Ass Mac Admin Reporting Tool A command-line utility generating kick-ass Jamf Pro reports: Features Reporting on the following Jamf Pro ob

Aardvark is a library that makes it dead simple to create actionable bug reports.
Aardvark is a library that makes it dead simple to create actionable bug reports.

Aardvark Aardvark makes it dead simple to create actionable bug reports. Aardvark is made up of a collection of frameworks that provide different bug

Convert xcodebuild plist and xcresult files to JUnit reports
Convert xcodebuild plist and xcresult files to JUnit reports

trainer This is an alternative approach to generate JUnit files for your CI (e.g. Jenkins) without parsing the xcodebuild output, but using the Xcode

🎯 PredicateKit allows Swift developers to write expressive and type-safe predicates for CoreData using key-paths, comparisons and logical operators, literal values, and functions.
🎯 PredicateKit allows Swift developers to write expressive and type-safe predicates for CoreData using key-paths, comparisons and logical operators, literal values, and functions.

🎯 PredicateKit PredicateKit is an alternative to NSPredicate allowing you to write expressive and type-safe predicates for CoreData using key-paths,

 πŸ”Œ Enum key paths
πŸ”Œ Enum key paths

πŸ”Œ Enum key paths With the package you can use key paths with enums import EnumKeyPaths

An iOS library to route API paths to objects on client side with request, mapping, routing and auth layers

WANetworkRouting Developed and Maintained by ipodishima Founder & CTO at Wasappli Inc. Sponsored by Wisembly A routing library to fetch objects from a

COVID Safe Paths (based on Private Kit) is an open and privacy preserving system to use personal information to battle COVID
COVID Safe Paths (based on Private Kit) is an open and privacy preserving system to use personal information to battle COVID

COVID Safe Paths is a mobile app for digital contract tracing (DCT) sponsored by Path Check a nonprofit and developed by a growing global community of engineers, designers, and contributors. Safe Paths is based on research originally conducted at the MIT Media Lab.

Mac App Store: Embedding a Command Line tool using paths as arguments

Mac App Store: Embedding a Command Line tool using paths as arguments Code snippets to embed a Command Line tool using paths as arguments on the Mac A

An xcconfig (Xcode configuration) file for easily turning on a boatload of warnings in your project or its targets.

Warnings This is an xcconfig file to make it easy for you to turn on a large suite of useful warnings in your Xcode project. These warnings catch bugs

Enables developers to write code that interacts with CloudKit in targets that don't support the CloudKit Framework directly

CloudKit Web Services This package enables developers to write code that interac

Enables developers to write code that interacts with CloudKit in targets that don't support the CloudKit Framework directly

CloudKit Web Services This package enables developers to write code that interac

Demonstration of Cocoapod test targets failing to build when integrated with TestingExtensions 0.2.11.

TestingExtensions0_2_11-Bug Symptoms Open project, hit test (Command+U), TestingExtensions fails to compile with a list of errors appearing to be rela

🐝 Draw Xcode targets and dependencies tree
🐝 Draw Xcode targets and dependencies tree

🐝 Bee Draw Xcode targets and dependencies tree.

UIPredicateEditor aims to be come a drop-in replacement of NSPredicateEditor for iOS, iPadOS and Mac Catalyst targets.

UIPredicateEditor UIPredicateEditor aims to be come a drop-in replacement of NSPredicateEditor for iOS, iPadOS and Mac Catalyst targets. The plan is t

Owner
TumblrArchive
TumblrArchive
This repository contains rules for Bazel that can be used to generate Xcode projects

rules_xcodeproj This repository contains rules for Bazel that can be used to generate Xcode projects. If you run into any problems with these rules, p

BuildBuddy 233 Dec 28, 2022
Swift CLI for strong-typing images, colors, storyboards, fonts and localizations

Shark Shark is a Swift command line tool that generates type safe enums for your images, colors, storyboards, fonts and localizations. Because Shark r

Kaan Dedeoglu 377 Dec 1, 2022
Strong typed, autocompleted resources like images, fonts and segues in Swift projects

R.swift Get strong typed, autocompleted resources like images, fonts and segues in Swift projects Why use this? It makes your code that uses resources

Mathijs Kadijk 8.9k Jan 6, 2023
Soulful docs for Swift & Objective-C

jazzy is a command-line utility that generates documentation for Swift or Objective-C About Both Swift and Objective-C projects are supported. Instead

Realm 7.2k Jan 3, 2023
Laurine - Localization code generator written in Swift. Sweet!

Author's note: Thanks everyone for making Laurine the TOP trending Swift repository in the world - this is amazing and very heart-warming! But this is

Jiri Trecak 1.3k Dec 28, 2022
swiftenv allows you to easily install, and switch between multiple versions of Swift.

Swift Version Manager swiftenv allows you to easily install, and switch between multiple versions of Swift. This project was heavily inspired by pyenv

Kyle Fuller 1.9k Dec 27, 2022
Script to support easily using Xcode Asset Catalog in Swift.

Misen Misen is a script to support using Xcode Asset Catalog in Swift. Features Misen scans sub-directories in the specified Asset Catalog and creates

Kazunobu Tasaka 123 Jun 29, 2022
An Xcode Plugin to convert Objective-C to Swift

XCSwiftr Convert Objective-C code into Swift from within Xcode. This plugin uses the Java applet of objc2swift to do the conversion. Noticed that the

Ignacio Romero Zurbuchen 338 Nov 29, 2022
Swift autocompleter for Sublime Text, via the adorable SourceKitten framework

SwiftKitten SwiftKitten is a Swift autocompleter for Sublime Text, via the adorable SourceKitten framework. Faster than XCode ! This package is new an

John Snyder 142 Sep 9, 2022
Command line utility to profile compilation time of Swift project.

xcprofiler Command line utility to profile compilation time of Swift project. This tool is developed in working time for Cookpad. Installation gem ins

Kohki Miki 334 Jan 3, 2023