From 081f41a17a217a3745d52a124fd284dcdefed435 Mon Sep 17 00:00:00 2001 From: "mathieu J." Date: Thu, 21 Nov 2024 11:21:16 +0200 Subject: [PATCH 1/3] =?UTF-8?q?=E2=9E=95=20(PerformanceKit):=20Add=20modul?= =?UTF-8?q?e=20PerformanceKit=20files?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AccentColor.colorset/Contents.json | 11 +++ .../AppIcon.appiconset/Contents.json | 98 +++++++++++++++++++ .../Resources/Assets.xcassets/Contents.json | 6 ++ .../Preview Assets.xcassets/Contents.json | 6 ++ .../Sources/MainApp.swift | 17 ++++ .../Sources/MainView.swift | 18 ++++ Modules/PerformanceKit/Project.swift | 21 ++++ .../Resources/Assets.xcassets/Contents.json | 6 ++ .../Sources/Manager/PerformanceManager.swift | 3 + .../Sources/PerformanceKit.swift | 7 ++ .../Tests/PerformanceKit_Tests.swift | 12 +++ 11 files changed, 205 insertions(+) create mode 100644 Modules/PerformanceKit/Examples/PerformanceKitExample/Resources/Assets.xcassets/AccentColor.colorset/Contents.json create mode 100644 Modules/PerformanceKit/Examples/PerformanceKitExample/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 Modules/PerformanceKit/Examples/PerformanceKitExample/Resources/Assets.xcassets/Contents.json create mode 100644 Modules/PerformanceKit/Examples/PerformanceKitExample/Resources/Preview Content/Preview Assets.xcassets/Contents.json create mode 100644 Modules/PerformanceKit/Examples/PerformanceKitExample/Sources/MainApp.swift create mode 100644 Modules/PerformanceKit/Examples/PerformanceKitExample/Sources/MainView.swift create mode 100644 Modules/PerformanceKit/Project.swift create mode 100644 Modules/PerformanceKit/Resources/Assets.xcassets/Contents.json create mode 100644 Modules/PerformanceKit/Sources/Manager/PerformanceManager.swift create mode 100644 Modules/PerformanceKit/Sources/PerformanceKit.swift create mode 100644 Modules/PerformanceKit/Tests/PerformanceKit_Tests.swift diff --git a/Modules/PerformanceKit/Examples/PerformanceKitExample/Resources/Assets.xcassets/AccentColor.colorset/Contents.json b/Modules/PerformanceKit/Examples/PerformanceKitExample/Resources/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 0000000000..eb87897008 --- /dev/null +++ b/Modules/PerformanceKit/Examples/PerformanceKitExample/Resources/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Modules/PerformanceKit/Examples/PerformanceKitExample/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json b/Modules/PerformanceKit/Examples/PerformanceKitExample/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000000..9221b9bb1a --- /dev/null +++ b/Modules/PerformanceKit/Examples/PerformanceKitExample/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,98 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "20x20" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "20x20" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "29x29" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "29x29" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "40x40" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "40x40" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "60x60" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "60x60" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "20x20" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "20x20" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "29x29" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "29x29" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "40x40" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "40x40" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "76x76" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "76x76" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "83.5x83.5" + }, + { + "idiom" : "ios-marketing", + "scale" : "1x", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Modules/PerformanceKit/Examples/PerformanceKitExample/Resources/Assets.xcassets/Contents.json b/Modules/PerformanceKit/Examples/PerformanceKitExample/Resources/Assets.xcassets/Contents.json new file mode 100644 index 0000000000..73c00596a7 --- /dev/null +++ b/Modules/PerformanceKit/Examples/PerformanceKitExample/Resources/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Modules/PerformanceKit/Examples/PerformanceKitExample/Resources/Preview Content/Preview Assets.xcassets/Contents.json b/Modules/PerformanceKit/Examples/PerformanceKitExample/Resources/Preview Content/Preview Assets.xcassets/Contents.json new file mode 100644 index 0000000000..73c00596a7 --- /dev/null +++ b/Modules/PerformanceKit/Examples/PerformanceKitExample/Resources/Preview Content/Preview Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Modules/PerformanceKit/Examples/PerformanceKitExample/Sources/MainApp.swift b/Modules/PerformanceKit/Examples/PerformanceKitExample/Sources/MainApp.swift new file mode 100644 index 0000000000..412a821473 --- /dev/null +++ b/Modules/PerformanceKit/Examples/PerformanceKitExample/Sources/MainApp.swift @@ -0,0 +1,17 @@ +// Leka - iOS Monorepo +// Copyright APF France handicap +// SPDX-License-Identifier: Apache-2.0 + +import PerformanceKit +import SwiftUI + +// MARK: - PerformanceKitExample + +@main +struct PerformanceKitExample: App { + var body: some Scene { + WindowGroup { + MainView() + } + } +} diff --git a/Modules/PerformanceKit/Examples/PerformanceKitExample/Sources/MainView.swift b/Modules/PerformanceKit/Examples/PerformanceKitExample/Sources/MainView.swift new file mode 100644 index 0000000000..531eccd8c1 --- /dev/null +++ b/Modules/PerformanceKit/Examples/PerformanceKitExample/Sources/MainView.swift @@ -0,0 +1,18 @@ +// Leka - iOS Monorepo +// Copyright APF France handicap +// SPDX-License-Identifier: Apache-2.0 + +import SwiftUI + +struct MainView: View { + @State var count = 1 + + var body: some View { + Text("Hello, PerformanceKit!") + .font(.largeTitle) + } +} + +#Preview { + MainView() +} diff --git a/Modules/PerformanceKit/Project.swift b/Modules/PerformanceKit/Project.swift new file mode 100644 index 0000000000..bfa4ab5809 --- /dev/null +++ b/Modules/PerformanceKit/Project.swift @@ -0,0 +1,21 @@ +// Leka - iOS Monorepo +// Copyright APF France handicap +// SPDX-License-Identifier: Apache-2.0 + +// swiftformat:disable acronyms + +import ProjectDescription +import ProjectDescriptionHelpers + +let project = Project.module( + name: "PerformanceKit", + examples: [ + ModuleExample( + name: "PerformanceKitExample" + ), + ], + dependencies: [ + .project(target: "FirebaseKit", path: Path("../../Modules/FirebaseKit")), + .project(target: "LogKit", path: Path("../../Modules/LogKit")), + ] +) diff --git a/Modules/PerformanceKit/Resources/Assets.xcassets/Contents.json b/Modules/PerformanceKit/Resources/Assets.xcassets/Contents.json new file mode 100644 index 0000000000..73c00596a7 --- /dev/null +++ b/Modules/PerformanceKit/Resources/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Modules/PerformanceKit/Sources/Manager/PerformanceManager.swift b/Modules/PerformanceKit/Sources/Manager/PerformanceManager.swift new file mode 100644 index 0000000000..36224913a5 --- /dev/null +++ b/Modules/PerformanceKit/Sources/Manager/PerformanceManager.swift @@ -0,0 +1,3 @@ +// Leka - iOS Monorepo +// Copyright APF France handicap +// SPDX-License-Identifier: Apache-2.0 diff --git a/Modules/PerformanceKit/Sources/PerformanceKit.swift b/Modules/PerformanceKit/Sources/PerformanceKit.swift new file mode 100644 index 0000000000..d3daf10172 --- /dev/null +++ b/Modules/PerformanceKit/Sources/PerformanceKit.swift @@ -0,0 +1,7 @@ +// Leka - iOS Monorepo +// Copyright APF France handicap +// SPDX-License-Identifier: Apache-2.0 + +import LogKit + +let log = LogKit.createLoggerFor(module: "PerformanceKit") diff --git a/Modules/PerformanceKit/Tests/PerformanceKit_Tests.swift b/Modules/PerformanceKit/Tests/PerformanceKit_Tests.swift new file mode 100644 index 0000000000..84ccb303d0 --- /dev/null +++ b/Modules/PerformanceKit/Tests/PerformanceKit_Tests.swift @@ -0,0 +1,12 @@ +// Leka - iOS Monorepo +// Copyright APF France handicap +// SPDX-License-Identifier: Apache-2.0 + +import Foundation +import XCTest + +final class PerformanceKit_Tests: XCTestCase { + func test_twoPlusTwo_isFour() { + XCTAssertEqual(2 + 2, 4) + } +} From 38937227d1e438ea070a4ee6a262b18744c41cbc Mon Sep 17 00:00:00 2001 From: "mathieu J." Date: Thu, 21 Nov 2024 11:31:38 +0200 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=94=A7=20(PerformanceKit):=20Finish?= =?UTF-8?q?=20PerformanceKit=20setup=20in=20project.swift?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Apps/LekaApp/Project.swift | 1 + Modules/FirebaseKit/Project.swift | 1 + Workspace.swift | 1 + 3 files changed, 3 insertions(+) diff --git a/Apps/LekaApp/Project.swift b/Apps/LekaApp/Project.swift index 24c6060524..ae07573a17 100644 --- a/Apps/LekaApp/Project.swift +++ b/Apps/LekaApp/Project.swift @@ -73,6 +73,7 @@ let project = Project.app( .project(target: "GameEngineKit", path: Path("../../Modules/GameEngineKit")), .project(target: "LocalizationKit", path: Path("../../Modules/LocalizationKit")), .project(target: "LogKit", path: Path("../../Modules/LogKit")), + .project(target: "PerformanceKit", path: Path("../../Modules/PerformanceKit")), .project(target: "RobotKit", path: Path("../../Modules/RobotKit")), .project(target: "UtilsKit", path: Path("../../Modules/UtilsKit")), diff --git a/Modules/FirebaseKit/Project.swift b/Modules/FirebaseKit/Project.swift index 1e4bd21e1a..4562c3bcc0 100644 --- a/Modules/FirebaseKit/Project.swift +++ b/Modules/FirebaseKit/Project.swift @@ -22,5 +22,6 @@ let project = Project.module( .external(name: "FirebaseAuthCombine-Community"), .external(name: "FirebaseFirestore"), .external(name: "FirebaseFirestoreCombine-Community"), + .external(name: "FirebasePerformance"), ] ) diff --git a/Workspace.swift b/Workspace.swift index f429703d43..6c21f282e8 100644 --- a/Workspace.swift +++ b/Workspace.swift @@ -32,6 +32,7 @@ var projects: [Path] { "Modules/GameEngineKit", "Modules/LocalizationKit", "Modules/LogKit", + "Modules/PerformanceKit", "Modules/RobotKit", "Modules/UtilsKit", ] From d36991c459a56edf6b08c04ee83f3e080d5ff1e1 Mon Sep 17 00:00:00 2001 From: "mathieu J." Date: Thu, 21 Nov 2024 12:04:00 +0200 Subject: [PATCH 3/3] =?UTF-8?q?=E2=9C=A8=20(PerformanceKit):=20Add=20basic?= =?UTF-8?q?=20PerformanceManager?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Apps/LekaApp/Sources/MainApp.swift | 1 + .../Sources/Manager/PerformanceManager.swift | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/Apps/LekaApp/Sources/MainApp.swift b/Apps/LekaApp/Sources/MainApp.swift index fc0da44b2d..8a87ffee02 100644 --- a/Apps/LekaApp/Sources/MainApp.swift +++ b/Apps/LekaApp/Sources/MainApp.swift @@ -11,6 +11,7 @@ import DesignKit import FirebaseKit import LocalizationKit import LogKit +import PerformanceKit import SwiftUI let log = LogKit.createLoggerFor(app: "LekaApp") diff --git a/Modules/PerformanceKit/Sources/Manager/PerformanceManager.swift b/Modules/PerformanceKit/Sources/Manager/PerformanceManager.swift index 36224913a5..7803f3d454 100644 --- a/Modules/PerformanceKit/Sources/Manager/PerformanceManager.swift +++ b/Modules/PerformanceKit/Sources/Manager/PerformanceManager.swift @@ -1,3 +1,21 @@ // Leka - iOS Monorepo // Copyright APF France handicap // SPDX-License-Identifier: Apache-2.0 + +import FirebasePerformance + +public class PerformanceManager { + public static func startTrace(name: String) -> Trace? { + let trace = Performance.startTrace(name: name) + trace?.start() + return trace + } + + public static func stopTrace(_ trace: Trace?) { + trace?.stop() + } + + public static func setMetric(_ trace: Trace?, name: String, value: Int) { + trace?.incrementMetric(name, by: Int64(value)) + } +}