-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add _BenchmarkHost and _PerformanceTest
- Loading branch information
Showing
11 changed files
with
117 additions
and
15 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#if os(iOS) | ||
import UIKit | ||
#elseif os(macOS) | ||
import AppKit | ||
#endif | ||
|
||
class TestingAppDelegate: DelegateBaseClass { | ||
static var performanceTests: [_PerformanceTest]? | ||
|
||
#if os(iOS) | ||
static var connectCallback: ((UIWindow) -> Void)? | ||
#endif | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
public protocol _Benchmark: _Test { | ||
func measure(host: _BenchmarkHost) -> [Double] | ||
} | ||
|
||
extension _TestApp { | ||
public func runBenchmarks(_ benchmarks: [_Benchmark]) -> Never { | ||
let _ = RootView() | ||
fatalError("TODO") | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// | ||
// _PerformanceTest.swift | ||
// OpenSwiftUI | ||
// | ||
// Created by Kyle on 2023/1/9. | ||
// Lastest Version: iOS 15.5 | ||
// Status: WIP | ||
|
||
#if os(iOS) | ||
import UIKit | ||
#elseif os(macOS) | ||
import AppKit | ||
#endif | ||
|
||
internal import OpenSwiftUIShims | ||
|
||
public protocol _PerformanceTest: _Test { | ||
var name: String { get } | ||
func runTest(host: _BenchmarkHost, options: [AnyHashable: Any]) | ||
} | ||
|
||
extension __App { | ||
public static func _registerPerformanceTests(_ tests: [_PerformanceTest]) { | ||
TestingAppDelegate.performanceTests = tests | ||
} | ||
} | ||
|
||
extension _TestApp { | ||
public func runPerformanceTests(_ tests: [_PerformanceTest]) -> Never { | ||
fatalError("TODO") | ||
} | ||
} | ||
|
||
extension _BenchmarkHost { | ||
public func _started(test: _PerformanceTest) { | ||
#if os(iOS) | ||
UIApplication.shared.startedTest(test.name) | ||
#else | ||
fatalError("TODO") | ||
#endif | ||
} | ||
|
||
public func _finished(test: _PerformanceTest) { | ||
#if os(iOS) | ||
UIApplication.shared.finishedTest(test.name) | ||
#else | ||
fatalError("TODO") | ||
#endif | ||
} | ||
|
||
public func _failed(test: _PerformanceTest) { | ||
#if os(iOS) | ||
UIApplication.shared.failedTest(test.name, withFailure: nil) | ||
#else | ||
fatalError("TODO") | ||
#endif | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// | ||
// OpenSwiftUI_SPI.h | ||
// | ||
// | ||
// Created by Kyle on 2024/1/9. | ||
// | ||
|
||
#ifndef OpenSwiftUI_SPI_h | ||
#define OpenSwiftUI_SPI_h | ||
|
||
#if __has_include(<UIKit/UIKit.h>) | ||
#import <UIKit/UIKit.h> | ||
@interface UIApplication (OpenSwiftUI_SPI) | ||
- (void)startedTest:(nullable NSString *)name; | ||
- (void)finishedTest:(nullable NSString *)name; | ||
- (void)failedTest:(nullable NSString *)name withFailure:(nullable NSError*)failure; | ||
@end | ||
#else | ||
|
||
#endif | ||
|
||
#endif /* OpenSwiftUI_SPI_h */ |