1 /* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.launcher3.logging 18 19 import androidx.annotation.MainThread 20 21 /** Interface to log launcher startup latency metrics. */ 22 interface StartupLatencyLogger { 23 lognull24 @MainThread fun log(): StartupLatencyLogger = this 25 26 @MainThread fun logWorkspaceLoadStartTime(): StartupLatencyLogger = this 27 28 /** 29 * Log size of workspace. Larger number of workspace items (icons, folders, widgets) means 30 * longer latency to initialize workspace. 31 */ 32 @MainThread fun logCardinality(cardinality: Int): StartupLatencyLogger = this 33 34 @MainThread 35 fun logStart(event: StatsLogManager.LauncherLatencyEvent): StartupLatencyLogger = this 36 37 @MainThread 38 fun logStart( 39 event: StatsLogManager.LauncherLatencyEvent, 40 startTimeMs: Long 41 ): StartupLatencyLogger = this 42 43 @MainThread fun logEnd(event: StatsLogManager.LauncherLatencyEvent): StartupLatencyLogger = this 44 45 @MainThread 46 fun logEnd(event: StatsLogManager.LauncherLatencyEvent, endTimeMs: Long): StartupLatencyLogger = 47 this 48 49 @MainThread fun reset() 50 51 companion object { 52 val NO_OP: StartupLatencyLogger = 53 object : StartupLatencyLogger { 54 override fun reset() {} 55 } 56 } 57 } 58