Skip to content
Merged
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
6 changes: 3 additions & 3 deletions eng/performance/build_machine_matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ jobs:
parameters:
osName: osx
architecture: x64
osVersion: 12
osVersion: 13
pool:
vmImage: 'macos-12'
queue: OSX.1015.Amd64.Iphone.Perf
vmImage: 'macos-13'
queue: OSX.13.Amd64.Iphone.Perf
machinePool: iPhoneMini12
${{ insert }}: ${{ parameters.jobParameters }}
1 change: 1 addition & 0 deletions eng/performance/maui_scenarios_ios.proj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

<PropertyGroup>
<IncludeXHarnessCli>true</IncludeXHarnessCli>
<MicrosoftDotNetXHarnessCLIVersion>9.0.0-prerelease.23606.1</MicrosoftDotNetXHarnessCLIVersion>
</PropertyGroup>

<PropertyGroup>
Expand Down
47 changes: 34 additions & 13 deletions src/scenarios/shared/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
Module for running scenario tasks
'''

from genericpath import exists
import sys
import os
import glob
import re
import time
from datetime import datetime
import json

from genericpath import exists
from datetime import datetime, timedelta
from logging import exception, getLogger
from collections import namedtuple
from argparse import ArgumentParser
Expand Down Expand Up @@ -666,9 +666,22 @@ def run(self):

getLogger().info("Checking device state.")
cmdline = xharnesscommand() + ['apple', 'state']
adb = RunCommand(cmdline, verbose=True)
adb.run()

apple_state = RunCommand(cmdline, verbose=True)
apple_state.run()

# Get the name and version of the device from the output of apple_state above
# Example output expected (PERFIOS-01 is the device name, and 17.0.2 is the version):
# Connected Devices:
# PERFIOS-01 00008101-001A09223E08001E 17.0.2 iPhone iOS
deviceInfoMatch = re.search(r'Connected Devices:\s+(?P<deviceName>\S+)\s+\S+\s+(?P<deviceVersion>\S+)', apple_state.stdout)
if deviceInfoMatch:
deviceName = deviceInfoMatch.group('deviceName')
deviceVersion = deviceInfoMatch.group('deviceVersion')
getLogger().info(f"Device Name: {deviceName}")
getLogger().info(f"Device Version: {deviceVersion}")
else:
raise Exception("Device name or version not found in the output of apple_state command.")

getLogger().info("Installing app on device.")
installCmd = xharnesscommand() + [
'apple',
Expand All @@ -683,17 +696,19 @@ def run(self):
getLogger().info("Completed install.")

allResults = []
timeToFirstDrawEventEndDateTime = datetime.now() # This is used to keep track of the latest time to draw end event, we use this to calculate time to draw and also as a reference point for the next iteration log time.
for i in range(self.startupiterations + 1): # adding one iteration to account for the warmup iteration
getLogger().info("Waiting 10 secs to ensure we're not getting confused with previous app run.")
time.sleep(10)

getLogger().info(f"Collect startup data for iteration {i}.")
runCmdTimestamp = datetime.now()
runCmdTimestamp = timeToFirstDrawEventEndDateTime + timedelta(seconds=1)
runCmd = xharnesscommand() + [
'apple',
'mlaunch',
'--',
f'--launchdevbundleid={self.packagename}',
'--launchdev', self.packagepath,
'--devname', deviceName
]
runCmdCommand = RunCommand(runCmd, verbose=True)

Expand Down Expand Up @@ -726,7 +741,12 @@ def run(self):
getLogger().error("App launch failed, please rerun the script to start a new measurement.")
raise

app_pid_search = re.search("Launched application.*with pid (?P<app_pid>\d+)", runCmdCommand.stdout)
# If the device version is less than 17 we need to use the old pid search
# otherwise we use the new pid search
if deviceVersion < '17':
app_pid_search = re.search(r"Launched application.*with pid (?P<app_pid>\d+)", runCmdCommand.stdout)
else:
app_pid_search = re.search(r"The app.*launched with pid (?P<app_pid>\d+)", runCmdCommand.stdout)
app_pid = int(app_pid_search.group('app_pid'))

logarchive_filename = os.path.join(const.TMPDIR, f'iteration{i}.logarchive')
Expand All @@ -748,6 +768,7 @@ def run(self):
'mlaunch',
'--',
f'--killdev={app_pid}',
'--devname', deviceName
]
killCmdCommand = RunCommand(killCmd, verbose=True)
killCmdCommand.run()
Expand Down Expand Up @@ -783,7 +804,7 @@ def run(self):
try:
lineData = json.loads(line)
if 'Now monitoring resource allowance' in lineData['eventMessage'] or 'Stopped monitoring' in lineData['eventMessage']:
events.append (lineData)
events.append(lineData)
except:
break

Expand All @@ -799,16 +820,16 @@ def run(self):
timeToFirstDrawEventStop = events[3]

# validate log messages
if f'application<{self.packagename}>:{app_pid}' not in timeToMainEventStart['eventMessage'] or 'Now monitoring resource allowance of 20.00s' not in timeToMainEventStart['eventMessage']:
if f'{self.packagename}' not in timeToMainEventStart['eventMessage'] or 'Now monitoring resource allowance of 20.00s' not in timeToMainEventStart['eventMessage']:
raise Exception(f"Invalid timeToMainEventStart: {timeToMainEventStart['eventMessage']}")

if f'application<{self.packagename}>:{app_pid}' not in timeToMainEventStop['eventMessage'] or 'Stopped monitoring' not in timeToMainEventStop['eventMessage']:
if f'{self.packagename}' not in timeToMainEventStop['eventMessage'] or 'Stopped monitoring' not in timeToMainEventStop['eventMessage']:
raise Exception(f"Invalid timeToMainEventStop: {timeToMainEventStop['eventMessage']}")

if f'application<{self.packagename}>:{app_pid}' not in timeToFirstDrawEventStart['eventMessage'] or 'Now monitoring resource allowance of' not in timeToFirstDrawEventStart['eventMessage']:
if f'{self.packagename}' not in timeToFirstDrawEventStart['eventMessage'] or 'Now monitoring resource allowance of' not in timeToFirstDrawEventStart['eventMessage']:
raise Exception(f"Invalid timeToFirstDrawEventStart: {timeToFirstDrawEventStart['eventMessage']}")

if f'application<{self.packagename}>:{app_pid}' not in timeToFirstDrawEventStop['eventMessage'] or 'Stopped monitoring' not in timeToFirstDrawEventStop['eventMessage']:
if f'{self.packagename}' not in timeToFirstDrawEventStop['eventMessage'] or 'Stopped monitoring' not in timeToFirstDrawEventStop['eventMessage']:
raise Exception(f"Invalid timeToFirstDrawEventStop: {timeToFirstDrawEventStop['eventMessage']}")

timeToMainEventStartDateTime = datetime.strptime(timeToMainEventStart['timestamp'], '%Y-%m-%d %H:%M:%S.%f%z')
Expand Down