forked from androidx/androidx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ksp-kapt-comparison.sh
executable file
·80 lines (73 loc) · 2.24 KB
/
ksp-kapt-comparison.sh
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
#!/bin/bash
# This script runs kotlin test app compilation with ksp and kapt repeatedly to measure time spent for each of them.
# Each build is a clean build for the test project
declare -A totals
declare -A taskTotals
function log {
echo $1
}
# parses the given profile file, extracts task durations that we are interested in and adds them to the global tracking
# usage: parseTimes profileFileURI prefix
function parseTimes {
filePath=$1
prefix=$2
# get the times
result=`curl -s $filePath|grep :$prefix -A1`
total=0
taskName="ERROR-$prefix"
while read -r line
do
if [[ "$line" == *"numeric"* ]]; then
taskTime=`echo $line|awk -F'[>s<]' '{print $5*1000}'`
total=$(($total + $taskTime))
taskTotals[$taskName]=$((taskTotals[$taskName] + $taskTime))
elif [[ "$line" == *":"* ]]; then
taskName=`echo $line|awk -F'[><]' '{print $3}'|awk -F'[:]' '{print $NF}'`
fi
done <<< $result
echo "total time spent for in this run $prefix: $total"
totals[$prefix]=$((totals[$prefix] + $total))
}
# Runs the kotlin integration test app with either ksp or kapt then records the duration of tasks.
# usage: runBuild ksp / runBuild kapt
function runBuild {
type=$1
useKsp=-1
if [ "$type" = "ksp" ]; then
echo "will use ksp"
useKsp=1
elif [ "$type" = "kapt" ]; then
echo "will use kapt"
useKsp=0
else
echo "bad arg '$type'"
exit
fi
cmd="./gradlew --profile room:integration-tests:room-testapp-kotlin:clean room:integration-tests:room-testapp-kotlin:assembleAndroidTest -PuseKsp=$useKsp"
log "Executing $cmd"
profileFile=`$cmd|grep -v "androidx-plugin"|awk '/profiling report at:/ {print $6}'`
log "result: $profileFile"
parseTimes $profileFile $type
}
# Runs the compilation with kapt and ksp for the given number of times
# usage: runTest 3
function runTest {
limit=$1
for (( c=1; c<=$limit; c++ ))
do
echo "run #$c of $limit"
runBuild "ksp"
runBuild "kapt"
done
}
function printData {
local -n data=$1
echo "$1:"
for i in "${!data[@]}"
do
echo "$i : ${data[$i]} ms"
done
}
runTest 10
printData totals
printData taskTotals