mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
Performance tests (#1301)
* Add signposts to performance tests. - Update flow to include support for the migration screen. * If the welcome screen shows, click on the button. * Ensure a clean simulator each run. * Add accessibility identifier for migration screen if required. * Handle walking into the room and back out again. * use iphone 14 pro to match what's used in xcode. * Remove ApplicationTests as duplicated in LoginTests. We measure app startup time in LoginTests as part of the flow - we may as well avoid spending 60s doing only that measurement in ApplicationTests * Sleep 10s, the ui is otherwise showing up in random order. * Revert "Remove ApplicationTests as duplicated in LoginTests." This reverts commit 8670710315bcd0d6c3c3046f534b32b4c728b837. * Update script to parse out correct values from results file. * Allow cancellation of password prompt in any order. * Remove test timeout, performance tests will always take a while. * Adjust parsing further * Remove ApplicationTests. * Move to a more elegant way to wait for something to disappear. * Linting. * Fix unit tests. --------- Co-authored-by: Doug <douglase@element.io> Co-authored-by: Doug <6060466+pixlwave@users.noreply.github.com>
This commit is contained in:
@@ -35,6 +35,10 @@ class AnalyticsService {
|
||||
private let client: AnalyticsClientProtocol
|
||||
private let appSettings: AppSettings
|
||||
private let bugReportService: BugReportServiceProtocol
|
||||
|
||||
/// A signpost client for performance testing the app. This client doesn't respect the
|
||||
/// `isRunning` state or behave any differently when `start`/`reset` are called.
|
||||
let signpost = Signposter()
|
||||
|
||||
init(client: AnalyticsClientProtocol, appSettings: AppSettings, bugReportService: BugReportServiceProtocol) {
|
||||
self.client = client
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
//
|
||||
// Copyright 2023 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import OSLog
|
||||
|
||||
/// A simple wrapper around OSSignposter for easy performance testing.
|
||||
class Signposter {
|
||||
/// The underlying signposter.
|
||||
private let signposter = OSSignposter(subsystem: subsystem, category: category)
|
||||
/// A logger instance to capture any errors.
|
||||
private let logger = Logger(subsystem: subsystem, category: category)
|
||||
|
||||
/// Signpost name constants.
|
||||
enum Name {
|
||||
static let login: StaticString = "Login"
|
||||
static let sync: StaticString = "Sync"
|
||||
static let roomFlow: StaticString = "RoomFlow"
|
||||
}
|
||||
|
||||
static let subsystem = "ElementX"
|
||||
static let category = "PerformanceTests"
|
||||
|
||||
// MARK: - Login
|
||||
|
||||
private var loginState: OSSignpostIntervalState?
|
||||
|
||||
func beginLogin() {
|
||||
loginState = signposter.beginInterval(Name.login)
|
||||
}
|
||||
|
||||
func endLogin() {
|
||||
guard let loginState else {
|
||||
logger.error("Missing login state.")
|
||||
return
|
||||
}
|
||||
|
||||
signposter.endInterval(Name.login, loginState)
|
||||
self.loginState = nil
|
||||
}
|
||||
|
||||
// MARK: - Sync
|
||||
|
||||
private var syncState: OSSignpostIntervalState?
|
||||
|
||||
func beginSync() {
|
||||
syncState = signposter.beginInterval(Name.sync)
|
||||
}
|
||||
|
||||
func endSync() {
|
||||
guard let syncState else { return }
|
||||
|
||||
signposter.endInterval(Name.sync, syncState)
|
||||
self.syncState = nil
|
||||
}
|
||||
|
||||
// MARK: - Room Flow
|
||||
|
||||
private var roomFlowState: OSSignpostIntervalState?
|
||||
|
||||
func beginRoomFlow(_ name: String) {
|
||||
roomFlowState = signposter.beginInterval(Name.roomFlow)
|
||||
signposter.emitEvent("RoomName", "\(name, privacy: .auto(mask: .hash))")
|
||||
}
|
||||
|
||||
func endRoomFlow() {
|
||||
guard let roomFlowState else { return }
|
||||
|
||||
signposter.endInterval(Name.roomFlow, roomFlowState)
|
||||
self.roomFlowState = nil
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user