mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-19 23:33:33 +08:00
Opt: Recommend best method in benchmark
This commit is contained in:
@@ -81,7 +81,9 @@ class Benchmark(DaemonBase, UI):
|
|||||||
return 'Fast'
|
return 'Fast'
|
||||||
if cost < 0.2:
|
if cost < 0.2:
|
||||||
return 'Medium'
|
return 'Medium'
|
||||||
return 'Slow'
|
if cost < 0.4:
|
||||||
|
return 'Slow'
|
||||||
|
return 'Very Slow'
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def show(test, data, evaluate_func):
|
def show(test, data, evaluate_func):
|
||||||
@@ -104,6 +106,7 @@ class Benchmark(DaemonBase, UI):
|
|||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
logger.hr('Benchmark', level=1)
|
logger.hr('Benchmark', level=1)
|
||||||
|
self.device.remove_minicap()
|
||||||
self.ui_ensure(page_campaign)
|
self.ui_ensure(page_campaign)
|
||||||
|
|
||||||
data = []
|
data = []
|
||||||
@@ -122,13 +125,24 @@ class Benchmark(DaemonBase, UI):
|
|||||||
data.append(['uiautomator2', self.benchmark_test(self.device._click_uiautomator2, x, y)])
|
data.append(['uiautomator2', self.benchmark_test(self.device._click_uiautomator2, x, y)])
|
||||||
x, y = random_rectangle_point(area)
|
x, y = random_rectangle_point(area)
|
||||||
data.append(['minitouch', self.benchmark_test(self.device._click_minitouch, x, y)])
|
data.append(['minitouch', self.benchmark_test(self.device._click_minitouch, x, y)])
|
||||||
click = data
|
control = data
|
||||||
|
|
||||||
|
def compare(res):
|
||||||
|
res = res[1]
|
||||||
|
if not isinstance(res, (int, float)):
|
||||||
|
return 100
|
||||||
|
else:
|
||||||
|
return res
|
||||||
|
|
||||||
logger.hr('Benchmark Results', level=1)
|
logger.hr('Benchmark Results', level=1)
|
||||||
if screenshot:
|
if screenshot:
|
||||||
self.show(test='Screenshot', data=screenshot, evaluate_func=self.evaluate_screenshot)
|
self.show(test='Screenshot', data=screenshot, evaluate_func=self.evaluate_screenshot)
|
||||||
if click:
|
fastest = sorted(screenshot, key=lambda item: compare(item))[0]
|
||||||
self.show(test='Click', data=click, evaluate_func=self.evaluate_click)
|
logger.info(f'Recommend screenshot method: {fastest[0]} ({float2str(fastest[1])})')
|
||||||
|
if control:
|
||||||
|
self.show(test='Control', data=control, evaluate_func=self.evaluate_click)
|
||||||
|
fastest = sorted(control, key=lambda item: compare(item))[0]
|
||||||
|
logger.info(f'Recommend control method: {fastest[0]} ({float2str(fastest[1])})')
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
@@ -144,3 +144,14 @@ class Connection:
|
|||||||
except AssertionError:
|
except AssertionError:
|
||||||
logger.warning('AssertionError when connecting emulator with uiautomator2.')
|
logger.warning('AssertionError when connecting emulator with uiautomator2.')
|
||||||
logger.warning('If you are using BlueStacks, you need to enable ADB in the settings of your emulator.')
|
logger.warning('If you are using BlueStacks, you need to enable ADB in the settings of your emulator.')
|
||||||
|
|
||||||
|
def remove_minicap(self):
|
||||||
|
"""
|
||||||
|
Force to delete minicap.
|
||||||
|
|
||||||
|
`minicap` sends compressed images, which may cause detection errors.
|
||||||
|
In most situation, uiautomator won't install minicap on emulators, but sometimes will.
|
||||||
|
"""
|
||||||
|
logger.info('Removing minicap')
|
||||||
|
self.adb_shell(["rm", "/data/local/tmp/minicap"])
|
||||||
|
self.adb_shell(["rm", "/data/local/tmp/minicap.so"])
|
||||||
|
|||||||
Reference in New Issue
Block a user