Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mathieu/feature/Add PerformanceKit module and basic manager #1583

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Apps/LekaApp/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")),

Expand Down
1 change: 1 addition & 0 deletions Apps/LekaApp/Sources/MainApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import DesignKit
import FirebaseKit
import LocalizationKit
import LogKit
import PerformanceKit
import SwiftUI

let log = LogKit.createLoggerFor(app: "LekaApp")
Expand Down
1 change: 1 addition & 0 deletions Modules/FirebaseKit/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ let project = Project.module(
.external(name: "FirebaseAuthCombine-Community"),
.external(name: "FirebaseFirestore"),
.external(name: "FirebaseFirestoreCombine-Community"),
.external(name: "FirebasePerformance"),
]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -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
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -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()
}
}
}
Original file line number Diff line number Diff line change
@@ -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()
}
21 changes: 21 additions & 0 deletions Modules/PerformanceKit/Project.swift
Original file line number Diff line number Diff line change
@@ -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")),
]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
21 changes: 21 additions & 0 deletions Modules/PerformanceKit/Sources/Manager/PerformanceManager.swift
Original file line number Diff line number Diff line change
@@ -0,0 +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))
}
}
7 changes: 7 additions & 0 deletions Modules/PerformanceKit/Sources/PerformanceKit.swift
Original file line number Diff line number Diff line change
@@ -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")
12 changes: 12 additions & 0 deletions Modules/PerformanceKit/Tests/PerformanceKit_Tests.swift
Original file line number Diff line number Diff line change
@@ -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)
}
}
1 change: 1 addition & 0 deletions Workspace.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ var projects: [Path] {
"Modules/GameEngineKit",
"Modules/LocalizationKit",
"Modules/LogKit",
"Modules/PerformanceKit",
"Modules/RobotKit",
"Modules/UtilsKit",
]
Expand Down
Loading