-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
106 lines (82 loc) · 2.77 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import threading, os, time
from com.dtmilano.android.viewclient import ViewClient
from interactions import Click, VirtualScrolling, OpenCloseDrawer
from perfs import Vmstat, Gfxinfo
import helpers as h
device, serialno = ViewClient.connectToDeviceOrExit()
vc = ViewClient(device, serialno)
info = device.getDisplayInfo()
ocd = OpenCloseDrawer(device, serialno)
vs = VirtualScrolling(device, serialno)
clk1 = Click(device, serialno, int(info['width'] * 0.9), int(info['height'] * 0.1))
clk2 = Click(device, serialno, int(info['width'] * 0.1), int(info['height'] * 0.1))
apps = [
{
"type": "native",
"package": "at.stefanhuber.contactappnative",
"activity": "MainActivity"
},
{
"type": "reactnative",
"package": "com.contactappreact",
"activity": "MainActivity"
},
{
"type": "capacitor",
"package": "at.stefanhuber.contactappcapacitor",
"activity": "MainActivity"
}
]
def swipe():
vs()
def drawer():
ocd()
def transition():
clk1()
time.sleep(2)
clk2()
interactions = [
{
"name": "swipe",
"func": swipe
},
{
"name": "transition",
"func": transition
},
{
"name": "drawer",
"func": drawer
}
]
def runAll():
for j in range(1, 26):
for i in range(0, len(interactions)):
for a in range(0, len(apps)):
vmstat = Vmstat(30, "vmstat_{}_{}_{}_{}.txt".format(serialno, apps[a]["type"], interactions[i]['name'], j))
gfxinfo = Gfxinfo(apps[a]["package"], "gfxinfo_{}_{}_{}_{}.txt".format(serialno, apps[a]["type"], interactions[i]['name'], j))
# install and start app
h.install_apk("{}/./apks/contactapp-{}.apk".format(os.getcwd(), apps[a]["type"]))
h.start_app(apps[a]["package"], apps[a]["activity"])
# sleep until app is started
time.sleep(50)
# start performance metering
systrace_thread = threading.Thread(target=vmstat, name="perf-vmstat-thread")
systrace_thread.start()
# sleep until metering is started
time.sleep(3)
# run interaction
interactions[i]['func']()
# sleep and get gfxinfo
time.sleep(5)
systrace_thread = threading.Thread(target=gfxinfo, name="perf-gfxinfo-thread")
systrace_thread.start()
time.sleep(15)
# stop and uninstall app
h.stop_app(apps[a]["package"])
h.uninstall_apk(apps[a]["package"])
time.sleep(25)
# store perf stats
vmstat.pull_data()
gfxinfo.pull_data()
runAll()