Move memory_advice training code into a separate repo
Memory advice libraries now live in the internal memory_advice_tools
repo; memoryadvice_exampleclient has been moved to samples/.
Bug: N/A
Test: N/A
Change-Id: Ie5283822c0c3ee9aa6799215e52c3a644a7077d4
diff --git a/games-memory-advice/CMakeLists.txt b/games-memory-advice/CMakeLists.txt
index 08645ae..92f7652 100644
--- a/games-memory-advice/CMakeLists.txt
+++ b/games-memory-advice/CMakeLists.txt
@@ -5,8 +5,7 @@
include("../samples/gamesdk.cmake")
-set( MEMORYADVICE_ASSETS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../test/memoryadvice/memoryadvice/src/main/assets/memoryadvice")
-set( MEMORYADVICE_RESOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../test/memoryadvice/memoryadvice/src/main/resources")
+set( RESOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/resources")
set( THIRD_PARTY_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../third_party")
set( TENSORFLOW_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../external/tensorflow")
set( EXTERNAL_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../external")
@@ -33,7 +32,7 @@
endif (${CMAKE_BUILD_TYPE} STREQUAL "Release")
set( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--hash-style=both" )
-file(READ "${MEMORYADVICE_ASSETS_DIR}/default.json" PARAMS_FILE)
+file(READ "${RESOURCES_DIR}/default.json" PARAMS_FILE)
set(PARAMS_STRING "namespace memory_advice {\nconst char* parameters_string = R\"PARAMS(\n")
string(APPEND PARAMS_STRING "${PARAMS_FILE}")
string(APPEND PARAMS_STRING "\n )PARAMS\";\n}\n")
@@ -71,8 +70,8 @@
../src/common/system_utils.cpp
${THIRD_PARTY_DIR}/json11/json11.cpp
advisor_parameters.cpp
- ${MEMORYADVICE_RESOURCES_DIR}/realtime.tflite
- ${MEMORYADVICE_RESOURCES_DIR}/oom_features.json
+ ${RESOURCES_DIR}/realtime.tflite
+ ${RESOURCES_DIR}/oom_features.json
)
add_library( tflite SHARED IMPORTED )
diff --git a/test/memoryadvice/memoryadvice/src/main/assets/memoryadvice/default.json b/games-memory-advice/resources/default.json
similarity index 100%
rename from test/memoryadvice/memoryadvice/src/main/assets/memoryadvice/default.json
rename to games-memory-advice/resources/default.json
diff --git a/test/memoryadvice/memoryadvice/src/main/resources/oom_features.json b/games-memory-advice/resources/oom_features.json
similarity index 100%
rename from test/memoryadvice/memoryadvice/src/main/resources/oom_features.json
rename to games-memory-advice/resources/oom_features.json
diff --git a/test/memoryadvice/memoryadvice/src/main/resources/realtime.tflite b/games-memory-advice/resources/realtime.tflite
similarity index 100%
rename from test/memoryadvice/memoryadvice/src/main/resources/realtime.tflite
rename to games-memory-advice/resources/realtime.tflite
Binary files differ
diff --git a/test/memoryadvice/.clang-format b/samples/memory_advice/.clang-format
similarity index 100%
rename from test/memoryadvice/.clang-format
rename to samples/memory_advice/.clang-format
diff --git a/test/memoryadvice_exampleclient/.gitignore b/samples/memory_advice/.gitignore
similarity index 100%
rename from test/memoryadvice_exampleclient/.gitignore
rename to samples/memory_advice/.gitignore
diff --git a/test/memoryadvice_exampleclient/app/.gitignore b/samples/memory_advice/app/.gitignore
similarity index 100%
rename from test/memoryadvice_exampleclient/app/.gitignore
rename to samples/memory_advice/app/.gitignore
diff --git a/test/memoryadvice_exampleclient/app/build.gradle b/samples/memory_advice/app/build.gradle
similarity index 100%
rename from test/memoryadvice_exampleclient/app/build.gradle
rename to samples/memory_advice/app/build.gradle
diff --git a/test/memoryadvice_exampleclient/app/src/main/AndroidManifest.xml b/samples/memory_advice/app/src/main/AndroidManifest.xml
similarity index 100%
rename from test/memoryadvice_exampleclient/app/src/main/AndroidManifest.xml
rename to samples/memory_advice/app/src/main/AndroidManifest.xml
diff --git a/test/memoryadvice_exampleclient/app/src/main/java/com/google/android/apps/internal/games/memoryadvice_exampleclient/MainActivity.java b/samples/memory_advice/app/src/main/java/com/google/android/apps/internal/games/memoryadvice_exampleclient/MainActivity.java
similarity index 100%
rename from test/memoryadvice_exampleclient/app/src/main/java/com/google/android/apps/internal/games/memoryadvice_exampleclient/MainActivity.java
rename to samples/memory_advice/app/src/main/java/com/google/android/apps/internal/games/memoryadvice_exampleclient/MainActivity.java
diff --git a/test/memoryadvice_exampleclient/app/src/main/java/com/google/android/apps/internal/games/memoryadvice_exampleclient/docs4/MainActivity.java b/samples/memory_advice/app/src/main/java/com/google/android/apps/internal/games/memoryadvice_exampleclient/docs4/MainActivity.java
similarity index 100%
rename from test/memoryadvice_exampleclient/app/src/main/java/com/google/android/apps/internal/games/memoryadvice_exampleclient/docs4/MainActivity.java
rename to samples/memory_advice/app/src/main/java/com/google/android/apps/internal/games/memoryadvice_exampleclient/docs4/MainActivity.java
diff --git a/test/istresser/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/samples/memory_advice/app/src/main/res/drawable-v24/ic_launcher_foreground.xml
similarity index 100%
rename from test/istresser/app/src/main/res/drawable-v24/ic_launcher_foreground.xml
rename to samples/memory_advice/app/src/main/res/drawable-v24/ic_launcher_foreground.xml
diff --git a/test/istresser/app/src/main/res/drawable/ic_launcher_background.xml b/samples/memory_advice/app/src/main/res/drawable/ic_launcher_background.xml
similarity index 100%
rename from test/istresser/app/src/main/res/drawable/ic_launcher_background.xml
rename to samples/memory_advice/app/src/main/res/drawable/ic_launcher_background.xml
diff --git a/test/memoryadvice_exampleclient/app/src/main/res/layout/activity_main.xml b/samples/memory_advice/app/src/main/res/layout/activity_main.xml
similarity index 100%
rename from test/memoryadvice_exampleclient/app/src/main/res/layout/activity_main.xml
rename to samples/memory_advice/app/src/main/res/layout/activity_main.xml
diff --git a/test/istresser/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/samples/memory_advice/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
similarity index 100%
rename from test/istresser/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
rename to samples/memory_advice/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
diff --git a/test/istresser/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/samples/memory_advice/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
similarity index 100%
rename from test/istresser/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
rename to samples/memory_advice/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
diff --git a/test/istresser/app/src/main/res/mipmap-hdpi/ic_launcher.png b/samples/memory_advice/app/src/main/res/mipmap-hdpi/ic_launcher.png
similarity index 100%
rename from test/istresser/app/src/main/res/mipmap-hdpi/ic_launcher.png
rename to samples/memory_advice/app/src/main/res/mipmap-hdpi/ic_launcher.png
Binary files differ
diff --git a/test/istresser/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/samples/memory_advice/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
similarity index 100%
rename from test/istresser/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
rename to samples/memory_advice/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
Binary files differ
diff --git a/test/istresser/app/src/main/res/mipmap-mdpi/ic_launcher.png b/samples/memory_advice/app/src/main/res/mipmap-mdpi/ic_launcher.png
similarity index 100%
rename from test/istresser/app/src/main/res/mipmap-mdpi/ic_launcher.png
rename to samples/memory_advice/app/src/main/res/mipmap-mdpi/ic_launcher.png
Binary files differ
diff --git a/test/istresser/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/samples/memory_advice/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
similarity index 100%
rename from test/istresser/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
rename to samples/memory_advice/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
Binary files differ
diff --git a/test/istresser/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/samples/memory_advice/app/src/main/res/mipmap-xhdpi/ic_launcher.png
similarity index 100%
rename from test/istresser/app/src/main/res/mipmap-xhdpi/ic_launcher.png
rename to samples/memory_advice/app/src/main/res/mipmap-xhdpi/ic_launcher.png
Binary files differ
diff --git a/test/istresser/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/samples/memory_advice/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
similarity index 100%
rename from test/istresser/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
rename to samples/memory_advice/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
Binary files differ
diff --git a/test/istresser/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/samples/memory_advice/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
similarity index 100%
rename from test/istresser/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
rename to samples/memory_advice/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Binary files differ
diff --git a/test/istresser/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/samples/memory_advice/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
similarity index 100%
rename from test/istresser/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
rename to samples/memory_advice/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
Binary files differ
diff --git a/test/istresser/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/samples/memory_advice/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
similarity index 100%
rename from test/istresser/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
rename to samples/memory_advice/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Binary files differ
diff --git a/test/istresser/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/samples/memory_advice/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
similarity index 100%
rename from test/istresser/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
rename to samples/memory_advice/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
Binary files differ
diff --git a/test/memoryadvice_exampleclient/app/src/main/res/values/strings.xml b/samples/memory_advice/app/src/main/res/values/strings.xml
similarity index 100%
rename from test/memoryadvice_exampleclient/app/src/main/res/values/strings.xml
rename to samples/memory_advice/app/src/main/res/values/strings.xml
diff --git a/test/memoryadvice_exampleclient/build.gradle b/samples/memory_advice/build.gradle
similarity index 100%
rename from test/memoryadvice_exampleclient/build.gradle
rename to samples/memory_advice/build.gradle
diff --git a/test/memoryadvice_exampleclient/gradle.properties b/samples/memory_advice/gradle.properties
similarity index 100%
rename from test/memoryadvice_exampleclient/gradle.properties
rename to samples/memory_advice/gradle.properties
diff --git a/test/memoryadvice/gradle/wrapper/gradle-wrapper.jar b/samples/memory_advice/gradle/wrapper/gradle-wrapper.jar
similarity index 100%
rename from test/memoryadvice/gradle/wrapper/gradle-wrapper.jar
rename to samples/memory_advice/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/test/memoryadvice_exampleclient/gradle/wrapper/gradle-wrapper.properties b/samples/memory_advice/gradle/wrapper/gradle-wrapper.properties
similarity index 100%
rename from test/memoryadvice_exampleclient/gradle/wrapper/gradle-wrapper.properties
rename to samples/memory_advice/gradle/wrapper/gradle-wrapper.properties
diff --git a/test/memoryadvice/gradlew b/samples/memory_advice/gradlew
similarity index 100%
rename from test/memoryadvice/gradlew
rename to samples/memory_advice/gradlew
diff --git a/test/memoryadvice/gradlew.bat b/samples/memory_advice/gradlew.bat
similarity index 100%
rename from test/memoryadvice/gradlew.bat
rename to samples/memory_advice/gradlew.bat
diff --git a/test/memoryadvice_exampleclient/settings.gradle b/samples/memory_advice/settings.gradle
similarity index 100%
rename from test/memoryadvice_exampleclient/settings.gradle
rename to samples/memory_advice/settings.gradle
diff --git a/test/collate/.clang-format b/test/collate/.clang-format
deleted file mode 100644
index 3b60c89..0000000
--- a/test/collate/.clang-format
+++ /dev/null
@@ -1,3 +0,0 @@
-BasedOnStyle: Google
-IndentWidth: 2
-SpacesBeforeTrailingComments: 2
diff --git a/test/collate/.gitignore b/test/collate/.gitignore
deleted file mode 100644
index 2549dd9..0000000
--- a/test/collate/.gitignore
+++ /dev/null
@@ -1,7 +0,0 @@
-.idea
-out
-cache
-reports
-target
-creds.json
-resources/sorter.js
\ No newline at end of file
diff --git a/test/collate/build.gradle b/test/collate/build.gradle
deleted file mode 100644
index f82b982..0000000
--- a/test/collate/build.gradle
+++ /dev/null
@@ -1,22 +0,0 @@
-apply plugin: 'java'
-
-repositories {
- google()
- mavenLocal()
- mavenCentral()
- maven {
- url 'https://jitpack.io'
- }
-}
-
-dependencies {
- implementation 'com.fasterxml.jackson.core:jackson-databind:2.12.2'
- implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-smile:2.12.3'
- implementation 'com.google.android.games:memory-advice-common:0.24'
- implementation 'com.google.cloud:google-cloud-storage:1.113.14'
- implementation 'com.google.oauth-client:google-oauth-client-jetty:1.31.2'
- implementation 'org.json:json:20210307'
- implementation 'com.google.apis:google-api-services-toolresults:v1beta3-rev651-1.25.0'
- implementation 'com.github.everit-org.json-schema:org.everit.json.schema:1.12.2'
- implementation 'com.google.cloud:google-cloud-datastore:1.105.7'
-}
diff --git a/test/collate/data/.gitignore b/test/collate/data/.gitignore
deleted file mode 100644
index 7340f2b..0000000
--- a/test/collate/data/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-clientSecrets.json
\ No newline at end of file
diff --git a/test/collate/gradle.properties b/test/collate/gradle.properties
deleted file mode 100644
index 2c4b330..0000000
--- a/test/collate/gradle.properties
+++ /dev/null
@@ -1 +0,0 @@
-org.gradle.jvmargs=-Xmx4608m
\ No newline at end of file
diff --git a/test/collate/gradle/wrapper/gradle-wrapper.jar b/test/collate/gradle/wrapper/gradle-wrapper.jar
deleted file mode 100644
index 62d4c05..0000000
--- a/test/collate/gradle/wrapper/gradle-wrapper.jar
+++ /dev/null
Binary files differ
diff --git a/test/collate/gradle/wrapper/gradle-wrapper.properties b/test/collate/gradle/wrapper/gradle-wrapper.properties
deleted file mode 100644
index c19e35b..0000000
--- a/test/collate/gradle/wrapper/gradle-wrapper.properties
+++ /dev/null
@@ -1,5 +0,0 @@
-distributionBase=GRADLE_USER_HOME
-distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.1-all.zip
-zipStoreBase=GRADLE_USER_HOME
-zipStorePath=wrapper/dists
diff --git a/test/collate/gradlew b/test/collate/gradlew
deleted file mode 100755
index fbd7c51..0000000
--- a/test/collate/gradlew
+++ /dev/null
@@ -1,185 +0,0 @@
-#!/usr/bin/env sh
-
-#
-# Copyright 2015 the original author or authors.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-##############################################################################
-##
-## Gradle start up script for UN*X
-##
-##############################################################################
-
-# Attempt to set APP_HOME
-# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >/dev/null
-APP_HOME="`pwd -P`"
-cd "$SAVED" >/dev/null
-
-APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
-
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
-
-# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD="maximum"
-
-warn () {
- echo "$*"
-}
-
-die () {
- echo
- echo "$*"
- echo
- exit 1
-}
-
-# OS specific support (must be 'true' or 'false').
-cygwin=false
-msys=false
-darwin=false
-nonstop=false
-case "`uname`" in
- CYGWIN* )
- cygwin=true
- ;;
- Darwin* )
- darwin=true
- ;;
- MINGW* )
- msys=true
- ;;
- NONSTOP* )
- nonstop=true
- ;;
-esac
-
-CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
-
-
-# Determine the Java command to use to start the JVM.
-if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
- # IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
- else
- JAVACMD="$JAVA_HOME/bin/java"
- fi
- if [ ! -x "$JAVACMD" ] ; then
- die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
- fi
-else
- JAVACMD="java"
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
-fi
-
-# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
- MAX_FD_LIMIT=`ulimit -H -n`
- if [ $? -eq 0 ] ; then
- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
- MAX_FD="$MAX_FD_LIMIT"
- fi
- ulimit -n $MAX_FD
- if [ $? -ne 0 ] ; then
- warn "Could not set maximum file descriptor limit: $MAX_FD"
- fi
- else
- warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
- fi
-fi
-
-# For Darwin, add options to specify how the application appears in the dock
-if $darwin; then
- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
-fi
-
-# For Cygwin or MSYS, switch paths to Windows format before running java
-if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
- APP_HOME=`cygpath --path --mixed "$APP_HOME"`
- CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
-
- JAVACMD=`cygpath --unix "$JAVACMD"`
-
- # We build the pattern for arguments to be converted via cygpath
- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
- SEP=""
- for dir in $ROOTDIRSRAW ; do
- ROOTDIRS="$ROOTDIRS$SEP$dir"
- SEP="|"
- done
- OURCYGPATTERN="(^($ROOTDIRS))"
- # Add a user-defined pattern to the cygpath arguments
- if [ "$GRADLE_CYGPATTERN" != "" ] ; then
- OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
- fi
- # Now convert the arguments - kludge to limit ourselves to /bin/sh
- i=0
- for arg in "$@" ; do
- CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
- CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
-
- if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
- eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
- else
- eval `echo args$i`="\"$arg\""
- fi
- i=`expr $i + 1`
- done
- case $i in
- 0) set -- ;;
- 1) set -- "$args0" ;;
- 2) set -- "$args0" "$args1" ;;
- 3) set -- "$args0" "$args1" "$args2" ;;
- 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
- esac
-fi
-
-# Escape application args
-save () {
- for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
- echo " "
-}
-APP_ARGS=`save "$@"`
-
-# Collect all arguments for the java command, following the shell quoting and substitution rules
-eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
-
-exec "$JAVACMD" "$@"
diff --git a/test/collate/gradlew.bat b/test/collate/gradlew.bat
deleted file mode 100644
index 5093609..0000000
--- a/test/collate/gradlew.bat
+++ /dev/null
@@ -1,104 +0,0 @@
-@rem
-@rem Copyright 2015 the original author or authors.
-@rem
-@rem Licensed under the Apache License, Version 2.0 (the "License");
-@rem you may not use this file except in compliance with the License.
-@rem You may obtain a copy of the License at
-@rem
-@rem https://www.apache.org/licenses/LICENSE-2.0
-@rem
-@rem Unless required by applicable law or agreed to in writing, software
-@rem distributed under the License is distributed on an "AS IS" BASIS,
-@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-@rem See the License for the specific language governing permissions and
-@rem limitations under the License.
-@rem
-
-@if "%DEBUG%" == "" @echo off
-@rem ##########################################################################
-@rem
-@rem Gradle startup script for Windows
-@rem
-@rem ##########################################################################
-
-@rem Set local scope for the variables with windows NT shell
-if "%OS%"=="Windows_NT" setlocal
-
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-set APP_BASE_NAME=%~n0
-set APP_HOME=%DIRNAME%
-
-@rem Resolve any "." and ".." in APP_HOME to make it shorter.
-for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
-
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
-
-@rem Find java.exe
-if defined JAVA_HOME goto findJavaFromJavaHome
-
-set JAVA_EXE=java.exe
-%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
-
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:findJavaFromJavaHome
-set JAVA_HOME=%JAVA_HOME:"=%
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-
-if exist "%JAVA_EXE%" goto init
-
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:init
-@rem Get command-line arguments, handling Windows variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-
-:execute
-@rem Setup the command line
-
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
-
-
-@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
-
-:end
-@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
-
-:fail
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
-rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
-
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
-
-:omega
diff --git a/test/collate/resources/main.html b/test/collate/resources/main.html
deleted file mode 100644
index 81b65a2..0000000
--- a/test/collate/resources/main.html
+++ /dev/null
@@ -1,16 +0,0 @@
-<html lang="en">
-<head>
- <script src="https://www.gstatic.com/external_hosted/dygraphs/dygraph-combined.js"></script>
- <title>Memory report</title>
-</head>
-<body>
-<link href="static/common.css" rel="stylesheet">
-<link href="static/dataExplorer.css" rel="stylesheet">
-<link href="static/report.css" rel="stylesheet">
-<script type="application/javascript">
-const data = [/*data*/];
-</script>
-<script src="static/report.js" type="module"></script>
-<main></main>
-</body>
-</html>
diff --git a/test/collate/resources/score.html b/test/collate/resources/score.html
deleted file mode 100644
index 3f73b33..0000000
--- a/test/collate/resources/score.html
+++ /dev/null
@@ -1,11 +0,0 @@
-<html lang="en">
-<head>
- <title>Memory score report</title>
-</head>
-<link href="static/common.css" rel="stylesheet">
-<link href="static/score.css" rel="stylesheet">
-<link href="static/dataExplorer.css" rel="stylesheet">
-
-<!--body-->
-
-</html>
diff --git a/test/collate/resources/static/buildDygraph.js b/test/collate/resources/static/buildDygraph.js
deleted file mode 100644
index da7d117..0000000
--- a/test/collate/resources/static/buildDygraph.js
+++ /dev/null
@@ -1,443 +0,0 @@
-import {getValues, rowMetrics, rowTime} from "./resultUtils.js";
-
-const onTrimCodes = {
- 0: 'TRIM_MEMORY_UNKNOWN',
- 5: 'TRIM_MEMORY_RUNNING_MODERATE',
- 10: 'TRIM_MEMORY_RUNNING_LOW',
- 15: 'TRIM_MEMORY_RUNNING_CRITICAL',
- 20: 'TRIM_MEMORY_UI_HIDDEN',
- 40: 'TRIM_MEMORY_BACKGROUND',
- 60: 'TRIM_MEMORY_MODERATE',
- 80: 'TRIM_MEMORY_COMPLETE'
-};
-
-function hashCode(str) {
- let hash = 0;
- for (let i = 0; i < str.length; i++) {
- hash = str.charCodeAt(i) + (hash << 5) - hash;
- }
- return hash;
-}
-
-export function buildDygraph(graphDiv, extrasDiv, deviceInfo, result) {
- const highlights = [];
-
- const annotations = [];
- let pausedStart = -1;
- let lowMemoryStart = -1;
- let serviceCrashedStart = -1;
- let allocFailedStart = -1;
- let activityPausedStart = -1;
- const graphData = [];
-
- const fields = ['Time'];
- const visibility = [];
- let startTime = 0;
- let time = 0;
- const series = {};
- const combined = {};
- const rowOut = [0];
- let maxApplicationAllocated = 0;
- for (const row of result) {
- const rowTime1 = rowTime(row);
- if (startTime === 0) {
- startTime = rowTime1;
- }
- time = (rowTime1 - startTime) / 1000;
-
- if ('exiting' in row) {
- annotations.push({
- series: 'applicationAllocated',
- x: time,
- shortText: 'E',
- text: 'Exiting'
- });
- }
- if ('onDestroy' in row) {
- annotations.push({
- series: 'applicationAllocated',
- x: time,
- shortText: 'D',
- text: 'onDestroy'
- });
- }
-
- if ('criticalLogLines' in row) {
- annotations.push({
- series: 'applicationAllocated',
- x: time,
- shortText: 'L',
- text: row.criticalLogLines[0]
- });
- }
-
- if ('activityPaused' in row) {
- if (row['activityPaused']) {
- if (activityPausedStart === -1) {
- activityPausedStart = time;
- }
- } else if (activityPausedStart !== -1) {
- highlights.push([activityPausedStart, time, 'lightgrey']);
- activityPausedStart = -1;
- }
- }
-
- let paused = !!row['paused'];
- if (paused && pausedStart === -1) {
- pausedStart = time;
- } else if (!row.paused && pausedStart !== -1) {
- highlights.push([pausedStart, time, 'yellow']);
- pausedStart = -1;
- }
-
- let serviceCrashed = !!row['serviceCrashed'];
- if (serviceCrashed && serviceCrashedStart === -1) {
- serviceCrashedStart = time;
- } else if (!serviceCrashed && serviceCrashedStart !== -1) {
- highlights.push([serviceCrashedStart, time, 'cyan']);
- serviceCrashedStart = -1;
- }
-
- let allocFailed = !!row['allocFailed'] || !!row['mmapAnonFailed'] ||
- !!row['mmapFileFailed'];
- if (allocFailed && allocFailedStart === -1) {
- allocFailedStart = time;
- } else if (!allocFailed && allocFailedStart !== -1) {
- highlights.push([allocFailedStart, time, 'lightblue']);
- allocFailedStart = -1;
- }
-
- if ('testMetrics' in row) {
- let applicationAllocated = 0;
- for (const value of Object.values(row.testMetrics)) {
- applicationAllocated += value;
- }
- combined.applicationAllocated = applicationAllocated;
- if (applicationAllocated > maxApplicationAllocated) {
- maxApplicationAllocated = applicationAllocated;
- }
- }
-
- const metrics = rowMetrics(row) || {};
-
- rowOut[0] = time;
-
- if ('constant' in metrics) {
- getValues(combined, metrics.constant, '');
- delete metrics.constant;
- }
-
- getValues(combined, metrics, '');
- delete combined.time;
- delete combined.onTrim;
- const advice = row.advice;
-
- if (advice && 'predictions' in advice && 'applicationAllocated' in combined) {
- const predictions = advice.predictions;
- for (const [field, value] of Object.entries(predictions).sort()) {
- const totalPrediction = value + combined.applicationAllocated;
- combined['prediction_' + field] =
- totalPrediction >= 0 ? totalPrediction : 0;
- }
- }
-
- for (const [field, value] of Object.entries(combined)) {
- if (typeof value !== 'number') {
- continue;
- }
- if (fields.indexOf(field) === -1) {
- const prefixPos = field.lastIndexOf('/');
- const prefix = prefixPos === -1 ? 'root' : field.substring(0, prefixPos);
-
- if (prefix === '_meta' || prefix === 'meta') {
- continue;
- }
-
- series[field] = {color: `hsl(${hashCode(field) % 360}, 100%, 30%)`};
- if (deviceInfo.params.heuristics &&
- field in deviceInfo.params.heuristics) {
- series[field].strokeWidth = 3;
- }
- fields.push(field);
- for (const existingRow of graphData) {
- existingRow.push(0);
- }
- visibility.push(localStorage.getItem(field) !== 'false');
- }
- rowOut[fields.indexOf(field)] =
- field === 'proc/oom_score' || field === 'predictedUsage' ? value : value / (1024 * 1024);
- }
-
- graphData.push(rowOut.slice(0));
-
- if ('onTrim' in metrics) {
- annotations.push({
- series: 'applicationAllocated',
- x: time,
- shortText: metrics.onTrim,
- text: onTrimCodes[metrics.onTrim]
- });
- }
-
- if ('mapTester' in metrics) {
- annotations.push(
- {series: 'applicationAllocated', x: time, shortText: 'M', text: 'M'});
- }
- if (advice && 'warnings' in advice) {
- const warnings = advice.warnings;
- for (let idx = 0; idx !== warnings.length; idx++) {
- let warning = warnings[idx];
- if (warning.level !== 'red') {
- continue;
- }
- for (const [key, value] of Object.entries(warning)) {
- if (key === 'level') {
- continue;
- }
- annotations.push({
- series: 'applicationAllocated',
- x: time,
- shortText: key,
- text: key
- });
- }
- }
- }
- let lowMemory = !!(metrics.MemoryInfo && metrics.MemoryInfo.lowMemory);
- if (lowMemory && lowMemoryStart === -1) {
- lowMemoryStart = time;
- } else if (!lowMemory && lowMemoryStart !== -1) {
- highlights.push([lowMemoryStart, time, 'pink']);
- lowMemoryStart = -1;
- }
- }
-
- if (activityPausedStart !== -1) {
- highlights.push([activityPausedStart, time, 'lightgrey']);
- allocFailedStart = -1;
- }
- if (pausedStart !== -1) {
- highlights.push([pausedStart, time, 'yellow']);
- }
- if (lowMemoryStart !== -1) {
- highlights.push([lowMemoryStart, time, 'pink']);
- }
- if (serviceCrashedStart !== -1) {
- highlights.push([serviceCrashedStart, time, 'cyan']);
- }
- if (allocFailedStart !== -1) {
- highlights.push([allocFailedStart, time, 'lightblue']);
- }
-
- if ('applicationAllocated' in series) {
- series.applicationAllocated.strokeWidth = 4;
- series.applicationAllocated.color = 'black';
- }
- const axes = {
- x: {drawGrid: false},
- y: {independentTicks: true},
-
- }
- let y2label;
- const useOom = localStorage.getItem("proc/oom_score") !== 'false';
- if (useOom && 'proc/oom_score' in series) {
- series['proc/oom_score'].axis = 'y2';
- axes.y2 = {valueRange: [0, 1000], independentTicks: true};
- y2label = 'OOM Score';
- } else if ('predictedUsage' in series) {
- series['predictedUsage'].axis = 'y2';
- axes.y2 = {valueRange: [0, 1], independentTicks: true};
- y2label = 'Predicted usage';
- }
- let wasHighlighted = null;
- const graph = new Dygraph(graphDiv, graphData, {
- height: 725,
- labels: fields,
- visibility,
- showLabelsOnHighlight: false,
- highlightCircleSize: 4,
- strokeWidth: 1,
- strokeBorderWidth: 1,
- highlightSeriesOpts:
- {strokeWidth: 2, strokeBorderWidth: 1, highlightCircleSize: 5},
- series: series,
- axes,
- ylabel: 'MB',
- y2label,
- includeZero: true,
-
- underlayCallback: (canvas, area, g) => {
- for (const [start, end, fillStyle] of highlights) {
- canvas.fillStyle = fillStyle;
- canvas.fillRect(
- g.toDomCoords(start, 0)[0], area.y,
- g.toDomCoords(end, 0)[0] - g.toDomCoords(start, 0)[0], area.h);
- }
- },
- pointClickCallback: (e, p) => {
- alert(p.name + '\n\n' + p.yval);
- },
- highlightCallback: (e, lastx, selPoints, lastRow_, highlightSet) => {
- const elements = document.getElementsByName(highlightSet);
- if (elements.length !== 1) {
- return;
- }
- const input = elements[0];
- if (wasHighlighted !== null) {
- wasHighlighted.style.color = wasHighlighted.style.backgroundColor;
- wasHighlighted.style.backgroundColor = '';
- wasHighlighted = null;
- }
- input.parentElement.style.backgroundColor =
- input.parentElement.style.color;
- input.parentElement.style.color = 'white';
- wasHighlighted = input.parentElement;
- },
- unhighlightCallback: (e) => {
- if (wasHighlighted !== null) {
- wasHighlighted.style.color = wasHighlighted.style.backgroundColor;
- wasHighlighted.style.backgroundColor = '';
- wasHighlighted = null;
- }
- }
- });
-
- if (maxApplicationAllocated > 0) {
- const oldValueRanges = graph.yAxisRanges();
- const newValueRanges = [...oldValueRanges];
- newValueRanges[0] = [0, maxApplicationAllocated / (1024 * 1024) / 0.6];
- graph.doAnimatedZoom(null, null, oldValueRanges, newValueRanges, () => {});
- }
-
- const fieldsets = {};
- const allCheckboxes = [];
- const form = document.createElement('form');
- form.classList.add('seriesForm');
- extrasDiv.appendChild(form);
-
- for (let idx = 0; idx !== fields.length; idx++) {
- const field = fields[idx];
- if (!(field in series)) {
- continue;
- }
- const prefixPos = field.lastIndexOf('/');
- const prefix = prefixPos === -1 ? 'root' : field.substring(0, prefixPos);
- const suffix = prefixPos === -1 ? field : field.substring(prefixPos + 1);
- let fieldset;
- if (prefix in fieldsets) {
- fieldset = fieldsets[prefix];
- } else {
- fieldset = document.createElement('fieldset');
- const legend = document.createElement('legend');
- legend.appendChild(document.createTextNode(prefix));
- fieldset.appendChild(legend);
- fieldsets[prefix] = fieldset;
- form.appendChild(fieldset);
- }
-
- const _series = series[field];
- const label = document.createElement('label');
- const input = document.createElement('input');
- label.appendChild(input);
- label.style.setProperty('color', _series.color);
- label.addEventListener('mouseover', evt => {
- graph.setSelection(0, field);
- graph.setVisibility(idx - 1, true);
- label.style.backgroundColor = label.style.color;
- label.style.color = 'white';
- wasHighlighted = label;
- });
- label.addEventListener('mouseout', evt => {
- if (wasHighlighted !== null) {
- graph.setVisibility(idx - 1, input.checked);
- wasHighlighted.style.color = wasHighlighted.style.backgroundColor;
- wasHighlighted.style.backgroundColor = '';
- wasHighlighted = null;
- }
- });
- input.setAttribute('type', 'checkbox');
- input.setAttribute('name', field);
- if (localStorage.getItem(field) !== 'false') {
- input.checked = true;
- }
-
- input.addEventListener('change', evt => {
- localStorage.setItem(field, input.checked);
- graph.setVisibility(idx - 1, input.checked);
- });
- allCheckboxes.push(input);
- label.appendChild(document.createTextNode(suffix));
- fieldset.appendChild(label);
- }
-
- const controls = document.createElement('section');
- {
- const selectAll = document.createElement('button');
- selectAll.appendChild(document.createTextNode('Select all'));
- selectAll.addEventListener('click', ev => {
- allCheckboxes.forEach(input => input.checked = true);
- const visibility = graph.visibility();
- for (let idx = 0; idx !== visibility.length; idx++) {
- visibility[idx] = true;
- }
- Object.keys(localStorage).forEach(key => {
- if (key !== 'saved') {
- localStorage.setItem(key, 'true');
- }
- });
- graph.setVisibility(0, true);
- });
- controls.appendChild(selectAll);
- }
-
- {
- const clearAll = document.createElement('button');
- clearAll.appendChild(document.createTextNode('Clear all'));
- clearAll.addEventListener('click', ev => {
- allCheckboxes.forEach(input => input.checked = false);
- const visibility = graph.visibility();
- for (let idx = 0; idx !== visibility.length; idx++) {
- visibility[idx] = false;
- }
- Object.keys(localStorage).forEach(key => {
- if (key !== 'saved') {
- localStorage.setItem(key, 'false');
- }
- });
-
- fields.forEach(field => localStorage.setItem(field, 'false'));
- graph.setVisibility(0, false);
- });
- controls.appendChild(clearAll);
- }
-
- {
- const save = document.createElement('button');
- save.appendChild(document.createTextNode('Save'));
- save.addEventListener('click', ev => {
- const saved = {};
- Object.keys(localStorage).forEach(key => {
- if (key !== 'saved') {
- saved[key] = localStorage.getItem(key);
- }
- });
- localStorage.setItem('saved', JSON.stringify(saved));
- });
- controls.appendChild(save);
- }
-
- {
- const load = document.createElement('button');
- load.appendChild(document.createTextNode('Load'));
- load.addEventListener('click', ev => {
- const saved = JSON.parse(localStorage.getItem('saved'));
- Object.keys(saved).forEach(key => localStorage.setItem(key, saved[key]));
- location.reload();
- });
- controls.appendChild(load);
- }
-
- extrasDiv.appendChild(controls);
-
- graph.ready(() => graph.setAnnotations(annotations));
-}
\ No newline at end of file
diff --git a/test/collate/resources/static/common.css b/test/collate/resources/static/common.css
deleted file mode 100644
index 6803bca..0000000
--- a/test/collate/resources/static/common.css
+++ /dev/null
@@ -1,16 +0,0 @@
-table, td, th {
- border: 1px solid;
- text-align: left;
-}
-
-table {
- border-collapse: collapse;
-}
-
-th, td {
- padding: 5px;
-}
-
-a {
- text-decoration: none;
-}
diff --git a/test/collate/resources/static/dataExplorer.css b/test/collate/resources/static/dataExplorer.css
deleted file mode 100644
index f6152b4..0000000
--- a/test/collate/resources/static/dataExplorer.css
+++ /dev/null
@@ -1,27 +0,0 @@
-ol {
- margin: 0;
-}
-
-details > summary > span {
- display: inline-block;
- max-width: 600px;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
-}
-
-details[open] > summary > span {
- display: none;
-}
-
-summary:focus {
- outline: none;
-}
-
-summary::-webkit-details-marker {
- color: lightgrey;
-}
-
-td.key {
- font-weight: bold;
-}
\ No newline at end of file
diff --git a/test/collate/resources/static/dataExplorer.js b/test/collate/resources/static/dataExplorer.js
deleted file mode 100644
index 953a121..0000000
--- a/test/collate/resources/static/dataExplorer.js
+++ /dev/null
@@ -1,58 +0,0 @@
-export function getDataExplorer(obj) {
- if (Array.isArray(obj)) {
- const ol = document.createElement('ol');
- ol.setAttribute('start', 0);
- for (let idx = 0; idx !== obj.length; idx++) {
- const li = document.createElement('li');
- li.appendChild(getDataExplorer(obj[idx]));
- ol.appendChild(li);
- }
- return ol;
- } else if (typeof obj === 'object') {
- const table = document.createElement('table');
- for (const [key, value] of Object.entries(obj)) {
- const tr = document.createElement('tr');
- const td0 = document.createElement('td');
- td0.classList.add('key');
- td0.appendChild(document.createTextNode(key));
- tr.appendChild(td0);
- const td1 = document.createElement('td');
- if (typeof value === 'object' || Array.isArray(value)) {
- const details = document.createElement('details');
- const summary = document.createElement('summary');
- const span = document.createElement('span');
- const text = document.createTextNode(JSON.stringify(value));
- span.appendChild(text);
- summary.appendChild(span);
- details.appendChild(summary);
- details.appendChild(getDataExplorer(value));
- td1.appendChild(details);
- } else {
- td1.appendChild(getDataExplorer(value));
- }
- tr.appendChild(td1);
- table.appendChild(tr);
- }
- return table;
- } else {
- if (typeof obj !== 'string') {
- obj = obj.toString();
- }
- const textNode = document.createTextNode(obj);
- if (/[\r\n]/.exec(obj)) {
- const pre = document.createElement('pre');
- pre.appendChild(textNode);
- return pre;
- } else {
- const a = document.createElement('a');
- a.appendChild(textNode);
- a.setAttribute('target', '_blank');
- a.href = obj;
- if (a.href === obj) {
- return a;
- } else {
- return textNode;
- }
- }
- }
-}
diff --git a/test/collate/resources/static/report.css b/test/collate/resources/static/report.css
deleted file mode 100644
index c801232..0000000
--- a/test/collate/resources/static/report.css
+++ /dev/null
@@ -1,32 +0,0 @@
-span.link {
- margin-right: 10px;
-}
-
-main {
- margin: 20px;
-}
-
-div.graph {
- margin: 4px;
-}
-
-form.seriesForm {
- display: flex;
- flex-wrap: wrap;
-}
-
-form.seriesForm > fieldset {
- border-style: dotted;
- padding: 0;
- margin-right: 10px;
- display: flex;
- flex-wrap: wrap;
-}
-
-form.seriesForm > fieldset > legend {
- font-weight: bold;
-}
-
-form.seriesForm > fieldset > label {
- margin-right: 5px
-}
diff --git a/test/collate/resources/static/report.js b/test/collate/resources/static/report.js
deleted file mode 100644
index 8a03109..0000000
--- a/test/collate/resources/static/report.js
+++ /dev/null
@@ -1,155 +0,0 @@
-import {buildDygraph} from './buildDygraph.js';
-import {getDataExplorer} from './dataExplorer.js';
-import {rowMetrics, rowTime} from './resultUtils.js';
-
-document.body.addEventListener('click', evt => {
- if (evt.target.href) {
- evt.target.href =
- evt.target.href.replace('gs://', 'https://storage.cloud.google.com/');
- }
-}, false);
-
-/**
- *
- * @type {ResultsRow[]}
- */
-const result = data;
-const first = result[0];
-
-result.sort((a, b) => rowTime(a) > rowTime(b) ? 1 : -1);
-
-const section = document.getElementsByTagName('main')[0];
-
-if ('extra' in first) {
- const extra = first.extra;
- if ('fromLauncher' in extra) {
- const fromLauncher = extra.fromLauncher;
- const h1 = document.createElement('h1');
- section.appendChild(h1);
- let fullName;
- if (fromLauncher.name.indexOf(fromLauncher.manufacturer) === -1) {
- fullName = `${fromLauncher.manufacturer} ${fromLauncher.name}`;
- } else {
- fullName = fromLauncher.name;
- }
- fullName += ` (${fromLauncher.id})`;
- h1.appendChild(document.createTextNode(fullName));
- const img = document.createElement('img');
- img.src = fromLauncher.thumbnailUrl;
- h1.appendChild(img);
- }
- {
- const paragraph = document.createElement('p');
- section.appendChild(paragraph);
- {
- const span = document.createElement('span');
- span.classList.add('link');
- const anchor = document.createElement('a');
- anchor.href = extra.resultsPage;
- anchor.appendChild(document.createTextNode('Results page'));
- span.appendChild(anchor);
- paragraph.appendChild(span);
- }
- {
- const span = document.createElement('span');
- span.classList.add('link');
- const toolLogs = extra.step.testExecutionStep.toolExecution.toolLogs;
- for (let idx = 0; idx !== toolLogs.length; idx++) {
- const anchor = document.createElement('a');
- span.appendChild(anchor);
- anchor.href = toolLogs[idx].fileUri;
- anchor.appendChild(document.createTextNode('Logs'));
- }
- paragraph.appendChild(span);
- }
- }
-}
-
-let deviceInfo;
-for (let idx = 0; idx !== result.length; idx++) {
- const row = result[idx];
- if ('deviceInfo' in row) {
- deviceInfo = row.deviceInfo;
- break;
- }
-}
-
-{
- const paragraph = document.createElement('p');
- section.appendChild(paragraph);
- paragraph.appendChild(getDataExplorer(first));
- paragraph.appendChild(getDataExplorer(deviceInfo));
- {
- const span = document.createElement('span');
- span.classList.add('link');
- const anchor = document.createElement('a');
- const label = document.createTextNode('Download JSON');
- anchor.appendChild(label);
- anchor.setAttribute('href', '_blank');
- anchor.addEventListener('click', ev => {
- anchor.setAttribute(
- 'href',
- 'data:application/json,' +
- encodeURIComponent(JSON.stringify(result, null, ' ')));
- })
- anchor.setAttribute('download', 'data');
- span.appendChild(anchor);
- paragraph.appendChild(span);
- }
- {
- const span = document.createElement('span');
- span.classList.add('link');
- const anchor = document.createElement('a');
- const label = document.createTextNode('View JSON');
- anchor.appendChild(label);
- anchor.setAttribute('href', '_blank');
- anchor.addEventListener('click', ev => {
- ev.preventDefault();
- const holder = document.createElement('p');
- holder.style.height = '600px';
- paragraph.appendChild(holder);
- const script = document.createElement('script');
- script.src = 'https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.12/ace.js';
- script.addEventListener('load', ev1 => {
- const jsonResults = ace.edit(holder, {
- mode: 'ace/mode/json',
- theme: 'ace/theme/crimson_editor',
- fontSize: '14px',
- readOnly: true
- });
- jsonResults.setValue(JSON.stringify(result, null, '\t'), -1);
- });
- document.body.appendChild(script);
- });
- span.appendChild(anchor);
- paragraph.appendChild(span);
- }
-}
-const graphDiv = document.createElement('div');
-section.appendChild(graphDiv);
-graphDiv.classList.add('graph');
-const extrasDiv = document.createElement('div');
-section.appendChild(extrasDiv);
-buildDygraph(graphDiv, extrasDiv, deviceInfo, result);
-
-let totalDuration = 0;
-let durationCount = 0;
-for (const row of result) {
- let metrics = rowMetrics(row);
- if (!metrics) {
- continue;
- }
-
- const advice = row.advice;
- if (advice && 'meta' in advice) {
- totalDuration += advice.meta.duration;
- durationCount++;
- }
-}
-
-if (durationCount > 0) {
- const paragraph = document.createElement('p');
- section.appendChild(paragraph);
- paragraph.appendChild(document.createTextNode(
- `Average duration ${(totalDuration / durationCount).toFixed(2)}`));
-}
diff --git a/test/collate/resources/static/resultUtils.js b/test/collate/resources/static/resultUtils.js
deleted file mode 100644
index 6be7589..0000000
--- a/test/collate/resources/static/resultUtils.js
+++ /dev/null
@@ -1,28 +0,0 @@
-export function rowMetrics(row) {
- if ('advice' in row) {
- return row.advice.metrics;
- } else if ('deviceInfo' in row) {
- return row.deviceInfo.baseline;
- } else if ('metrics' in row) {
- return row.metrics;
- } else {
- return undefined;
- }
-}
-
-export function rowTime(row) {
- if ('time' in row) {
- return row.time;
- }
- return rowMetrics(row).meta.time;
-}
-
-export function getValues(combined, object, path) {
- for (const [key, value] of Object.entries(object)) {
- if (typeof value === 'number') {
- combined[path + key] = value;
- } else if (value.constructor === Object) {
- getValues(combined, value, key + '/');
- }
- }
-}
\ No newline at end of file
diff --git a/test/collate/resources/static/score.css b/test/collate/resources/static/score.css
deleted file mode 100644
index e16eb51..0000000
--- a/test/collate/resources/static/score.css
+++ /dev/null
@@ -1,35 +0,0 @@
-td.best {
- background: lightgreen;
-}
-
-td.good {
- background: #dfffdf;
-}
-
-td.unacceptable {
- text-decoration: line-through;
-}
-
-td.failedToClear:after {
- content: "*";
-}
-
-td.serviceCrashed {
- font-weight: bold;
-}
-
-th.params {
- padding: 0;
-}
-
-th.params > table {
- border: none;
-}
-
-th.params details > summary > span {
- max-width: 200px;
-}
-
-th.params table td {
- border-color: lightgray;
-}
\ No newline at end of file
diff --git a/test/collate/resources/tests.json5 b/test/collate/resources/tests.json5
deleted file mode 100644
index 5c3be6e..0000000
--- a/test/collate/resources/tests.json5
+++ /dev/null
@@ -1,182 +0,0 @@
-[
- [
- {
- "apk_base": "../istresser/app/build/outputs/apk/debug",
- "apk_name": "app-debug.apk",
- "firebase" : {
- "no-record-video": true,
- "timeout" : "11m"
- },
- "orientation" : "landscape",
- "maxMillisecondsPerSecond": 1000,
- "minimumFrequency": 200,
- "maximumFrequency": 2000,
- "advisorParameters": {
- "metrics": {
- "constant": {
- "MemoryInfo": {
- "totalMem": true,
- "threshold": true
- },
- "meminfo": {
- "CommitLimit": true,
- "HighTotal": true,
- "LowTotal": true,
- "MemTotal": true
- },
- "ActivityManager": {
- "MemoryClass": true,
- "LargeMemoryClass": true,
- "LowRamDevice": true
- }
- },
- "variable": {
- "predictRealtime" : true,
- "debug": {
- "nativeHeapAllocatedSize": true
- },
- "MemoryInfo": {
- "availMem": true,
- "lowMemory": true
- },
- "meminfo": {
- "Active": true,
- "Active(anon)": true,
- "Active(file)": true,
- "AnonPages": true,
- "MemAvailable": true,
- "MemFree": true,
- "VmData": true,
- "VmRSS": true
- },
- "proc": {
- "oom_score": true
- },
- "status": {
- "VmRSS": true,
- "VmSize": true
- }
- }
- },
- "predictions": {
- "oom_score": true
- }
- }
- }
- ],
- [
- {
- "malloc": "40K"
- },
- {
- "glTest": "40K",
- "maxConsumer": "2048K"
- }
- ],
- [
- {
- },
- {
- "advisorParameters": {
- "heuristics": {
- "onTrim": true
- }
- }
- },
- {
- "advisorParameters": {
- "heuristics": {
- "oom_score": {
- "deltaLimit": {
- "red": 0.85,
- "yellow": 0.75
- }
- }
- }
- }
- },
- {
- "advisorParameters": {
- "heuristics": {
- "oom_score": {
- "fixed": {
- "red": 380,
- "yellow": 300
- }
- }
- }
- }
- },
- {
- "advisorParameters": {
- "heuristics": {
- "VmRSS": {
- "deltaLimit": {
- "red": 0.90,
- "yellow": 0.75
- }
- }
- }
- }
- },
- {
- "advisorParameters": {
- "heuristics": {
- "availMem": {
- "baselineRatio": {
- "red": 0.30,
- "yellow": 0.40
- }
- },
- "MemAvailable": {
- "baselineRatio": {
- "red": 0.30,
- "yellow": 0.40
- }
- }
- }
- }
- },
- {
- "advisorParameters": {
- "heuristics": {
- "Active": {
- "fixed": {
- "red": "300M",
- "yellow": "400M"
- }
- }
- }
- }
- },
- {
- "advisorParameters": {
- "metrics": {
- "variable": {
- "canaryProcessTester": {
- "memory": "1M"
- }
- }
- },
- "heuristics": {
- "canaryProcessTester": true
- }
- }
- },
- {
- "advisorParameters": {
- "predictOomLimit" : true,
- "heuristics": {
- "formulas": {
- "yellow": [
- "oom_score > predictedUsage * 0.75"
- ],
- "red": [
- "oom_score > predictedUsage * 0.85"
- ]
- }
- }
- }
- }
- ]
-]
\ No newline at end of file
diff --git a/test/collate/resources/tests_json.README b/test/collate/resources/tests_json.README
deleted file mode 100644
index 4652036..0000000
--- a/test/collate/resources/tests_json.README
+++ /dev/null
@@ -1,13 +0,0 @@
-test.json configures the number and configuration of the iStresser tests.
-
-It consists of an array of dimensions. Each dimension is itself an array of settings for that
-dimension.
-
-They are combined in a cartesian product to product settings for each test, which in turn is run on
-every eligible device.
-
-For example, if there were 3 dimensions, containing 2, 3 and 4 settings then 2 x 3 x 4 = 24 tests
-would be run in total.
-
-Any configuration key can be set in any dimension. The meaning of each configuration key is set by
-the iStresser app. Keys can be overridden in larger-numbered dimensions.
\ No newline at end of file
diff --git a/test/collate/settings.gradle b/test/collate/settings.gradle
deleted file mode 100644
index fb51ac4..0000000
--- a/test/collate/settings.gradle
+++ /dev/null
@@ -1,2 +0,0 @@
-rootProject.name = 'collate'
-
diff --git a/test/collate/src/main/java/net/jimblackler/collate/AuthUserFlow.java b/test/collate/src/main/java/net/jimblackler/collate/AuthUserFlow.java
deleted file mode 100644
index 0724361..0000000
--- a/test/collate/src/main/java/net/jimblackler/collate/AuthUserFlow.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package net.jimblackler.collate;
-
-import com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp;
-import com.google.api.client.extensions.jetty.auth.oauth2.LocalServerReceiver;
-import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow;
-import com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets;
-import com.google.api.client.http.javanet.NetHttpTransport;
-import com.google.api.client.json.JsonFactory;
-import com.google.api.client.util.store.FileDataStoreFactory;
-import com.google.auth.oauth2.GoogleCredentials;
-import com.google.auth.oauth2.UserCredentials;
-import com.google.common.collect.ImmutableList;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.nio.charset.StandardCharsets;
-
-public class AuthUserFlow {
- public static GoogleCredentials runAuthUserFlow(InputStream clientSecretsStream,
- JsonFactory jsonFactory, NetHttpTransport transport, ImmutableList<String> scopes)
- throws IOException {
- try (InputStreamReader reader =
- new InputStreamReader(clientSecretsStream, StandardCharsets.UTF_8)) {
- GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(jsonFactory, reader);
- String clientId = clientSecrets.getDetails().getClientId();
- GoogleClientSecrets.Details details = clientSecrets.getDetails();
- return UserCredentials.newBuilder()
- .setClientId(details.getClientId())
- .setClientSecret(details.getClientSecret())
- .setRefreshToken(new AuthorizationCodeInstalledApp(
- new GoogleAuthorizationCodeFlow.Builder(transport, jsonFactory, clientSecrets, scopes)
- .setDataStoreFactory(new FileDataStoreFactory(
- new File(AuthUserFlow.class.getResource("/").getPath(), clientId)))
- .setAccessType("offline")
- .setApprovalPrompt("auto")
- .build(),
- new LocalServerReceiver.Builder().setPort(61984).build())
- .authorize("user")
- .getRefreshToken())
- .build();
- }
- }
-}
\ No newline at end of file
diff --git a/test/collate/src/main/java/net/jimblackler/collate/CanaryFiredReport.java b/test/collate/src/main/java/net/jimblackler/collate/CanaryFiredReport.java
deleted file mode 100644
index ef3bf65..0000000
--- a/test/collate/src/main/java/net/jimblackler/collate/CanaryFiredReport.java
+++ /dev/null
@@ -1,140 +0,0 @@
-package net.jimblackler.collate;
-
-import static net.jimblackler.collate.Utils.getOrDefault;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.stream.Collectors;
-
-/**
- * A tool to analyze the recent run of iStresser in order to extract the record values of certain
- * memory metrics for all devices in the run.
- */
-public class CanaryFiredReport {
- private static final Mode mode = Mode.FORMULA;
-
- public static void main(String[] args) throws IOException {
- Gson gson = new GsonBuilder().setPrettyPrinting().create();
- List<Float> fireTimes = new ArrayList<>();
-
- AtomicInteger totalResults = new AtomicInteger();
- Collector.cloudCollect(null, results -> {
- if (results.isEmpty()) {
- return;
- }
- Map<String, Object> first = (Map<String, Object>) results.get(0);
-
- if (!first.containsKey("params")) {
- System.out.println("No usable results. Data returned was:");
- System.out.println(gson.toJson(results));
- return;
- }
-
- Map<String, Object> flattened =
- Utils.flattenParams((Map<String, Object>) first.get("params"));
- Map<String, Object> advisorParameters =
- (Map<String, Object>) flattened.get("advisorParameters");
- if (advisorParameters != null) {
- Map<String, Object> heuristics = (Map<String, Object>) advisorParameters.get("heuristics");
- if (heuristics != null && !heuristics.isEmpty()) {
- // Runs with heuristics are not useful.
- return;
- }
- }
- if (!flattened.containsKey("malloc") && !flattened.containsKey("glTest")
- && !flattened.containsKey("vkTest")) {
- // Only interested in these kinds of stress tests.
- return;
- }
-
- Map<String, Object> fired = null;
- Map<String, Object> finalRow = null;
- Map<String, Object> baselineMetrics = null;
- for (Object o : results) {
- Map<String, Object> row = (Map<String, Object>) o;
- if (Boolean.TRUE.equals(row.get("activityPaused"))) {
- // The run was interrupted and is unusable.
- finalRow = null;
- break;
- }
-
- Map<String, Object> metrics = ReportUtils.rowMetrics(row);
- if (metrics == null) {
- continue;
- }
- if (baselineMetrics == null) {
- baselineMetrics = metrics;
- }
-
- if (Boolean.TRUE.equals(row.get("allocFailed"))
- || Boolean.TRUE.equals(row.get("mmapAnonFailed"))
- || Boolean.TRUE.equals(row.get("mmapFileFailed"))
- || row.containsKey("criticalLogLines")) {
- break;
- }
- finalRow = row;
- if (fired == null) {
- switch (mode) {
- case MAP:
- if (Boolean.TRUE.equals(metrics.get("mapTester"))) {
- fired = row;
- }
- break;
- case PROCESS:
- if ("red".equals(metrics.get("canaryProcessTester"))) {
- fired = row;
- }
- break;
- case LOW_MEMORY:
- Map<String, Object> memoryInfo = (Map<String, Object>) metrics.get("MemoryInfo");
- if (memoryInfo != null) {
- if (getOrDefault(memoryInfo, "lowMemory", false)) {
- fired = row;
- }
- }
- break;
- case FORMULA:
- Map<String, Object> status = (Map<String, Object>) metrics.get("status");
- if (status != null) {
- Number vmRSS1 = (Number) status.get("VmRSS");
- long vmRSS = vmRSS1 == null ? 0 : vmRSS1.longValue();
- Map<String, Object> baselineMemoryInfo =
- (Map<String, Object>) baselineMetrics.get("MemoryInfo");
- if (baselineMemoryInfo != null) {
- Number availMem = (Number) baselineMemoryInfo.get("availMem");
- long baselineAvailMem = availMem == null ? 0 : availMem.longValue();
- if (vmRSS > baselineAvailMem) {
- fired = row;
- }
- }
- }
- }
- }
- }
- if (finalRow != null) {
- totalResults.getAndIncrement();
- long firstTime = ReportUtils.rowTime(first);
- long finalTime = ReportUtils.rowTime(finalRow);
-
- if (fired != null) {
- long fireTime = ReportUtils.rowTime(fired);
- float relative = (float) (fireTime - firstTime) / (finalTime - firstTime);
- fireTimes.add(relative);
- }
- }
- });
-
- System.out.println("Total, Fired, Didn't Fire, Times");
- System.out.print(totalResults + ",");
- System.out.print(fireTimes.size() + ",");
- System.out.print(totalResults.get() - fireTimes.size() + ",");
- System.out.println(fireTimes.stream().map(Object::toString).collect(Collectors.joining(",")));
- }
-
- private enum Mode { MAP, PROCESS, LOW_MEMORY, FORMULA }
-}
diff --git a/test/collate/src/main/java/net/jimblackler/collate/Collector.java b/test/collate/src/main/java/net/jimblackler/collate/Collector.java
deleted file mode 100644
index 3ff7620..0000000
--- a/test/collate/src/main/java/net/jimblackler/collate/Collector.java
+++ /dev/null
@@ -1,379 +0,0 @@
-package net.jimblackler.collate;
-
-import static com.google.api.client.googleapis.javanet.GoogleNetHttpTransport.newTrustedTransport;
-import static net.jimblackler.collate.JsonUtils.getSchema;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.ObjectReader;
-import com.fasterxml.jackson.dataformat.smile.databind.SmileMapper;
-import com.google.api.client.http.HttpRequestInitializer;
-import com.google.api.client.http.javanet.NetHttpTransport;
-import com.google.api.client.json.jackson2.JacksonFactory;
-import com.google.api.services.toolresults.ToolResults;
-import com.google.api.services.toolresults.model.Execution;
-import com.google.api.services.toolresults.model.ListExecutionsResponse;
-import com.google.api.services.toolresults.model.ListHistoriesResponse;
-import com.google.api.services.toolresults.model.ListStepsResponse;
-import com.google.api.services.toolresults.model.Step;
-import com.google.api.services.toolresults.model.StepDimensionValueEntry;
-import com.google.api.services.toolresults.model.TestExecutionStep;
-import com.google.api.services.toolresults.model.ToolExecution;
-import com.google.api.services.toolresults.model.ToolOutputReference;
-import com.google.auth.http.HttpCredentialsAdapter;
-import com.google.auth.oauth2.GoogleCredentials;
-import com.google.cloud.datastore.DatastoreOptions;
-import com.google.cloud.datastore.Query;
-import com.google.cloud.datastore.StructuredQuery;
-import com.google.cloud.storage.Blob;
-import com.google.cloud.storage.BlobId;
-import com.google.cloud.storage.Storage;
-import com.google.cloud.storage.StorageOptions;
-import com.google.common.collect.ImmutableList;
-import java.io.IOException;
-import java.net.URI;
-import java.nio.charset.MalformedInputException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.security.GeneralSecurityException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.function.Consumer;
-import java.util.regex.Pattern;
-import org.everit.json.schema.Schema;
-import org.everit.json.schema.ValidationException;
-import org.json.JSONObject;
-
-class Collector {
- private static final Pattern BAD_CHARS = Pattern.compile("[^a-zA-Z0-9-_.]");
- private static final Pattern LINE_SPLIT = Pattern.compile("\\r?\\n");
-
- static void deviceCollect(String appName, Consumer<List<Map<String, Object>>> emitter)
- throws IOException {
- Schema resultsRowSchema = getSchema("resultsRow.schema.json");
- // Requires adb root
- Path outputFile = Files.createTempFile("data-", ".json");
- // noinspection HardcodedFileSeparator
- String files = Utils.execute("adb", "shell", "find",
- "/storage/emulated/0/Android/data/" + appName + "/files", "-type", "f");
- for (String file : files.split(System.lineSeparator())) {
- Utils.execute("adb", "pull", file, outputFile.toString());
- collectResult(emitter, FileUtils.readFile(outputFile), null, resultsRowSchema);
- }
- }
-
- static void cloudCollect(String historyId, Consumer<List<Map<String, Object>>> emitter)
- throws IOException {
- int sleepFor = 0;
- int ioSleepFor = 0;
-
- String projectId = Utils.getProjectId();
-
- Schema resultsRowSchema = getSchema("resultsRow.schema.json");
- Map<String, Map<String, Object>> launcherDevices = new HashMap<>();
- DeviceFetcher.fetch(device -> launcherDevices.put((String) device.get("id"), device));
-
- int inProgress = 0;
- Collection<String> reported = new HashSet<>();
- NetHttpTransport httpTransport = null;
- try {
- httpTransport = newTrustedTransport();
- } catch (GeneralSecurityException e) {
- throw new IOException(e);
- }
- JacksonFactory jsonFactory = new JacksonFactory();
- GoogleCredentials googleCredentials = AuthUserFlow.runAuthUserFlow(
- Collector.class.getResourceAsStream("/clientSecrets.json"), jsonFactory, httpTransport,
- ImmutableList.of("https://www.googleapis.com/auth/devstorage.read_only",
- "https://www.googleapis.com/auth/cloud-platform"));
- HttpRequestInitializer requestInitializer = new HttpCredentialsAdapter(googleCredentials);
- do {
- try {
- Storage storage =
- StorageOptions.newBuilder().setCredentials(googleCredentials).build().getService();
- ToolResults toolResults =
- new ToolResults.Builder(new NetHttpTransport(), jsonFactory, requestInitializer)
- .setServicePath(ToolResults.DEFAULT_SERVICE_PATH)
- .setApplicationName(projectId)
- .build();
-
- if (historyId == null) {
- // If no historyId supplied, get the latest run.
- ListHistoriesResponse historiesResponse =
- toolResults.projects().histories().list(projectId).setPageSize(1).execute();
- historyId = historiesResponse.getHistories().get(0).getHistoryId();
- }
-
- while (true) {
- int fetched = 0;
- inProgress = 0;
- ToolResults.Projects.Histories.Executions.List list =
- toolResults.projects().histories().executions().list(projectId, historyId);
- while (true) {
- ListExecutionsResponse response = list.execute();
- if (response == null) {
- break;
- }
- for (Execution execution : response.getExecutions()) {
- String executionId = execution.getExecutionId();
- ToolResults.Projects.Histories.Executions.Steps.List list1 =
- toolResults.projects().histories().executions().steps().list(
- projectId, historyId, executionId);
- while (true) {
- ListStepsResponse response1 = list1.execute();
- if (response1.isEmpty()) {
- break;
- }
- for (Step step : response1.getSteps()) {
- if ("inProgress".equals(step.getState())) {
- inProgress++;
- }
- TestExecutionStep testExecutionStep = step.getTestExecutionStep();
- if (testExecutionStep == null) {
- continue;
- }
- ToolExecution toolExecution = testExecutionStep.getToolExecution();
- if (toolExecution == null) {
- continue;
- }
- String stepId = step.getStepId();
- if (!reported.add(stepId)) {
- continue;
- }
- fetched++;
- Map<String, Object> extra = new LinkedHashMap<>();
- extra.put("historyId", historyId);
- extra.put("step", step);
- // noinspection HardcodedFileSeparator
- extra.put("resultsPage",
- "https://console.firebase.google.com/project/" + projectId
- + "/testlab/histories/" + historyId + "/matrices/" + executionId
- + "/executions/" + stepId);
- for (StepDimensionValueEntry entry : step.getDimensionValue()) {
- if ("Model".equals(entry.getKey())) {
- String id = entry.getValue();
- if (launcherDevices.containsKey(id)) {
- extra.put("fromLauncher", launcherDevices.get(id));
- }
- break;
- }
- }
-
- List<ToolOutputReference> toolOutputs = toolExecution.getToolOutputs();
- String contents = "";
- if (toolOutputs != null) {
- for (ToolOutputReference toolOutputReference : toolOutputs) {
- URI uri = URI.create(toolOutputReference.getOutput().getFileUri());
- if (!uri.getPath().endsWith(".json")) {
- continue;
- }
- try {
- contents = getContents(storage, uri.getHost(), uri.getPath().substring(1));
- break;
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
- collectResult(emitter, contents, extra, resultsRowSchema);
- }
- String nextPageToken1 = response1.getNextPageToken();
- if (nextPageToken1 == null) {
- break;
- }
- list1.setPageToken(nextPageToken1);
- }
- }
- String nextPageToken = response.getNextPageToken();
- if (nextPageToken == null) {
- break;
- }
- list.setPageToken(nextPageToken);
- }
- if (inProgress == 0) {
- break;
- }
- System.out.println(inProgress + " runs in progress");
- if (fetched == 0) {
- sleepFor += 10;
- System.out.print("Nothing fetched so sleeping for " + sleepFor + " seconds... ");
- try {
- Thread.sleep(sleepFor * 1000L);
- } catch (InterruptedException ignored) {
- // Ignored by design.
- }
- System.out.println("done");
- } else {
- sleepFor = 0;
- }
- }
- ioSleepFor = 0;
- } catch (IOException e) {
- e.printStackTrace();
- ioSleepFor += 10;
- System.out.print("IO error so sleeping for " + ioSleepFor + " seconds... ");
- try {
- Thread.sleep(ioSleepFor * 1000L);
- } catch (InterruptedException ignored) {
- // Ignored by design.
- }
- System.out.println("done");
- }
- } while (inProgress != 0 || reported.isEmpty());
- }
-
- private static void collectResult(Consumer<List<Map<String, Object>>> emitter, String text,
- Map<String, Object> extra, Schema resultsRowSchema) {
- ObjectMapper objectMapper = new ObjectMapper();
- boolean validate = false;
- List<Map<String, Object>> data = new ArrayList<>();
- Arrays.asList(LINE_SPLIT.split(text)).forEach(line -> {
- line = line.trim();
- try {
- Map<String, Object> value = objectMapper.readValue(line, Map.class);
- if (validate) {
- resultsRowSchema.validate(new JSONObject(line));
- }
- data.add(value);
- } catch (JsonProcessingException e) {
- System.out.println("Not JSON: " + line);
- } catch (ValidationException e) {
- System.out.println("Did not validate: " + e.getMessage());
- }
- });
- if (data.isEmpty()) {
- data.add(new LinkedHashMap<>());
- }
- if (extra != null) {
- data.get(0).put("extra", extra);
- }
- emitter.accept(data);
- }
-
- private static String getContents(Storage storage, String bucketName, String path)
- throws IOException {
- Path file = Paths.get("cache", bucketName, BAD_CHARS.matcher(path).replaceAll("_"));
-
- if (!Files.exists(file)) {
- System.out.println("Fetching " + path);
- file.toFile().getParentFile().mkdirs();
- BlobId blobId = BlobId.of(bucketName, path);
- Blob blob = storage.get(blobId);
- if (blob == null) {
- throw new IOException("Could not get blob " + blobId);
- } else {
- blob.downloadTo(file);
- }
- }
- try {
- String s = FileUtils.readFile(file);
- if (s.isEmpty()) {
- Files.delete(file); // Don't cache an empty file.
- }
- return s;
- } catch (MalformedInputException e) {
- throw new IOException(e);
- }
- }
-
- static void collectDataStoreResult(DataStoreResultConsumer consumer, String version)
- throws IOException {
- ObjectMapper objectMapper = new ObjectMapper();
- ObjectReader objectReader = objectMapper.reader();
- ObjectReader smileReader = new SmileMapper().reader();
- Collection<Number> runTimes = new HashSet<>();
- NetHttpTransport httpTransport;
- try {
- httpTransport = newTrustedTransport();
- } catch (GeneralSecurityException e) {
- throw new IOException(e);
- }
- JacksonFactory jsonFactory = new JacksonFactory();
- String secretsName = "/clientSecrets_gatherBenchmarks.json";
- GoogleCredentials googleCredentials =
- AuthUserFlow.runAuthUserFlow(Collector.class.getResourceAsStream(secretsName), jsonFactory,
- httpTransport, ImmutableList.of("https://www.googleapis.com/auth/datastore"));
- Map<String, Object> secrets =
- jsonFactory.fromInputStream(Collector.class.getResourceAsStream(secretsName), Map.class);
- Map<String, Object> installed = (Map<String, Object>) secrets.get("installed");
- String projectId = (String) installed.get("project_id");
- DatastoreOptions.newBuilder()
- .setCredentials(googleCredentials)
- .setProjectId(projectId)
- .build()
- .getService()
- .run(Query.newEntityQueryBuilder()
- .setKind("Benchmark")
- .setFilter(StructuredQuery.CompositeFilter.and(
- StructuredQuery.PropertyFilter.eq("versionName", version),
- StructuredQuery.PropertyFilter.eq("testType", "management")))
- .build())
- .forEachRemaining(entity -> {
- Map<String, Object> results1;
- try {
- if (entity.contains("resultsSmile")) {
- com.google.cloud.datastore.Blob resultsSmile = entity.getBlob("resultsSmile");
- results1 = smileReader.readValue(resultsSmile.toByteArray(), Map.class);
- } else {
- results1 = objectReader.readValue(entity.getString("results"), Map.class);
- }
- } catch (IOException e) {
- throw new IllegalStateException(e);
- }
-
- Number runTime = (Number) results1.get("runTime");
- if (!runTimes.add(runTime)) {
- System.out.println("Duplicate run seen");
- return;
- }
-
- System.out.println("Registering run number " + runTimes.size());
-
- List<List<Map<String, Object>>> tests1 =
- (List<List<Map<String, Object>>>) results1.get("tests");
-
- Map<String, Object> buildConfig = (Map<String, Object>) results1.get("buildConfig");
-
- String versionName = (String) buildConfig.get("VERSION_NAME");
-
- List<List<Map<String, Object>>> results =
- (List<List<Map<String, Object>>>) results1.get("results");
- for (int testNumber = 0; testNumber != results.size(); testNumber++) {
- List<Map<String, Object>> result = results.get(testNumber);
- Map<String, Object> paramsIn = new LinkedHashMap<>();
- paramsIn.put("tests", tests1);
- paramsIn.put("coordinates", getCoordinates(testNumber, tests1));
- paramsIn.put("run", versionName);
- if (!result.isEmpty()) {
- Map<String, Object> first = result.get(0);
- if (first != null) {
- first.put("params", paramsIn);
- }
- }
- consumer.accept(results1, result);
- }
- });
- }
-
- static Collection<Integer> getCoordinates(int testNumber, List<List<Map<String, Object>>> tests) {
- List<Integer> coordinates = new ArrayList<>();
- int calc = testNumber;
- for (int idx = tests.size() - 1; idx >= 0; idx--) {
- int dimensionSize = tests.get(idx).size();
- coordinates.add(0, calc % dimensionSize);
- calc /= dimensionSize;
- }
- return coordinates;
- }
-
- interface DataStoreResultConsumer {
- void accept(Map<String, Object> results1, List<Map<String, Object>> result);
- }
-}
diff --git a/test/collate/src/main/java/net/jimblackler/collate/Config.java b/test/collate/src/main/java/net/jimblackler/collate/Config.java
deleted file mode 100644
index a1183c2..0000000
--- a/test/collate/src/main/java/net/jimblackler/collate/Config.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package net.jimblackler.collate;
-
-import java.nio.file.FileSystems;
-import java.nio.file.Path;
-
-public class Config {
- private static final Path HOME =
- FileSystems.getDefault().getPath(System.getProperty("user.home"));
- private static final Path SDK_BASE = HOME.resolve("code/android-games-sdk");
- static final Path GRABBER_BASE = SDK_BASE.resolve("gamesdk/test/grabber");
- private static final Path GCLOUD_LOCATION = HOME.resolve("Library")
- .resolve("Application Support")
- .resolve("google-cloud-tools-java")
- .resolve("managed-cloud-sdk")
- .resolve("LATEST")
- .resolve("google-cloud-sdk")
- .resolve("bin");
- static final Path GCLOUD_EXECUTABLE = GCLOUD_LOCATION.resolve("gcloud");
-}
diff --git a/test/collate/src/main/java/net/jimblackler/collate/CreateTrainingData.java b/test/collate/src/main/java/net/jimblackler/collate/CreateTrainingData.java
deleted file mode 100644
index 4c2c3af..0000000
--- a/test/collate/src/main/java/net/jimblackler/collate/CreateTrainingData.java
+++ /dev/null
@@ -1,143 +0,0 @@
-package net.jimblackler.collate;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import java.io.File;
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
-import java.util.SortedMap;
-import java.util.TreeMap;
-import java.util.function.Consumer;
-
-/**
- * Creates training data for the machine learning tool.
- */
-public class CreateTrainingData {
- private static final boolean USE_DATASTORE = true;
- private static final String VERSION = "1.7.19";
-
- public static void main(String[] args) throws IOException {
- Gson gson = new GsonBuilder().setPrettyPrinting().create();
- List<Object> dataOut = new ArrayList<>();
- Random random = new Random();
- Consumer<List<Map<String, Object>>> consumer = results -> {
- if (results.isEmpty()) {
- return;
- }
- Map<String, Object> first = results.get(0);
-
- if (!first.containsKey("params")) {
- System.out.println("No usable results. Data returned was:");
- System.out.println(gson.toJson(results));
- return;
- }
- Map<String, Object> deviceInfo = ReportUtils.getDeviceInfo(results);
- if (deviceInfo == null) {
- return;
- }
- Map<String, Object> flattened =
- Utils.flattenParams((Map<String, Object>) first.get("params"));
- Map<String, Object> advisorParameters =
- (Map<String, Object>) flattened.get("advisorParameters");
- if (advisorParameters != null) {
- Map<String, Object> heuristics = (Map<String, Object>) advisorParameters.get("heuristics");
- if (heuristics != null && !heuristics.isEmpty()) {
- // Runs with heuristics are not useful.
- return;
- }
- }
-
- if (!flattened.containsKey("malloc") && !flattened.containsKey("glTest")) {
- // Only interested in these kinds of stress tests.
- return;
- }
-
- Map<String, Object> dataOut2 = new LinkedHashMap<>();
- dataOut2.put("build", deviceInfo.get("build"));
- dataOut2.put("baseline", deviceInfo.get("baseline"));
-
- int seen = 0;
- Map<String, Object> sample = null;
-
- SortedMap<Long, Map<String, Object>> sorted = new TreeMap<>();
- results.forEach(row -> sorted.put(ReportUtils.rowTime(row), row));
-
- Map<String, Object> baseline = null;
- Map<String, Object> limit = null;
-
- long firstTime = Long.MAX_VALUE;
- for (Map.Entry<Long, Map<String, Object>> pair : sorted.entrySet()) {
- long time = pair.getKey();
- Map<String, Object> row = pair.getValue();
- if (Boolean.TRUE.equals(row.get("paused"))) {
- continue;
- }
-
- Map<String, Object> metrics = ReportUtils.rowMetrics(row);
- if (metrics == null) {
- continue;
- }
-
- // Limit is the latest reading.
- limit = row;
-
- if (Boolean.TRUE.equals(row.get("activityPaused"))) {
- // The run was interrupted and is unusable.
- return;
- }
- if (Boolean.TRUE.equals(row.get("allocFailed"))
- || Boolean.TRUE.equals(row.get("mmapAnonFailed"))
- || Boolean.TRUE.equals(row.get("mmapFileFailed"))
- || row.containsKey("criticalLogLines")) {
- break;
- }
-
- if (firstTime == Long.MAX_VALUE) {
- firstTime = time;
- }
-
- if (metrics.containsKey("constant") && baseline == null) {
- // Baseline is the earliest reading with 'constant'.
- baseline = row;
- }
-
- seen++;
- if (random.nextInt(seen) == 0) {
- sample = row;
- }
- }
- if (limit == null) {
- return;
- }
- if (sample == null) {
- return;
- }
-
- long finalTime = ReportUtils.rowTime(limit);
- dataOut2.put("limit", limit);
- dataOut2.put("firstTime", firstTime);
- dataOut2.put("finalTime", finalTime);
- dataOut2.put("sample", ReportUtils.rowMetrics(sample));
- if (sample.containsKey("testMetrics")) {
- dataOut2.put("sampleTestMetrics", sample.get("testMetrics"));
- }
- dataOut.add(dataOut2);
- };
-
- if (USE_DATASTORE) {
- Collector.collectDataStoreResult((results1, result) -> consumer.accept(result), VERSION);
- } else {
- for (File directory : new File("reports").listFiles(File::isDirectory)) {
- Collector.cloudCollect(directory.getName(), consumer);
- }
- }
- Files.write(Paths.get("realtime.json"), gson.toJson(dataOut).getBytes(StandardCharsets.UTF_8));
- }
-}
diff --git a/test/collate/src/main/java/net/jimblackler/collate/CsvEscaper.java b/test/collate/src/main/java/net/jimblackler/collate/CsvEscaper.java
deleted file mode 100644
index 41c78f0..0000000
--- a/test/collate/src/main/java/net/jimblackler/collate/CsvEscaper.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package net.jimblackler.collate;
-
-public class CsvEscaper {
- public static String escape(String value) {
- if (!value.contains(",")) {
- return value;
- }
- return "\"" + value + "\"";
- }
-}
diff --git a/test/collate/src/main/java/net/jimblackler/collate/DataExplorer.java b/test/collate/src/main/java/net/jimblackler/collate/DataExplorer.java
deleted file mode 100644
index a0ee6df..0000000
--- a/test/collate/src/main/java/net/jimblackler/collate/DataExplorer.java
+++ /dev/null
@@ -1,70 +0,0 @@
-package net.jimblackler.collate;
-
-import com.google.gson.Gson;
-import java.util.List;
-import java.util.Map;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.Text;
-
-public class DataExplorer {
- static Node getDataExplorer(Document document, Object obj) {
- Gson gson = new Gson();
- if (obj instanceof List) {
- Element ol = document.createElement("ol");
- List<Object> array = (List<Object>) obj;
- ol.setAttribute("start", "0");
- for (int idx = 0; idx != array.size(); idx++) {
- Element li = document.createElement("li");
- li.appendChild(getDataExplorer(document, array.get(idx)));
- ol.appendChild(li);
- }
- return ol;
- } else if (obj instanceof Map) {
- Element table = document.createElement("table");
- Map<String, Object> object = (Map<String, Object>) obj;
- for (Map.Entry<String, Object> entry : object.entrySet()) {
- Object value = entry.getValue();
- Element tr = document.createElement("tr");
- Element td0 = document.createElement("td");
- td0.appendChild(document.createTextNode(entry.getKey()));
- td0.setAttribute("class", "key");
- tr.appendChild(td0);
- Element td1 = document.createElement("td");
- if (value instanceof Map || value instanceof List) {
- Element details = document.createElement("details");
- Element summary = document.createElement("summary");
- Element span = document.createElement("span");
- Text text = document.createTextNode(value.toString());
- span.appendChild(text);
- summary.appendChild(span);
- details.appendChild(summary);
- details.appendChild(getDataExplorer(document, value));
- td1.appendChild(details);
- } else {
- td1.appendChild(getDataExplorer(document, value));
- }
- tr.appendChild(td1);
- table.appendChild(tr);
- }
- return table;
- } else {
- String string = gson.toJson(obj);
- Text textNode = document.createTextNode(string);
- if (string.contains(System.lineSeparator())) {
- Element pre = document.createElement("pre");
- pre.appendChild(textNode);
- return pre;
- } else if (string.startsWith("http://")) {
- Element a = document.createElement("a");
- a.appendChild(textNode);
- a.setAttribute("target", "_blank");
- a.setAttribute("href", string);
- return a;
- } else {
- return textNode;
- }
- }
- }
-}
diff --git a/test/collate/src/main/java/net/jimblackler/collate/DeviceFetcher.java b/test/collate/src/main/java/net/jimblackler/collate/DeviceFetcher.java
deleted file mode 100644
index 264b1a8..0000000
--- a/test/collate/src/main/java/net/jimblackler/collate/DeviceFetcher.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package net.jimblackler.collate;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import java.io.IOException;
-import java.util.List;
-import java.util.Map;
-import java.util.function.Consumer;
-
-/**
- * A service for fetching information about Firebase Test lab devices.
- */
-public class DeviceFetcher {
- /**
- * Fetch information about Firebase Test lab devices.
- *
- * @param consumer The consumer for the device information.
- * @throws IOException There was an error fetching the information.
- */
- static void fetch(Consumer<Map<String, Object>> consumer) throws IOException {
- String[] args = {Config.GCLOUD_EXECUTABLE.toString(), "beta", "firebase", "test", "android",
- "models", "list", "--format", "json"};
-
- String text = Utils.executeSilent(args);
- List<Object> devices = new ObjectMapper().readValue(text, List.class);
- for (Object device : devices) {
- consumer.accept((Map<String, Object>) device);
- }
- }
-}
diff --git a/test/collate/src/main/java/net/jimblackler/collate/DeviceTable.java b/test/collate/src/main/java/net/jimblackler/collate/DeviceTable.java
deleted file mode 100644
index b94684c..0000000
--- a/test/collate/src/main/java/net/jimblackler/collate/DeviceTable.java
+++ /dev/null
@@ -1,98 +0,0 @@
-package net.jimblackler.collate;
-
-import static net.jimblackler.collate.CsvEscaper.escape;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.util.List;
-
-/**
- * Builds a table of data about devices from lab test results.
- */
-public class DeviceTable {
- public static void main(String[] args) throws IOException {
- try (PrintWriter writer = new PrintWriter(Files.newBufferedWriter(Paths.get("devices.csv")))) {
- writer.print("Id");
- writer.print(",");
- writer.print("Versions");
- writer.print(",");
- writer.print("Manufacturer");
- writer.print(",");
- writer.print("Brand");
- writer.print(",");
- writer.print("Codename");
- writer.print(",");
- writer.print("Name");
- writer.print(",");
- writer.print("Form");
- writer.print(",");
- writer.print("FormFactor");
- writer.print(",");
- writer.print("ScreenDensity");
- writer.print(",");
- writer.print("ScreenX");
- writer.print(",");
- writer.print("ScreenY");
- writer.print(",");
- writer.print("SupportedAbis");
- writer.print(",");
- writer.print("Thumbnail");
- writer.println();
-
- DeviceFetcher.fetch(device -> {
- writer.print(device.get("id"));
- writer.print(",");
- writer.print(escape(versionIdsToString((List<Object>) device.get("supportedVersionIds"))));
- writer.print(",");
- writer.print(device.get("manufacturer"));
- writer.print(",");
- writer.print(device.get("brand"));
- writer.print(",");
- writer.print(device.get("codename"));
- writer.print(",");
- writer.print(escape((String) device.get("name")));
- writer.print(",");
- writer.print(device.get("form"));
- writer.print(",");
- writer.print(device.get("formFactor"));
- writer.print(",");
- writer.print(device.get("screenDensity"));
- writer.print(",");
- writer.print(device.get("screenX"));
- writer.print(",");
- writer.print(device.get("screenY"));
- writer.print(",");
- writer.print(escape(supportedAbisToString((List<Object>) device.get("supportedAbis"))));
- writer.print(",");
- writer.print(
- device.containsKey("thumbnailUrl") ? escape((String) device.get("thumbnailUrl")) : "");
- writer.println();
- });
- }
- }
-
- private static String supportedAbisToString(List<Object> supportedAbis) {
- StringBuilder sb = new StringBuilder();
- for (int idx = 0; idx != supportedAbis.size(); idx++) {
- if (idx != 0) {
- sb.append(",");
- }
- String items = (String) supportedAbis.get(idx);
- sb.append(items);
- }
- return sb.toString();
- }
-
- private static String versionIdsToString(List<Object> supportedVersionIds) {
- StringBuilder sb = new StringBuilder();
- for (int idx = 0; idx != supportedVersionIds.size(); idx++) {
- if (idx != 0) {
- sb.append(",");
- }
- sb.append(supportedVersionIds.get(idx));
- }
- return sb.toString();
- }
-}
diff --git a/test/collate/src/main/java/net/jimblackler/collate/Discover.java b/test/collate/src/main/java/net/jimblackler/collate/Discover.java
deleted file mode 100644
index 66cd74e..0000000
--- a/test/collate/src/main/java/net/jimblackler/collate/Discover.java
+++ /dev/null
@@ -1,165 +0,0 @@
-package net.jimblackler.collate;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.ObjectWriter;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-/**
- * A tool to analyze the recent run of iStresser in order to extract the record values of certain
- * memory metrics for all devices in the run.
- */
-public class Discover {
- public static void main(String[] args) throws IOException {
- ObjectWriter objectWriter = new ObjectMapper().writerWithDefaultPrettyPrinter();
- Map<String, Object> recordResults = new LinkedHashMap<>();
-
- Collector.cloudCollect(null, result -> {
- if (result.isEmpty()) {
- return;
- }
- Map<String, Object> first = (Map<String, Object>) result.get(0);
-
- if (!first.containsKey("params")) {
- System.out.println("No usable result. Data returned was:");
- try {
- System.out.println(objectWriter.writeValueAsString(result));
- } catch (JsonProcessingException e) {
- throw new IllegalStateException(e);
- }
- return;
- }
- Map<String, Object> deviceInfo = ReportUtils.getDeviceInfo(result);
- Map<String, Object> flattened =
- Utils.flattenParams((Map<String, Object>) first.get("params"));
- Map<String, Object> advisorParameters =
- (Map<String, Object>) flattened.get("advisorParameters");
- if (advisorParameters != null) {
- Map<String, Object> heuristics = (Map<String, Object>) advisorParameters.get("heuristics");
- if (heuristics != null && !heuristics.isEmpty()) {
- // Runs with heuristics are not useful.
- return;
- }
- }
- if (!flattened.containsKey("malloc") && !flattened.containsKey("glTest")) {
- // Only interested in these kinds of stress tests.
- return;
- }
- Map<String, Object> baseline = null;
- Map<String, Object> limit = null;
- Map<String, Object> firstFailed = null;
- for (Object o : result) {
- Map<String, Object> row = (Map<String, Object>) o;
- if (Boolean.TRUE.equals(row.get("activityPaused"))) {
- // The run was interrupted and is unusable.
- limit = null;
- break;
- }
- Map<String, Object> metrics = ReportUtils.rowMetrics(row);
- if (metrics == null) {
- continue;
- }
- long time = ReportUtils.rowTime(row);
- if (Boolean.TRUE.equals(row.get("allocFailed"))
- || Boolean.TRUE.equals(row.get("mmapAnonFailed"))
- || Boolean.TRUE.equals(row.get("mmapFileFailed"))
- || row.containsKey("criticalLogLines")) {
- if (firstFailed == null || time < ReportUtils.rowTime(firstFailed)) {
- firstFailed = row;
- }
- }
- if (firstFailed != null && time >= ReportUtils.rowTime(firstFailed)) {
- continue;
- }
- if (metrics.containsKey("constant")) {
- if (baseline == null || time < ReportUtils.rowTime(baseline)) {
- // Baseline is the earliest reading with 'constant'.
- baseline = row;
- }
- }
- if (limit == null || time > ReportUtils.rowTime(limit)) {
- // Limit is the latest reading.
- limit = row;
- }
- }
- if (limit != null) {
- String fingerprint =
- (String) ((Map<String, Object>) ((Map<String, Object>) deviceInfo.get("build"))
- .get("fields"))
- .get("FINGERPRINT");
- Map<String, Object> baselineCurrent = (Map<String, Object>) deviceInfo.get("baseline");
- Map<String, Object> limitCurrent = ReportUtils.rowMetrics(limit);
-
- Map<String, Object> testMetrics = (Map<String, Object>) limit.get("testMetrics");
- long total = 0;
- for (Object o : testMetrics.values()) {
- total += ((Number) o).longValue();
- }
- Map<String, Object> stressedGroup = new LinkedHashMap<>();
- stressedGroup.put("applicationAllocated", total);
- limitCurrent.put("stressed", stressedGroup);
-
- Map<String, Object> recordResult = (Map<String, Object>) recordResults.get(fingerprint);
- if (recordResult != null) {
- // Multiple results are combined.
- // We take the metric result with the smallest ('worst') delta in every case.
- Map<String, Object> limitPrevious = (Map<String, Object>) recordResult.get("limit");
- Map<String, Object> baselinePrevious = (Map<String, Object>) recordResult.get("baseline");
- for (Map.Entry<String, Object> e : limitPrevious.entrySet()) {
- String groupName = e.getKey();
- Object value = e.getValue();
- if (!(value instanceof Map)) {
- continue;
- }
- Map<String, Object> limitPreviousGroup = (Map<String, Object>) value;
- Map<String, Object> limitCurrentGroup =
- (Map<String, Object>) limitCurrent.get(groupName);
- Map<String, Object> baselineCurrentGroup =
- (Map<String, Object>) baselineCurrent.get(groupName);
- if (baselineCurrentGroup == null) {
- continue;
- }
- Map<String, Object> baselinePreviousGroup =
- (Map<String, Object>) baselinePrevious.get(groupName);
- for (Map.Entry<String, Object> entry : limitPreviousGroup.entrySet()) {
- String key = entry.getKey();
- if (!(entry.getValue() instanceof Number)) {
- continue;
- }
- if (!baselinePreviousGroup.containsKey(key)) {
- if (((Number) limitCurrentGroup.get(key)).longValue()
- < ((Number) limitPreviousGroup.get(key)).longValue()) {
- limitPreviousGroup.put(key, limitCurrentGroup.get(key));
- }
- continue;
- }
- if (!(baselinePreviousGroup.get(key) instanceof Number)) {
- continue;
- }
- long previous = ((Number) limitPreviousGroup.get(key)).longValue()
- - ((Number) baselinePreviousGroup.get(key)).longValue();
- long baselineCurrentValue = ((Number) baselineCurrentGroup.get(key)).longValue();
- long limitCurrentValue = ((Number) limitCurrentGroup.get(key)).longValue();
- long current = limitCurrentValue - baselineCurrentValue;
- if (Math.abs(current) < Math.abs(previous)) {
- baselinePreviousGroup.put(key, baselineCurrentValue);
- limitPreviousGroup.put(key, limitCurrentValue);
- }
- }
- }
- } else {
- recordResult = new LinkedHashMap<>();
- recordResult.put("baseline", baselineCurrent);
- recordResult.put("limit", limitCurrent);
- recordResults.put(fingerprint, recordResult);
- }
- }
- });
-
- Files.write(Paths.get("lookup.json"), objectWriter.writeValueAsBytes(recordResults));
- }
-}
diff --git a/test/collate/src/main/java/net/jimblackler/collate/ExecutionError.java b/test/collate/src/main/java/net/jimblackler/collate/ExecutionError.java
deleted file mode 100644
index b3524f3..0000000
--- a/test/collate/src/main/java/net/jimblackler/collate/ExecutionError.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package net.jimblackler.collate;
-
-import java.io.IOException;
-
-public class ExecutionError extends IOException {
- public ExecutionError() {}
-
- public ExecutionError(String message) {
- super(message);
- }
-
- public ExecutionError(String message, Throwable cause) {
- super(message, cause);
- }
-
- public ExecutionError(Throwable cause) {
- super(cause);
- }
-}
diff --git a/test/collate/src/main/java/net/jimblackler/collate/FileUtils.java b/test/collate/src/main/java/net/jimblackler/collate/FileUtils.java
deleted file mode 100644
index 88f0ad1..0000000
--- a/test/collate/src/main/java/net/jimblackler/collate/FileUtils.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package net.jimblackler.collate;
-
-import com.google.android.apps.internal.games.memoryadvice_common.StreamUtils;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.UnsupportedEncodingException;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Path;
-
-class FileUtils {
- /**
- * Loads all text from the specified file and returns the result as a string.
- *
- * @param filename The name of the file to read.
- * @return All of the text from the file.
- * @throws IOException Thrown if a read error occurs.
- */
- static String readFile(String filename) throws IOException {
- try (FileInputStream inputStream = new FileInputStream(filename)) {
- return StreamUtils.readStream(inputStream);
- }
- }
-
- /**
- * Loads all text from the specified file and returns the result as a string.
- *
- * @param path The path of the file to read.
- * @return All of the text from the file.
- * @throws IOException Thrown if a read error occurs.
- */
- static String readFile(Path path) throws IOException {
- return readFile(path.toString());
- }
-
- /**
- * Write the supplied string to the path provided.
- * @param path The path of a file to create or overwrite.
- * @param text The text to write.
- */
- static void writeString(Path path, String text) {
- try (PrintWriter out = new PrintWriter(path.toFile(), StandardCharsets.UTF_8.name())) {
- out.println(text);
- } catch (FileNotFoundException | UnsupportedEncodingException e) {
- throw new RuntimeException(e);
- }
- }
-}
diff --git a/test/collate/src/main/java/net/jimblackler/collate/HtmlUtils.java b/test/collate/src/main/java/net/jimblackler/collate/HtmlUtils.java
deleted file mode 100644
index ae0a629..0000000
--- a/test/collate/src/main/java/net/jimblackler/collate/HtmlUtils.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package net.jimblackler.collate;
-
-import java.io.IOException;
-import java.io.StringWriter;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-
-public class HtmlUtils {
- public static Document getDocument() {
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- DocumentBuilder builder;
- try {
- builder = factory.newDocumentBuilder();
- } catch (ParserConfigurationException e) {
- throw new IllegalStateException(e);
- }
- return builder.newDocument();
- }
-
- public static String toString(Node node) {
- try {
- Transformer transformer = TransformerFactory.newInstance().newTransformer();
- transformer.setOutputProperty(OutputKeys.METHOD, "html");
- try (StringWriter stringWriter = new StringWriter()) {
- transformer.transform(new DOMSource(node), new StreamResult(stringWriter));
- return stringWriter.toString();
- }
- } catch (IOException | TransformerException e) {
- throw new IllegalStateException(e);
- }
- }
-}
diff --git a/test/collate/src/main/java/net/jimblackler/collate/JsonUtils.java b/test/collate/src/main/java/net/jimblackler/collate/JsonUtils.java
deleted file mode 100644
index 9ba9191..0000000
--- a/test/collate/src/main/java/net/jimblackler/collate/JsonUtils.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package net.jimblackler.collate;
-
-import com.google.android.apps.internal.games.memoryadvice_common.Schemas;
-import com.google.android.apps.internal.games.memoryadvice_common.StreamUtils;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.UncheckedIOException;
-import java.net.URL;
-import org.everit.json.schema.Schema;
-import org.everit.json.schema.loader.SchemaLoader;
-import org.json.JSONObject;
-
-public class JsonUtils {
- /**
- * Convert a schema from text form in the Memory Advice common library into a org.everit schema
- * for validation.
- *
- * @param name The name of the Schema to fectch.
- * @return The built org.everit Schema object.
- */
- static Schema getSchema(String name) {
- try {
- URL schema = Schemas.getSchema(name);
- return SchemaLoader.load(new JSONObject(StreamUtils.readStream(schema.openStream())), url -> {
- try {
- if (url.startsWith("http://") || url.startsWith("https://")) {
- // Web resources are streamed.
- return new URL(url).openStream();
- }
- // Raw URLs are obtained from the Memory Advice common library.
- return Schemas.getSchema(url).openStream();
- } catch (IOException e1) {
- System.out.println("Couldn't load " + url); // Warn about the loading error.
- // Don't abort building the whole tree because of this one missing part. Transplant a
- // permissive schema.
- return new ByteArrayInputStream("{}".getBytes());
- }
- });
- } catch (IOException ex) {
- throw new UncheckedIOException(ex);
- }
- }
-}
diff --git a/test/collate/src/main/java/net/jimblackler/collate/Launcher.java b/test/collate/src/main/java/net/jimblackler/collate/Launcher.java
deleted file mode 100644
index 39b5c5e..0000000
--- a/test/collate/src/main/java/net/jimblackler/collate/Launcher.java
+++ /dev/null
@@ -1,276 +0,0 @@
-package net.jimblackler.collate;
-
-import static java.lang.System.currentTimeMillis;
-import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
-
-import com.fasterxml.jackson.core.json.JsonReadFeature;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.ObjectReader;
-import com.fasterxml.jackson.databind.ObjectWriter;
-import com.google.common.collect.ImmutableSet;
-import java.io.BufferedWriter;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.nio.file.FileSystems;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.time.OffsetDateTime;
-import java.time.format.DateTimeFormatter;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Date;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicReference;
-
-public class Launcher {
- private static final boolean USE_DEVICE = false;
- private static final int MIN_VERSION = 26;
- private static final boolean USE_WHITELIST = false;
- private static final int MAX_DEVICES = Integer.MAX_VALUE;
- private static final String STANDARD_APK_PATH = "app/build/outputs/apk/debug/app-debug.apk";
- private static final long EXTRA_TIMEOUT = 1000 * 10; // Allow extra time to start test on device.
- private static final ImmutableSet<String> whitelist = ImmutableSet.of("602SO", "A0001",
- "A1N_sprout", "ASUS_X00T_3", "ASUS_Z01H_1", "FRT", "G8142", "H8416", "HWCOR", "HWMHA",
- "HWMHA", "OnePlus5T", "OnePlus6T", "SC-02K", "a9y18qltechn", "addison", "albus", "aljeter_n",
- "athene_f", "aura", "blueline", "capricorn", "cheryl", "crownqlteue", "cruiserltesq",
- "deen_sprout", "flame", "g3", "hammerhead", "harpia", "hero2qlteatt", "hero2qltevzw",
- "heroqltetfnvzw", "hlte", "htc_m8", "hwALE-H", "j1acevelteub", "james", "jeter", "lithium",
- "lucye", "lv0", "m0", "mlv1", "poseidonlteatt", "potter", "shamu", "victara");
-
- public static void main(String[] args) throws IOException {
- if (USE_DEVICE) {
- deviceLaunch();
- } else {
- cloudLaunch();
- }
- Score.go(USE_DEVICE, false);
- }
-
- private static void deviceLaunch() throws IOException {
- AtomicReference<String> pack = new AtomicReference<>(); // 'package' is a Java keyword.
- AtomicReference<Path> installed = new AtomicReference<>();
- doLaunch((id, apkPath, paramsIn) -> {
- Map<String, Object> flattened = Utils.flattenParams(paramsIn);
- pack.set((String) flattened.get("package"));
-
- // To avoid Android re-serving us an existing run, dismiss any app previous run activity
- // and then kill the app.
- Utils.execute("adb", "shell", "am", "start", "-a android.intent.action.MAIN",
- "-c android.intent.category.HOME");
- Utils.execute("adb", "shell", "am", "force-stop", pack.get());
-
- if (!apkPath.equals(installed.getAndSet(apkPath))) {
- // Uninstall any previous versions of the app the first time.
- try {
- Utils.execute("adb", "uninstall", pack.get());
- } catch (IOException e) {
- // Ignored by design. App might not be installed.
- }
- Utils.execute("adb", "install", apkPath.toString());
- }
-
- long timeout = Utils.getDuration(Utils.getOrDefault(flattened, "timeout", "10m"));
- Utils.execute("adb", "shell", "am", "start", "-S", "-W", "-n",
- pack + "/" + pack + ".MainActivity", "--es", "\"Params\"",
- jsonToShellParameter(paramsIn));
-
- // Wait for process to end or for the run to time out.
- int[] pids = new int[0];
- long started = currentTimeMillis();
- while (true) {
- if (currentTimeMillis() > started + timeout + EXTRA_TIMEOUT) {
- break;
- }
- int[] newPids = getPids(pack.get());
- if (!Arrays.equals(newPids, pids)) {
- if (pids.length == 0) {
- pids = newPids;
- started = currentTimeMillis(); // Restart timeout timer.
- } else {
- break; // pid has changed - something went wrong.
- }
- }
- }
- });
- }
-
- /**
- * Get the PID of a running Android app.
- *
- * @param pack The package name of the app.
- * @return The PID.
- */
- private static int[] getPids(String pack) throws IOException {
- try {
- String output = Utils.executeSilent("adb", "shell", "pidof", pack);
- String[] outputs = output.split(" ");
- int[] toReturn = new int[outputs.length];
- for (int idx = 0; idx != outputs.length; idx++) {
- toReturn[idx] = Integer.parseInt(outputs[idx]);
- }
- return toReturn;
- } catch (ExecutionError e) {
- return new int[0];
- }
- }
-
- /**
- * Encode a JSON string for shell command line use.
- *
- * @param json JSON string to encode.
- * @return The encoded string.
- */
- private static String jsonToShellParameter(Map<String, Object> json) {
- return "\"" + json.toString().replace("\"", "\\\"") + "\"";
- }
-
- private static void cloudLaunch() throws IOException {
- ObjectWriter objectWriter = new ObjectMapper().writerWithDefaultPrettyPrinter();
- Path grabberPath = Config.GRABBER_BASE.resolve(STANDARD_APK_PATH);
-
- List<String> baseCommands = new ArrayList<>(Arrays.asList(Config.GCLOUD_EXECUTABLE.toString(),
- "beta", "firebase", "test", "android", "run", "--type", "game-loop", "--async",
- "--scenario-numbers", "1", "--format", "json"));
- Collection<String> devices = new ArrayList<>();
-
- DeviceFetcher.fetch(device -> {
- if (!USE_WHITELIST && devices.size() >= MAX_DEVICES) {
- return;
- }
- if (!device.get("formFactor").equals("PHONE")) {
- return;
- }
- if (!device.get("form").equals("PHYSICAL")) {
- return;
- }
- List<Object> supportedVersionIds = (List<Object>) device.get("supportedVersionIds");
- for (int idx2 = 0; idx2 != supportedVersionIds.size(); idx2++) {
- int versionId = Integer.parseInt(supportedVersionIds.get(idx2).toString());
- if (versionId < MIN_VERSION) {
- continue;
- }
- String id = (String) device.get("id");
- if (USE_WHITELIST && !whitelist.contains(id)) {
- continue;
- }
- devices.add(String.format("--device=model=%s,version=%d", id, versionId));
- }
- });
-
- Path[] grabberCopy = {null};
-
- doLaunch((id, apkPath, paramsIn) -> {
- Path tempFile = Files.createTempFile("params", ".json");
- try (BufferedWriter writer = new BufferedWriter(new FileWriter(tempFile.toFile()))) {
- writer.write(objectWriter.writeValueAsString(paramsIn));
- }
-
- List<String> commands = new ArrayList<>(baseCommands);
- commands.add("--other-files");
- commands.add("/sdcard/params.json=" + tempFile);
- commands.add("--results-history-name=" + id);
- commands.add("--app=" + apkPath);
-
- Map<String, Object> flattened = Utils.flattenParams(paramsIn);
-
- Map<String, Object> firebase = (Map<String, Object>) flattened.get("firebase");
- if (firebase != null) {
- for (Map.Entry<String, Object> entry : firebase.entrySet()) {
- String key = entry.getKey();
- Object value = entry.getValue();
- if (value.equals(Boolean.TRUE)) {
- commands.add("--" + key);
- } else {
- commands.add("--" + key + "=" + value);
- }
- }
- }
-
- Object orientation = flattened.get("orientation");
- if (orientation != null) {
- for (String device : devices) {
- commands.add(device + ",orientation=" + orientation);
- }
- } else {
- commands.addAll(devices);
- }
-
- if (flattened.containsKey("serviceBlocker")) {
- if (grabberCopy[0] == null) {
- grabberCopy[0] = Files.createTempFile("grabber", ".apk");
- Files.copy(grabberPath, grabberCopy[0], REPLACE_EXISTING);
- }
- commands.add("--additional-apks");
- commands.add(grabberCopy[0].toString());
- }
-
- String text = Utils.execute(commands.toArray(new String[0]));
- System.out.println(text);
- });
- }
-
- private static void doLaunch(LaunchClient client) throws IOException {
- ObjectMapper objectMapper = new ObjectMapper();
- OffsetDateTime now = OffsetDateTime.now();
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd_HH:mm:ss");
- String id = formatter.format(now);
- Date date = new Date();
-
- ObjectReader objectReader = objectMapper.readerFor(Map.class)
- .with(JsonReadFeature.ALLOW_JAVA_COMMENTS)
- .with(JsonReadFeature.ALLOW_SINGLE_QUOTES)
- .with(JsonReadFeature.ALLOW_TRAILING_COMMA)
- .with(JsonReadFeature.ALLOW_UNQUOTED_FIELD_NAMES);
-
- List<Object> tests = objectReader.readValue(Utils.fileToString("tests.json5"), List.class);
- int numberDimensions = tests.size();
- List<Integer> coordinates = new ArrayList<>();
- for (int dimension = 0; dimension < numberDimensions; dimension++) {
- coordinates.add(0);
- }
- while (true) {
- Map<String, Object> paramsIn = new LinkedHashMap<>();
- paramsIn.put("tests", tests);
- paramsIn.put("run", id);
- paramsIn.put("started", date.getTime());
- paramsIn.put("coordinates", coordinates);
-
- Map<String, Object> flattened = Utils.flattenParams(paramsIn);
-
- Path apkPath = FileSystems.getDefault().getPath(
- (String) flattened.get("apk_base"), (String) flattened.get("apk_name"));
- if (!apkPath.toFile().exists()) {
- throw new IllegalStateException(apkPath + " missing");
- }
- System.out.println(coordinates);
-
- client.launch(id, apkPath, paramsIn);
-
- int coordinateNumber = numberDimensions - 1;
- while (true) {
- int e = coordinates.get(coordinateNumber) + 1;
- if (e >= ((Collection<Object>) tests.get(coordinateNumber)).size()) {
- coordinates.set(coordinateNumber, 0);
- coordinateNumber--;
- if (coordinateNumber < 0) {
- break;
- }
- } else {
- coordinates.set(coordinateNumber, e);
- break;
- }
- }
-
- if (coordinateNumber < 0) {
- break;
- }
- }
- }
-
- private interface LaunchClient {
- void launch(String id, Path apkPath, Map<String, Object> flattened) throws IOException;
- }
-}
diff --git a/test/collate/src/main/java/net/jimblackler/collate/LocalInfo.java b/test/collate/src/main/java/net/jimblackler/collate/LocalInfo.java
deleted file mode 100644
index 9e742d4..0000000
--- a/test/collate/src/main/java/net/jimblackler/collate/LocalInfo.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package net.jimblackler.collate;
-
-import java.io.IOException;
-import java.nio.file.FileSystems;
-import java.util.Timer;
-import java.util.TimerTask;
-
-/**
- * Tool to create tables from stats received from a live run on a local device.
- */
-public class LocalInfo {
- public static void main(String[] args) throws ExecutionError {
- int pid = Integer.parseInt(Utils.execute("adb", "shell", "pidof", "net.jimblackler.istresser"));
- int[] c = {0};
- new Timer().scheduleAtFixedRate(new TimerTask() {
- @Override
- public void run() {
- try {
- {
- String data = Utils.execute("adb", "shell", "cat", "/d/kgsl/globals");
- FileUtils.writeString(FileSystems.getDefault().getPath(
- "out", String.format("kgsl_globals_%02d.txt", c[0])),
- data);
- }
-
- {
- String data = Utils.execute("adb", "shell", "cat", "/d/kgsl/proc/" + pid + "/mem");
- FileUtils.writeString(
- FileSystems.getDefault().getPath("out", String.format("kgsl_mem_%02d.txt", c[0])),
- data);
- }
-
- c[0]++;
-
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
- }, 1000, 1000);
- }
-}
diff --git a/test/collate/src/main/java/net/jimblackler/collate/Main.java b/test/collate/src/main/java/net/jimblackler/collate/Main.java
deleted file mode 100644
index 16ab2f7..0000000
--- a/test/collate/src/main/java/net/jimblackler/collate/Main.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package net.jimblackler.collate;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.ObjectWriter;
-import java.awt.Desktop;
-import java.io.IOException;
-import java.net.URI;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.List;
-import java.util.Map;
-
-class Main {
- public static void main(String[] args) throws IOException {
- Path directory = Files.createTempDirectory("report-");
-
- Collector.deviceCollect("net.jimblackler.istresser", result -> {
- try {
- Desktop.getDesktop().browse(writeGraphs(directory, result));
- } catch (IOException e) {
- throw new IllegalStateException(e);
- }
- });
- }
-
- static URI writeGraphs(Path directory, List<Map<String, Object>> result) {
- ObjectWriter objectWriter = new ObjectMapper().writerWithDefaultPrettyPrinter();
- try {
- Path outputFile;
- Map<String, Object> params = (Map<String, Object>) result.get(0).get("params");
- Map<String, Object> deviceInfo = ReportUtils.getDeviceInfo(result);
- Map<String, Object> build = (Map<String, Object>) deviceInfo.get("build");
- Map<String, Object> fields = (Map<String, Object>) build.get("fields");
- int count = 0;
- while (true) {
- String coordinates = params.get("coordinates").toString();
- String name = fields.get("DEVICE") + (count > 0 ? "_" + count : "")
- + coordinates.replace("[", "_").replace(",", "-").replace("]", "").replace(" ", "")
- + ".html";
- outputFile = directory.resolve(name);
- if (!Files.exists(outputFile)) {
- break;
- }
- count++;
- }
- String content = Utils.fileToString("main.html");
- // noinspection HardcodedFileSeparator
- content = content.replace("[/*data*/]", objectWriter.writeValueAsString(result));
- FileUtils.writeString(outputFile, content);
- return outputFile.toUri();
- } catch (IOException ex) {
- throw new RuntimeException(ex);
- }
- }
-}
diff --git a/test/collate/src/main/java/net/jimblackler/collate/OnTrimReport.java b/test/collate/src/main/java/net/jimblackler/collate/OnTrimReport.java
deleted file mode 100644
index e25f617..0000000
--- a/test/collate/src/main/java/net/jimblackler/collate/OnTrimReport.java
+++ /dev/null
@@ -1,119 +0,0 @@
-package net.jimblackler.collate;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeSet;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.stream.Collectors;
-
-/**
- * A tool to analyze the recent run of iStresser in order to extract the record values of certain
- * memory metrics for all devices in the run.
- */
-public class OnTrimReport {
- public static void main(String[] args) throws IOException {
- Gson gson = new GsonBuilder().setPrettyPrinting().create();
- Collection<Integer> trimLevels = new TreeSet<>();
- trimLevels.add(80);
- trimLevels.add(60);
- trimLevels.add(40);
- trimLevels.add(20);
- trimLevels.add(15);
- trimLevels.add(10);
- trimLevels.add(5);
-
- Map<Integer, List<Float>> fireTimes = new HashMap<>();
- trimLevels.forEach(trimLevel -> fireTimes.put(trimLevel, new ArrayList<>()));
- AtomicInteger totalResults = new AtomicInteger();
- Collector.cloudCollect(null, results -> {
- if (results.isEmpty()) {
- return;
- }
- Map<String, Object> first = (Map<String, Object>) results.get(0);
-
- if (!first.containsKey("params")) {
- System.out.println("No usable results. Data returned was:");
- System.out.println(gson.toJson(results));
- return;
- }
-
- Map<String, Object> flattened =
- Utils.flattenParams((Map<String, Object>) first.get("params"));
- Map<String, Object> advisorParameters =
- (Map<String, Object>) flattened.get("advisorParameters");
- if (advisorParameters != null) {
- Map<String, Object> heuristics = (Map<String, Object>) advisorParameters.get("heuristics");
- if (heuristics != null && !heuristics.isEmpty()) {
- // Runs with heuristics are not useful.
- return;
- }
- }
- if (!flattened.containsKey("malloc") && !flattened.containsKey("glTest")
- && !flattened.containsKey("vkTest")) {
- // Only interested in these kinds of stress tests.
- return;
- }
-
- Map<Integer, Map<String, Object>> firstFired = new HashMap<>();
- Map<String, Object> finalRow = null;
- for (Object o : results) {
- Map<String, Object> row = (Map<String, Object>) o;
- if (Boolean.TRUE.equals(row.get("activityPaused"))) {
- // The run was interrupted and is unusable.
- finalRow = null;
- break;
- }
-
- Map<String, Object> metrics = ReportUtils.rowMetrics(row);
- if (metrics == null) {
- continue;
- }
-
- if (Boolean.TRUE.equals(row.get("allocFailed"))
- || Boolean.TRUE.equals(row.get("mmapAnonFailed"))
- || Boolean.TRUE.equals(row.get("mmapFileFailed"))
- || row.containsKey("criticalLogLines")) {
- break;
- }
- finalRow = row;
- Number onTrim1 = (Number) metrics.get("onTrim");
- if (onTrim1 != null) {
- int onTrim = onTrim1.intValue();
- if (!trimLevels.contains(onTrim)) {
- throw new RuntimeException("Missing " + onTrim);
- }
- if (!firstFired.containsKey(onTrim)) {
- firstFired.put(onTrim, row);
- }
- }
- }
- if (finalRow != null) {
- totalResults.getAndIncrement();
- long firstTime = ReportUtils.rowTime(first);
- long finalTime = ReportUtils.rowTime(finalRow);
- trimLevels.forEach(trimLevel -> {
- if (firstFired.containsKey(trimLevel)) {
- long fireTime = ReportUtils.rowTime(firstFired.get(trimLevel));
- float relative = (float) (fireTime - firstTime) / (finalTime - firstTime);
- fireTimes.get(trimLevel).add(relative);
- }
- });
- }
- });
-
- System.out.println("Trim Level, Total, Fired, Times");
- trimLevels.forEach(trimLevel -> {
- System.out.print(trimLevel + ",");
- System.out.print(totalResults + ",");
- List<Float> times = fireTimes.get(trimLevel);
- System.out.print(times.size() + ",");
- System.out.println(times.stream().map(Object::toString).collect(Collectors.joining(",")));
- });
- }
-}
diff --git a/test/collate/src/main/java/net/jimblackler/collate/ReportUtils.java b/test/collate/src/main/java/net/jimblackler/collate/ReportUtils.java
deleted file mode 100644
index 62d8ee1..0000000
--- a/test/collate/src/main/java/net/jimblackler/collate/ReportUtils.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package net.jimblackler.collate;
-
-import java.util.Map;
-
-public class ReportUtils {
- static Map<String, Object> rowMetrics(Map<String, Object> row) {
- Map<String, Object> advice = (Map<String, Object>) row.get("advice");
- if (advice != null) {
- return (Map<String, Object>) advice.get("metrics");
- }
- Map<String, Object> deviceInfo = (Map<String, Object>) row.get("deviceInfo");
- if (deviceInfo != null) {
- return (Map<String, Object>) deviceInfo.get("baseline");
- }
- return (Map<String, Object>) row.get("metrics");
- }
-
- static long rowTime(Map<String, Object> row) {
- Map<String, Object> metrics = rowMetrics(row);
- if (metrics == null) {
- return 0;
- }
- return ((Number) ((Map<String, Object>) metrics.get("meta")).get("time")).longValue();
- }
-
- static Map<String, Object> getDeviceInfo(Iterable<Map<String, Object>> result) {
- for (Map<String, Object> line : result) {
- if (line == null) {
- continue;
- }
- Map<String, Object> deviceInfo = (Map<String, Object>) line.get("deviceInfo");
- if (deviceInfo != null) {
- return deviceInfo;
- }
- }
- return null;
- }
-}
diff --git a/test/collate/src/main/java/net/jimblackler/collate/Score.java b/test/collate/src/main/java/net/jimblackler/collate/Score.java
deleted file mode 100644
index 1082032..0000000
--- a/test/collate/src/main/java/net/jimblackler/collate/Score.java
+++ /dev/null
@@ -1,553 +0,0 @@
-package net.jimblackler.collate;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.ObjectWriter;
-import java.io.File;
-import java.io.IOException;
-import java.net.URI;
-import java.nio.file.FileSystems;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.concurrent.atomic.AtomicReference;
-import java.util.function.Consumer;
-import java.util.stream.Stream;
-import org.w3c.dom.Node;
-
-public class Score {
- private static final boolean USE_DEVICE = false;
- private static final boolean USE_DATASTORE = true;
- private static final String VERSION = "1.7r";
-
- public static void main(String[] args) throws IOException {
- go(USE_DEVICE, USE_DATASTORE);
- }
-
- static void go(boolean useDevice, boolean useDatastore) throws IOException {
- ObjectMapper objectMapper = new ObjectMapper();
- ObjectWriter objectWriter = objectMapper.writerWithDefaultPrettyPrinter();
- Map<String, Map<String, Result>> out = new HashMap<>();
- Map<String, Map<String, Object>> deviceInfos = new HashMap<>();
- AtomicReference<Path> directory = new AtomicReference<>();
- AtomicReference<List<List<Map<String, Object>>>> tests = new AtomicReference<>();
- AtomicReference<Timer> timer = new AtomicReference<>();
-
- if (useDatastore) {
- Collector.collectDataStoreResult(
- (results1, result)
- -> handleResult(result, out, deviceInfos, directory, tests, objectWriter,
- Boolean.TRUE.equals(results1.get("automatic"))),
- VERSION);
- } else {
- Consumer<List<Map<String, Object>>> collect = result -> {
- if (timer.get() != null) {
- timer.get().cancel();
- }
- timer.set(new Timer());
- TimerTask task = new TimerTask() {
- @Override
- public void run() {
- List<List<Map<String, Object>>> _tests = tests.get();
- if (_tests == null || _tests.isEmpty()) {
- return;
- }
- try {
- URI uri = writeReport(out, deviceInfos, directory.get(), _tests);
- System.out.println(uri);
- } catch (IOException e) {
- throw new IllegalStateException(e);
- }
- }
- };
- timer.get().schedule(task, 1000 * 10);
-
- handleResult(result, out, deviceInfos, directory, tests, objectWriter, true);
- };
-
- if (useDevice) {
- Collector.deviceCollect("net.jimblackler.istresser", collect);
- } else {
- Collector.cloudCollect(null, collect);
- }
- }
-
- if (timer.get() != null) {
- timer.get().cancel();
- }
- URI uri = writeReport(out, deviceInfos, directory.get(), tests.get());
- System.out.println(uri);
- }
-
- private static void handleResult(List<Map<String, Object>> result,
- Map<String, Map<String, Result>> out, Map<String, Map<String, Object>> deviceInfos,
- AtomicReference<Path> directory, AtomicReference<List<List<Map<String, Object>>>> tests,
- ObjectWriter objectWriter, boolean automatic) {
- Map<String, Object> deviceInfo = ReportUtils.getDeviceInfo(result);
- if (deviceInfo == null) {
- System.out.println("Could not find deviceInfo.");
- return;
- }
- deviceInfo.put("automatic", automatic);
- Map<String, Object> first = result.get(0);
- Map<String, Object> params = (Map<String, Object>) first.get("params");
- if (params == null) {
- System.out.println("No usable results. Data returned was:");
- try {
- System.out.println(objectWriter.writeValueAsString(first));
- } catch (JsonProcessingException e) {
- throw new IllegalStateException(e);
- }
- return;
- }
- List<Number> coordinates = (List<Number>) params.get("coordinates");
- tests.set((List<List<Map<String, Object>>>) params.get("tests"));
-
- assert deviceInfo.containsKey("build");
- Map<String, Object> build = (Map<String, Object>) deviceInfo.get("build");
- String key = coordinates.toString();
- String id = build.toString();
-
- Map<String, Object> extra = (Map<String, Object>) first.get("extra");
- if (extra != null) {
- Map<String, Object> step = (Map<String, Object>) extra.get("step");
- if (step != null) {
- id = step.get("dimensionValue").toString();
- }
- }
-
- while (out.containsKey(id) && out.get(id).containsKey(key)) {
- id += "2";
- }
-
- if (directory.get() == null) {
- String dirName = extra == null ? (String) params.get("run") : (String) extra.get("historyId");
- directory.set(FileSystems.getDefault().getPath("reports").resolve(dirName));
- try {
- File outDir = directory.get().toFile();
- if (outDir.exists()) {
- // Empty the directory if it already exists.
- try (Stream<Path> files = Files.walk(directory.get())) {
- files.sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete);
- }
- }
- outDir.mkdirs();
- Utils.copyFolder(FileSystems.getDefault().getPath("resources", "static"),
- directory.get().resolve("static"));
- } catch (IOException e) {
- throw new IllegalStateException(e);
- }
- }
-
- deviceInfos.put(id, deviceInfo);
-
- long lowestTop = Long.MAX_VALUE;
- long largest = 0;
- boolean exited = false;
- boolean allocFailed = false;
- boolean failedToClear = false;
- boolean serviceCrashed = false;
-
- for (Object o : result) {
- Map<String, Object> row = (Map<String, Object>) o;
- exited |= Boolean.TRUE.equals(row.get("exiting"));
-
- allocFailed |= Boolean.TRUE.equals(row.get("allocFailed"));
- allocFailed |= Boolean.TRUE.equals(row.get("mmapAnonFailed"));
- allocFailed |= Boolean.TRUE.equals(row.get("mmapFileFailed"));
- allocFailed |= row.containsKey("criticalLogLines");
-
- failedToClear |= Boolean.TRUE.equals(row.get("failedToClear"));
-
- serviceCrashed |= Boolean.TRUE.equals(row.get("serviceCrashed"));
- long score = 0;
- Map<String, Object> testMetrics = (Map<String, Object>) row.get("testMetrics");
- if (testMetrics != null) {
- for (Object o2 : testMetrics.values()) {
- score += ((Number) o2).longValue();
- }
- }
-
- if (score > largest) {
- largest = score;
- }
-
- Map<String, Object> advice = (Map<String, Object>) row.get("advice");
- if (advice != null) {
- Iterable<Object> warnings = (Iterable<Object>) advice.get("warnings");
- if (warnings != null && !Boolean.TRUE.equals(row.get("paused"))) {
- for (Object o2 : warnings) {
- Map<String, Object> warning = (Map<String, Object>) o2;
- if (!"red".equals(warning.get("level"))) {
- continue;
- }
- long top = score;
- if (top < lowestTop) {
- lowestTop = top;
- }
- break;
- }
- }
- }
- }
-
- float score =
- (lowestTop == Long.MAX_VALUE ? (float) largest : (float) lowestTop) / (1024 * 1024);
- Map<String, Result> results0 = out.computeIfAbsent(id, k -> new HashMap<>());
- Map<String, Object> group = Utils.flattenParams(coordinates, tests.get());
- group.remove("advisorParameters");
- URI uri = Main.writeGraphs(directory.get(), result);
- System.out.println(uri);
- results0.put(key,
- new Result(
- score, uri, exited && !allocFailed, failedToClear, serviceCrashed, group.toString()));
- }
-
- private static URI writeReport(Map<String, Map<String, Result>> rows,
- Map<String, Map<String, Object>> deviceInfos, Path directory,
- List<List<Map<String, Object>>> tests) throws IOException {
- StringBuilder body = new StringBuilder();
- // The vertical orders are the variations of the graphs. The vertical order refers to how the
- // dimensions will be ordered in the header, which is arranged like a tree. The first group is
- // at the top of the tree. The final group will appear as multiple leaves at the base of the
- // tree.
- List<List<Integer>> verticalOrders = getPermutations(tests.size());
- for (List<Integer> verticalOrder : verticalOrders) {
- if (!worthRendering(verticalOrder, tests)) {
- continue;
- }
- writeTable(body, rows, deviceInfos, tests, directory, verticalOrder);
- body.append("</br>");
- }
-
- String content = Utils.fileToString("score.html");
- content = content.replace("<!--body-->", body);
-
- Path outputFile = directory.resolve("index.html");
- FileUtils.writeString(outputFile, content);
- return outputFile.toUri();
- }
-
- /**
- * Determines if a vertical group order will have an effective duplicate or not.
- * In short, there is no point repositioning the dimensions of length 1, since
- * that will only result in duplicates of the actual groupings.
- *
- * @param verticalOrder The vertical group order under consideration.
- * @param objects The array of dimension arrays.
- * @return true if the permutation is the definitive version.
- */
- private static boolean worthRendering(
- Iterable<Integer> verticalOrder, List<List<Map<String, Object>>> objects) {
- int original = 0;
- for (int idx : verticalOrder) {
- if (idx != original) {
- int n = objects.get(idx).size();
- if (n <= 1) {
- return false;
- }
- }
- original++;
- }
- return true;
- }
-
- /**
- * Get a list of all possible orderings of a given permutation.
- * For example: '2' would return 1,2; 2,1
- *
- * @param size The permutation.
- * @return The list of possible orderings.
- */
- private static List<List<Integer>> getPermutations(int size) {
- List<List<Integer>> out = new ArrayList<>();
- Set<Integer> used = new HashSet<>();
- List<Integer> base = new ArrayList<>();
- getPermutations(base, used, size, out);
- return out;
- }
-
- private static void getPermutations(
- List<Integer> base, Set<Integer> used, int size, List<List<Integer>> out) {
- if (used.size() == size) {
- out.add(new ArrayList<>(base));
- return;
- }
- for (int i = 0; i != size; i++) {
- if (used.contains(i)) {
- continue;
- }
- used.add(i);
- base.add(i);
-
- getPermutations(base, used, size, out);
-
- base.remove(base.size() - 1);
- used.remove(i);
- }
- }
-
- private static void writeTable(StringBuilder body, Map<String, Map<String, Result>> rows,
- Map<String, Map<String, Object>> deviceInfos, List<List<Map<String, Object>>> tests,
- Path directory, List<Integer> verticalOrder) {
- int rowspan = tests.size() + 1;
-
- int colspan = getTotalVariations(tests);
- body.append("<table>")
- .append("<thead>")
- .append("<tr>")
- .append("<th rowspan=" + rowspan + " >")
- .append("Manufacturer")
- .append("</th>")
- .append("<th rowspan=" + rowspan + " >")
- .append("Model")
- .append("</th>")
- .append("<th rowspan=" + rowspan + " >")
- .append("Device")
- .append("</th>")
- .append("<th rowspan=" + rowspan + " >")
- .append("SDK")
- .append("</th>")
- .append("<th rowspan=" + rowspan + " >")
- .append("Release")
- .append("<th rowspan=" + rowspan + " >")
- .append("totalMem")
- .append("</th>")
- .append("<th rowspan=" + rowspan + " >")
- .append("Automatic")
- .append("</th>")
- .append("</tr>");
-
- int repeats = 1;
- for (int idx : verticalOrder) {
- Collection<Map<String, Object>> test = tests.get(idx);
- colspan /= test.size();
- body.append("<tr>");
-
- for (int repeat = 0; repeat != repeats; repeat++) {
- for (Map<String, Object> _param : test) {
- Node dataExplorer = DataExplorer.getDataExplorer(HtmlUtils.getDocument(), _param);
- body.append("<th colspan=" + colspan + " class='params'>")
- .append(HtmlUtils.toString(dataExplorer))
- .append("</th>");
- }
- }
- body.append("</tr>");
- repeats *= test.size();
- }
-
- List<List<Object>> horizontalOrder = getHorizontalOrder(tests, verticalOrder);
- body.append("<tr>");
- body.append("<td colspan=7/>");
- for (List<Object> coords : horizontalOrder) {
- int total = 0;
- int acceptable = 0;
- float validScore = 0;
- for (Map.Entry<String, Map<String, Result>> row : rows.entrySet()) {
- Map<String, Result> rows0 = row.getValue();
- Result result = rows0.get(coords.toString());
- if (result == null) {
- continue;
- }
- total++;
- if (result.isAcceptable()) {
- acceptable++;
- validScore += result.getScore();
- }
- }
- body.append("<td>");
- if (total > 0) {
- body.append(acceptable * 100 / total).append("%").append(" ");
- }
-
- if (acceptable > 0) {
- body.append((int) validScore / acceptable).append("</td>");
- }
- }
- body.append("</tr>");
- body.append("</thead>");
-
- for (Map.Entry<String, Map<String, Result>> row : rows.entrySet()) {
- body.append("<tr>");
-
- String id = row.getKey();
- Map<String, Result> rows0 = row.getValue();
- Map<String, Object> deviceInfo = deviceInfos.get(id);
- Map<String, Object> build = (Map<String, Object>) deviceInfo.get("build");
-
- Map<String, Object> version = (Map<String, Object>) build.get("version");
- Map<String, Object> fields = (Map<String, Object>) build.get("fields");
- Map<String, Object> baseline = (Map<String, Object>) deviceInfo.get("baseline");
- Map<String, Object> baselineMemoryInfo = (Map<String, Object>) baseline.get("MemoryInfo");
- long totalMem = ((Number) baselineMemoryInfo.get("totalMem")).longValue();
- body.append("<td>")
- .append(fields.get("MANUFACTURER"))
- .append("</td>")
- .append("<td>")
- .append(fields.get("MODEL"))
- .append("</td>")
- .append("<td>")
- .append(fields.get("DEVICE"))
- .append("</td>")
- .append("<td>")
- .append(version.get("SDK_INT"))
- .append("</td>")
- .append("<td>")
- .append(version.get("RELEASE"))
- .append("</td>")
- .append("<td>")
- .append(totalMem / (1024 * 1024))
- .append("</td>")
- .append("<td>")
- .append(Boolean.TRUE.equals(deviceInfo.get("automatic")) ? "auto" : "")
- .append("</td>");
-
- Map<String, Float> maxScore = new HashMap<>();
-
- for (List<Object> coords : horizontalOrder) {
- Result result = rows0.get(coords.toString());
- if (result != null && result.isAcceptable()) {
- maxScore.merge(result.getGroup(), result.getScore(), Math::max);
- }
- }
-
- for (List<Object> coords : horizontalOrder) {
- Result result = rows0.get(coords.toString());
- if (result == null) {
- body.append("<td/>");
- continue;
- }
- Collection<String> classes = new ArrayList<>();
- String group = result.getGroup();
- if (result.isAcceptable()) {
- float max = maxScore.get(group);
- if (result.getScore() == max) {
- classes.add("best");
- } else if (result.getScore() > max * 0.90) {
- classes.add("good");
- }
- }
- if (result.isFailedToClear()) {
- classes.add("failedToClear");
- }
- if (!result.isAcceptable()) {
- classes.add("unacceptable");
- }
- if (result.isServiceCrashed()) {
- classes.add("serviceCrashed");
- }
- if (classes.isEmpty()) {
- body.append("<td>");
- } else {
- body.append(String.format("<td class='%s'>", String.join(" ", classes)));
- }
-
- URI uri = directory.toUri().relativize(result.getUri());
- body.append(String.format("<a href='%s'>%.1f</a>", uri, result.getScore())).append("</td>");
- }
-
- body.append("</tr>");
- }
- body.append("</table>");
- }
-
- /**
- * Use the vertical order to determine the dimension selections for every test in the table,
- * arranged from left to right.
- *
- * @param tests The test dimensions to reorder.
- * @param verticalOrder The new order to use.
- * @return The selections for the tests in an array, ordered left to right.
- */
- private static List<List<Object>> getHorizontalOrder(
- List<List<Map<String, Object>>> tests, List<Integer> verticalOrder) {
- List<List<Object>> horizontalOrder = new ArrayList<>();
- List<Object> base = new ArrayList<>();
- while (base.size() < tests.size()) {
- base.add(0);
- }
-
- while (true) {
- horizontalOrder.add(new ArrayList<>(base));
- boolean rolledOver = true;
- ListIterator<Integer> it = verticalOrder.listIterator(verticalOrder.size());
- while (it.hasPrevious()) {
- int idx = it.previous();
- List<Map<String, Object>> test = tests.get(idx);
- int value = (int) base.get(idx);
- if (value == test.size() - 1) {
- base.set(idx, 0);
- } else {
- base.set(idx, value + 1);
- rolledOver = false;
- break;
- }
- }
- if (rolledOver) {
- break;
- }
- }
- return horizontalOrder;
- }
-
- private static int getTotalVariations(Iterable<List<Map<String, Object>>> tests) {
- int total = 1;
- for (Object o : tests) {
- total *= ((Collection<Object>) o).size();
- }
- return total;
- }
-
- private static class Result {
- private final float score;
- private final URI uri;
- private final boolean acceptable;
- private final boolean failedToClear;
- private final boolean serviceCrashed;
- private final String group;
-
- Result(float score, URI uri, boolean acceptable, boolean failedToClear, boolean serviceCrashed,
- String group) {
- this.score = score;
- this.uri = uri;
- this.acceptable = acceptable;
- this.failedToClear = failedToClear;
- this.serviceCrashed = serviceCrashed;
- this.group = group;
- }
-
- float getScore() {
- return score;
- }
-
- URI getUri() {
- return uri;
- }
-
- boolean isAcceptable() {
- return acceptable;
- }
-
- boolean isFailedToClear() {
- return failedToClear;
- }
-
- boolean isServiceCrashed() {
- return serviceCrashed;
- }
-
- String getGroup() {
- return group;
- }
- }
-}
diff --git a/test/collate/src/main/java/net/jimblackler/collate/Timing.java b/test/collate/src/main/java/net/jimblackler/collate/Timing.java
deleted file mode 100644
index 5555cf2..0000000
--- a/test/collate/src/main/java/net/jimblackler/collate/Timing.java
+++ /dev/null
@@ -1,156 +0,0 @@
-package net.jimblackler.collate;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.function.Consumer;
-
-/**
- * Generates a report about how long it took to gather various metric groups.
- */
-public class Timing {
- private static final boolean USE_DEVICE = false;
-
- public static void main(String[] args) throws IOException {
- go(USE_DEVICE);
- }
-
- static void go(boolean useDevice) throws IOException {
- Set<String> allGroups = new HashSet<>();
- Map<String, Map<String, Long>> totalsByFingerprint = new HashMap<>();
- Map<String, Map<String, Long>> countsByFingerprint = new HashMap<>();
-
- Consumer<List<Map<String, Object>>> collect = results -> {
- Map<String, Object> params = (Map<String, Object>) results.get(0).get("params");
- if (params == null) {
- return;
- }
- Map<String, Long> totals = new HashMap<>();
- Map<String, Long> counts = new HashMap<>();
- boolean allZeroes = true;
-
- for (Object o : (Iterable<Object>) params.get("coordinates")) {
- int coordinate = ((Number) o).intValue();
- if (coordinate != 0) {
- allZeroes = false;
- }
- }
- if (!allZeroes) {
- return;
- }
-
- for (Object o : results) {
- Map<String, Object> row = (Map<String, Object>) o;
- if (!row.containsKey("metrics")) {
- continue;
- }
- Map<String, Object> metrics = (Map<String, Object>) row.get("metrics");
-
- Map<String, Object> memInfo = (Map<String, Object>) metrics.get("memInfo");
- if (memInfo != null) {
- register("memInfo", memInfo, totals, counts, allGroups);
- }
-
- Map<String, Object> debug = (Map<String, Object>) metrics.get("debug");
- if (debug != null) {
- register("debug", debug, totals, counts, allGroups);
- }
-
- Map<String, Object> memoryInfo = (Map<String, Object>) metrics.get("MemoryInfo");
- if (memInfo != null) {
- register("MemoryInfo", memoryInfo, totals, counts, allGroups);
- }
-
- Map<String, Object> proc = (Map<String, Object>) metrics.get("proc");
- if (proc != null) {
- register("proc", proc, totals, counts, allGroups);
- }
-
- Map<String, Object> status = (Map<String, Object>) metrics.get("status");
- if (status != null) {
- register("status", status, totals, counts, allGroups);
- }
-
- Map<String, Object> summary = (Map<String, Object>) metrics.get("summary");
- if (summary != null) {
- register("summary", summary, totals, counts, allGroups);
- }
-
- Map<String, Object> activityManager = (Map<String, Object>) metrics.get("activityManager");
- if (metrics.containsKey("activityManager")) {
- register("activityManager", activityManager, totals, counts, allGroups);
- }
- }
-
- Map<String, Object> deviceInfo = ReportUtils.getDeviceInfo(results);
- if (deviceInfo == null) {
- return;
- }
- Map<String, Object> deviceProfile = (Map<String, Object>) deviceInfo.get("deviceProfile");
- String fingerprint = (String) deviceProfile.get("fingerprint");
- totalsByFingerprint.put(fingerprint, totals);
- countsByFingerprint.put(fingerprint, counts);
- };
-
- if (useDevice) {
- Collector.deviceCollect("net.jimblackler.istresser", collect);
- } else {
- Collector.cloudCollect(null, collect);
- }
-
- List<String> allGroupsSorted = new ArrayList<>(allGroups);
- allGroupsSorted.sort(String::compareTo);
-
- try (PrintWriter writer = new PrintWriter(Files.newBufferedWriter(Paths.get("timing.csv")))) {
- {
- StringBuilder stringBuilder = new StringBuilder();
- stringBuilder.append("Fingerprint");
- for (String group : allGroupsSorted) {
- stringBuilder.append(",");
- stringBuilder.append(group);
- }
- writer.println(stringBuilder);
- }
- for (Map.Entry<String, Map<String, Long>> entry : totalsByFingerprint.entrySet()) {
- String fingerprint = entry.getKey();
- StringBuilder stringBuilder = new StringBuilder();
- stringBuilder.append(fingerprint);
- Map<String, Long> totalsByGroup = entry.getValue();
- Map<String, Long> countsByGroup = countsByFingerprint.get(fingerprint);
- for (String group : allGroupsSorted) {
- stringBuilder.append(",");
- Number v0 = totalsByGroup.get(group);
- if (v0 != null) {
- Number v = countsByGroup.get(group);
- if (v != null && v.longValue() > 0) {
- stringBuilder.append(v0.doubleValue() / (v.longValue() * 1000000));
- }
- }
- }
- writer.println(stringBuilder);
- }
- }
- }
-
- private static void register(String name, Map<String, Object> group, Map<String, Long> totals,
- Map<String, Long> counts, Set<String> allGroups) {
- Map<String, Object> meta = (Map<String, Object>) group.get("_meta");
- allGroups.add(name);
- if (!totals.containsKey(name)) {
- totals.put(name, 0L);
- }
- totals.put(name, totals.get(name) + ((Number) meta.get("duration")).longValue());
-
- if (!counts.containsKey(name)) {
- counts.put(name, 0L);
- }
- counts.put(name, counts.get(name) + 1);
- }
-}
diff --git a/test/collate/src/main/java/net/jimblackler/collate/Utils.java b/test/collate/src/main/java/net/jimblackler/collate/Utils.java
deleted file mode 100644
index 0b42396..0000000
--- a/test/collate/src/main/java/net/jimblackler/collate/Utils.java
+++ /dev/null
@@ -1,233 +0,0 @@
-package net.jimblackler.collate;
-
-import static com.google.android.apps.internal.games.memoryadvice_common.StreamUtils.readStream;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.PrintStream;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Stream;
-
-/**
- * Class containing various utility methods used by tools in the package.
- */
-class Utils {
- private static final PrintStream NULL_PRINT_STREAM = new PrintStream(new OutputStream() {
- @Override
- public void write(int b) {}
- });
-
- static String fileToString(String filename) throws IOException {
- return FileUtils.readFile(Paths.get("resources", filename));
- }
-
- public static void copyFolder(Path from, Path to) throws IOException {
- Files.createDirectory(to);
- try (Stream<Path> stream = Files.walk(from)) {
- stream.forEachOrdered(path -> {
- if (Files.isDirectory(path)) {
- return;
- }
- try {
- Files.copy(path, to.resolve(from.relativize(path)));
- } catch (IOException e) {
- throw new IllegalStateException(e);
- }
- });
- }
- }
-
- static String executeSilent(String... args) throws ExecutionError {
- return execute(NULL_PRINT_STREAM, args);
- }
-
- static String execute(String... args) throws ExecutionError {
- return execute(System.out, args);
- }
-
- static String execute(PrintStream out, String... args) throws ExecutionError {
- out.println(String.join(" ", args));
- int sleepFor = 0;
- for (int attempt = 0; attempt != 10; attempt++) {
- Process process = null;
- try {
- process = new ProcessBuilder(args).start();
- } catch (IOException e) {
- throw new ExecutionError("Error executing: " + Arrays.toString(args), e);
- }
-
- try {
- String input = readStream(process.getInputStream(), out);
- String error = readStream(process.getErrorStream(), out);
-
- try {
- process.waitFor();
- } catch (InterruptedException e) {
- throw new RuntimeException(e);
- }
- int exit = process.exitValue();
- if (exit != 0) {
- if (error.contains("Broken pipe") || error.contains("Can't find service")) {
- sleepFor += 10;
- out.println(error);
- out.print("Retrying in " + sleepFor + " seconds... ");
- try {
- Thread.sleep(sleepFor * 1000L);
- } catch (InterruptedException e) {
- // Intentionally ignored.
- }
- out.println("done");
- continue;
- }
- throw new ExecutionError(error);
- }
- return input;
- } catch (IOException ex) {
- throw new ExecutionError("Error fetching results for: " + Arrays.toString(args), ex);
- }
- }
- throw new ExecutionError("Maximum attempts reached");
- }
-
- /**
- * Selects the parameters for a run based on the 'tests' and 'coordinates' of the test
- * specification file.
- *
- * @param spec The test specification file.
- * @return The selected parameters.
- */
- static Map<String, Object> flattenParams(Map<String, Object> spec) {
- return flattenParams((List<Number>) spec.get("coordinates"),
- (List<List<Map<String, Object>>>) spec.get("tests"));
- }
-
- /**
- * Selects the parameters for a run.
- * @param coordinates The coordinates to select.
- * @param tests The test array to select from.
- * @return The run parameters.
- */
- static Map<String, Object> flattenParams(
- List<Number> coordinates, List<List<Map<String, Object>>> tests) {
- Map<String, Object> params = new HashMap<>();
- for (int coordinateNumber = 0; coordinateNumber != coordinates.size(); coordinateNumber++) {
- merge(tests.get(coordinateNumber).get(coordinates.get(coordinateNumber).intValue()), params);
- }
- return params;
- }
-
- /**
- * Creates a deep union of two maps. Arrays are concatenated and dictionaries are merged.
- *
- * @param in The first map; read only.
- * @param out The second map and the object into which changes are written.
- */
- private static void merge(Map<String, Object> in, Map<String, Object> out) {
- for (Map.Entry<String, Object> entry : in.entrySet()) {
- String key = entry.getKey();
- Object inObject = entry.getValue();
- Object outObject = out.get(key);
- if (outObject == null) {
- out.put(key, clone(inObject));
- continue;
- }
- if (inObject instanceof List && outObject instanceof List) {
- ((Collection<Object>) outObject).addAll((Collection<?>) clone(inObject));
- continue;
- }
- if (inObject instanceof Map && outObject instanceof Map) {
- merge((Map<String, Object>) inObject, ((Map<String, Object>) outObject));
- continue;
- }
- }
- }
-
- /**
- * Return a deep-clone of a JSON-compatible object tree.
- *
- * @param in The tree to clone.
- * @param <T> The cloned tree.
- */
- public static <T> T clone(T in) {
- if (in instanceof Map) {
- Map<String, Object> map = new LinkedHashMap<>();
- for (Map.Entry<String, Object> entry : ((Map<String, Object>) in).entrySet()) {
- map.put(entry.getKey(), clone(entry.getValue()));
- }
- return (T) map;
- }
-
- if (in instanceof List) {
- Collection<Object> list = new ArrayList<>();
- for (Object obj : (Iterable<Object>) in) {
- list.add(clone(obj));
- }
- return (T) list;
- }
- return in;
- }
-
- static String getProjectId() throws ExecutionError {
- return execute(Config.GCLOUD_EXECUTABLE.toString(), "config", "get-value", "project");
- }
-
- /**
- * Converts a time duration in an object to a number of milliseconds. If the object is a number,
- * it is interpreted as the number of milliseconds. If the value is a string, it is converted
- * according to the specified unit. e.g. "30s", "1H". No unit is interpreted as milliseconds.
- *
- * @param object The object to extract from.
- * @return The equivalent number of milliseconds.
- */
- static long getDuration(Object object) {
- if (object instanceof Number) {
- return ((Number) object).longValue();
- }
-
- if (object instanceof String) {
- String str = ((String) object).toUpperCase();
- int unitPosition = str.indexOf('S');
- int unitMultiplier = 1000;
- if (unitPosition == -1) {
- unitPosition = str.indexOf('M');
- unitMultiplier *= 60;
- if (unitPosition == -1) {
- unitPosition = str.indexOf('H');
- unitMultiplier *= 60;
- if (unitPosition == -1) {
- unitMultiplier = 1;
- }
- }
- }
- float value = Float.parseFloat(str.substring(0, unitPosition));
- return (long) (value * unitMultiplier);
- }
- throw new IllegalArgumentException("Input to getDuration neither string or number.");
- }
-
- /**
- * Return the value associated with the key in the given map. If the map does not define
- * the key, return the specified default value.
- *
- * @param object The map to extract the value from.
- * @param key The key associated with the value.
- * @param defaultValue The value to return if the map does not specify the key.
- * @param <T> The parameter type.
- * @return The associated value, or the defaultValue if the object does not define the key.
- */
- public static <T> T getOrDefault(Map<String, Object> object, String key, T defaultValue) {
- if (object.containsKey(key)) {
- return (T) object.get(key);
- }
- return defaultValue;
- }
-}
diff --git a/test/collate/src/main/java/net/jimblackler/collate/WaterlineTable.java b/test/collate/src/main/java/net/jimblackler/collate/WaterlineTable.java
deleted file mode 100644
index a4e0686..0000000
--- a/test/collate/src/main/java/net/jimblackler/collate/WaterlineTable.java
+++ /dev/null
@@ -1,130 +0,0 @@
-package net.jimblackler.collate;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.nio.file.FileSystems;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Tool to create a table of maximum values from tests.
- */
-public class WaterlineTable {
- public static void main(String[] args) throws IOException {
- Gson gson = new GsonBuilder().setPrettyPrinting().create();
- Map<String, Object> out = gson.fromJson(
- FileUtils.readFile(FileSystems.getDefault().getPath("lookup.json")), Map.class);
- List<String> baselineMetrics = new ArrayList<>();
-
- for (Object o : out.values()) {
- Map<String, Object> limits = (Map<String, Object>) o;
- Map<String, Object> baseline = (Map<String, Object>) limits.get("baseline");
- load(baselineMetrics, baseline);
-
- Map<String, Object> constant = (Map<String, Object>) baseline.get("constant");
- if (constant != null) {
- load(baselineMetrics, constant);
- }
- }
-
- Collections.sort(baselineMetrics);
-
- List<String> limitMetrics = new ArrayList<>();
-
- for (Object o : out.values()) {
- Map<String, Object> limits = (Map<String, Object>) o;
- Map<String, Object> limit = (Map<String, Object>) limits.get("limit");
- load(limitMetrics, limit);
- }
-
- Collections.sort(limitMetrics);
-
- try (
- PrintWriter writer = new PrintWriter(Files.newBufferedWriter(Paths.get("waterline.csv")))) {
- writer.print("Device");
-
- for (String metric : baselineMetrics) {
- writer.print(",");
- writer.print(metric + " baseline");
- }
-
- for (String metric : limitMetrics) {
- writer.print(",");
- writer.print(metric + " limit");
- }
- writer.println();
-
- {
- for (Map.Entry<String, Object> entry : out.entrySet()) {
- Map<String, Object> limits = (Map<String, Object>) entry.getValue();
- Map<String, Object> limit = (Map<String, Object>) limits.get("limit");
- Map<String, Object> baseline = (Map<String, Object>) limits.get("baseline");
- Map<String, Object> constant = (Map<String, Object>) baseline.get("constant");
-
- writer.print(entry.getKey());
-
- for (String metric : baselineMetrics) {
- writer.print(",");
- Long value = find(baseline, metric);
- if (value == null && constant != null) {
- value = find(constant, metric);
- }
- if (value != null) {
- writer.print(value);
- }
- }
-
- for (String metric : limitMetrics) {
- writer.print(",");
- Long value = find(limit, metric);
- if (value != null) {
- writer.print(value);
- }
- }
-
- writer.println();
- }
- }
- }
- }
-
- private static Long find(Map<String, Object> metrics, String metric) {
- for (Object o : metrics.values()) {
- if (!(o instanceof Map)) {
- continue;
- }
- Map<String, Object> group = (Map<String, Object>) o;
- Number number = (Number) group.get(metric);
- if (number != null) {
- return number.longValue();
- }
- }
- return null;
- }
-
- private static void load(Collection<String> allMetrics, Map<String, Object> metrics) {
- for (Object o : metrics.values()) {
- if (!(o instanceof Map)) {
- continue;
- }
- Map<String, Object> group = (Map<String, Object>) o;
- for (Map.Entry<String, Object> entry : group.entrySet()) {
- String metric = entry.getKey();
- if (allMetrics.contains(metric)) {
- continue;
- }
- Object object = entry.getValue();
- if (object instanceof Number) {
- allMetrics.add(metric);
- }
- }
- }
- }
-}
diff --git a/test/istresser/.clang-format b/test/istresser/.clang-format
deleted file mode 100644
index 3b60c89..0000000
--- a/test/istresser/.clang-format
+++ /dev/null
@@ -1,3 +0,0 @@
-BasedOnStyle: Google
-IndentWidth: 2
-SpacesBeforeTrailingComments: 2
diff --git a/test/istresser/.gitignore b/test/istresser/.gitignore
deleted file mode 100644
index 0f0539e..0000000
--- a/test/istresser/.gitignore
+++ /dev/null
@@ -1,17 +0,0 @@
-*.iml
-/app/.cxx
-/local.properties
-/.idea/caches
-/.idea/libraries
-/.idea/modules.xml
-/.idea/workspace.xml
-/.idea/navEditor.xml
-/.idea/assetWizardSettings.xml
-.DS_Store
-/build
-/captures
-/caches
-/codeStyles
-/libraries
-/shelf
-.externalNativeBuild
diff --git a/test/istresser/app/.gitignore b/test/istresser/app/.gitignore
deleted file mode 100644
index 4e4023c..0000000
--- a/test/istresser/app/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-/build
-/debug
diff --git a/test/istresser/app/build.gradle b/test/istresser/app/build.gradle
deleted file mode 100644
index 0e2aa94..0000000
--- a/test/istresser/app/build.gradle
+++ /dev/null
@@ -1,37 +0,0 @@
-apply plugin: 'com.android.application'
-
-android {
- compileSdkVersion 29
- buildToolsVersion "29.0.2"
- defaultConfig {
- applicationId "net.jimblackler.istresser"
- minSdkVersion 19
- targetSdkVersion 29
- versionCode 24
- versionName "1.0"
- testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
- }
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
- }
- }
-
- compileOptions {
- sourceCompatibility = '1.8'
- targetCompatibility = '1.8'
- }
-}
-
-dependencies {
- api 'com.google.guava:guava:28.0-android'
- implementation fileTree(dir: 'libs', include: ['*.jar'])
- implementation 'com.fasterxml.jackson.core:jackson-databind:2.12.2'
- implementation 'com.google.android.games:memory-advice:0.24'
- implementation 'com.google.android.games:memory-advice-common:0.24'
- implementation 'com.google.android.games:memory-test:0.24'
- implementation 'androidx.annotation:annotation:1.1.0'
- implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
- implementation 'androidx.core:core:1.3.2'
-}
diff --git a/test/istresser/app/src/main/AndroidManifest.xml b/test/istresser/app/src/main/AndroidManifest.xml
deleted file mode 100644
index 9c50812..0000000
--- a/test/istresser/app/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- package="net.jimblackler.istresser">
-
- <uses-feature
- android:glEsVersion="0x00020000"
- android:required="true" />
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
- <application
- android:allowBackup="true"
- android:icon="@mipmap/ic_launcher"
- android:label="@string/app_name"
- android:requestLegacyExternalStorage="true"
- android:roundIcon="@mipmap/ic_launcher_round"
- android:supportsRtl="true"
- android:theme="@style/AppTheme"
- tools:ignore="AllowBackup,GoogleAppIndexingWarning">
- <activity android:name=".MainActivity">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- <intent-filter>
- <action android:name="com.google.intent.action.TEST_LOOP" />
- <category android:name="android.intent.category.DEFAULT" />
- <data android:mimeType="application/javascript" />
- </intent-filter>
- </activity>
- <meta-data
- android:name="com.google.test.loops"
- android:value="1" />
- <provider
- android:name="androidx.core.content.FileProvider"
- android:authorities="${applicationId}.provider"
- android:exported="false"
- android:grantUriPermissions="true">
- <meta-data
- android:name="android.support.FILE_PROVIDER_PATHS"
- android:resource="@xml/file_paths" />
- </provider>
- </application>
-
-</manifest>
\ No newline at end of file
diff --git a/test/istresser/app/src/main/assets/default.json b/test/istresser/app/src/main/assets/default.json
deleted file mode 100644
index 2404c6d..0000000
--- a/test/istresser/app/src/main/assets/default.json
+++ /dev/null
@@ -1,95 +0,0 @@
-{
- "tests": [
- [
- {
- "glTest": "40K",
- "maxConsumer": "2048K",
- "timeout": "10m",
- "advisorParameters": {
- "metrics": {
- "constant": {
- "MemoryInfo": {
- "totalMem": true,
- "threshold": true
- },
- "meminfo": {
- "CommitLimit": true,
- "HighTotal": true,
- "LowTotal": true,
- "MemTotal": true
- }
- },
- "variable": {
- "debug": {
- "nativeHeapAllocatedSize": true
- },
- "MemoryInfo": {
- "availMem": true,
- "lowMemory": true
- },
- "meminfo": {
- "Active": true,
- "Active(anon)": true,
- "Active(file)": true,
- "AnonPages": true,
- "MemAvailable": true,
- "MemFree": true,
- "VmData": true,
- "VmRSS": true
- },
- "proc": {
- "oom_score": true
- },
- "status": {
- "VmRSS": true,
- "VmSize": true
- },
- "summary": {
- "summary.native-heap": true,
- "summary.graphics": true,
- "summary.total-pss": true,
- "summary.total-swap": true
- },
- "ActivityManager": {
- "MemoryClass": true,
- "LargeMemoryClass": true,
- "LowRamDevice": true
- },
- "canaryProcessTester": {
- "memory": "1M"
- }
- },
- "baseline": {
- "ActivityManager": true,
- "MemoryInfo": true,
- "debug": true,
- "meminfo": true,
- "proc": true,
- "status": true,
- "summary": true
- }
- },
- "heuristics": {
- "canaryProcessTester": true,
- "formulas": {
- "yellow": [
- "VmRSS > baseline.availMem * .9"
- ],
- "red": [
- "VmRSS > baseline.availMem"
- ]
- }
- }
- },
- "switchTest": {
- "enabled": true,
- "launchDuration": "30S",
- "returnDuration": "60S"
- }
- }
- ]
- ],
- "coordinates": [
- 0
- ]
-}
\ No newline at end of file
diff --git a/test/istresser/app/src/main/java/net/jimblackler/istresser/LogMonitor.java b/test/istresser/app/src/main/java/net/jimblackler/istresser/LogMonitor.java
deleted file mode 100644
index 075a37e..0000000
--- a/test/istresser/app/src/main/java/net/jimblackler/istresser/LogMonitor.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package net.jimblackler.istresser;
-
-import android.util.Log;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.nio.charset.StandardCharsets;
-
-/**
- * A long-running service that sends every new log line to a client.
- */
-public class LogMonitor {
- private static final String TAG = LogMonitor.class.getSimpleName();
-
- /**
- * Create a new log monitor.
- *
- * @param client The client to send every new log line to on a best-effort basis.
- */
- public LogMonitor(LogReaderClient client) {
- startLog(client);
- }
-
- private static void startLog(LogReaderClient client) {
- new Thread(() -> {
- try (InputStream inputStream = Runtime.getRuntime().exec("logcat").getInputStream();
- BufferedReader bufferedReader =
- new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8))) {
- // Initially all log lines already present on the log are discarded. The class is only for
- // monitoring future log activity.
- while (bufferedReader.ready()) {
- bufferedReader.readLine();
- }
-
- while (true) {
- try {
- String line = bufferedReader.readLine();
- if (line == null) {
- // Null is returned when and only when the stream terminates.
- // logcat is supposed to be long-running (unless -d is used) but has been seen to
- // terminate on some devices. If this happens we simply restart it; ASAP to reduce
- // the number of lost log lines.
- Log.w(TAG, "Restarting log monitor");
- startLog(client);
- return;
- } else {
- client.receive(line);
- }
- } catch (IOException e) {
- Log.w(TAG, "Error reading a log line", e);
- }
- }
- } catch (IOException e) {
- Log.w(TAG, "Log monitor could not access logcat", e);
- }
- }).start();
- }
-
- interface LogReaderClient {
- void receive(String line);
- }
-}
diff --git a/test/istresser/app/src/main/java/net/jimblackler/istresser/MainActivity.java b/test/istresser/app/src/main/java/net/jimblackler/istresser/MainActivity.java
deleted file mode 100644
index a4d6378..0000000
--- a/test/istresser/app/src/main/java/net/jimblackler/istresser/MainActivity.java
+++ /dev/null
@@ -1,432 +0,0 @@
-package net.jimblackler.istresser;
-
-import static com.google.android.apps.internal.games.memoryadvice.Utils.readFile;
-import static com.google.android.apps.internal.games.memoryadvice_common.ConfigUtils.getOrDefault;
-import static com.google.android.apps.internal.games.memoryadvice_common.StreamUtils.readStream;
-import static com.google.android.apps.internal.games.memorytest.DurationUtils.getDuration;
-import static com.google.android.apps.internal.games.memorytest.MapUtils.flattenParams;
-import static net.jimblackler.istresser.ServiceCommunicationHelper.CRASHED_BEFORE;
-import static net.jimblackler.istresser.ServiceCommunicationHelper.TOTAL_MEMORY_MB;
-
-import android.app.Activity;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager;
-import android.net.Uri;
-import android.os.Bundle;
-import android.os.Environment;
-import android.provider.MediaStore;
-import android.util.Log;
-import android.view.View;
-import android.webkit.WebView;
-import androidx.annotation.Nullable;
-import androidx.core.content.FileProvider;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.google.android.apps.internal.games.memoryadvice.MemoryAdvisor;
-import com.google.android.apps.internal.games.memoryadvice.MemoryWatcher;
-import com.google.android.apps.internal.games.memorytest.MemoryTest;
-import com.google.android.apps.internal.games.memorytest.TestSurface;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Timer;
-import java.util.TimerTask;
-
-/**
- * The main activity of the istresser app
- */
-public class MainActivity extends Activity {
- private static final String TAG = MainActivity.class.getSimpleName();
- private static final int BACKGROUND_MEMORY_PRESSURE_MB = 500;
- private static final int BACKGROUND_PRESSURE_PERIOD_SECONDS = 30;
- private static final int BYTES_IN_MEGABYTE = 1024 * 1024;
- private static final String MEMORY_BLOCKER = "MemoryBlockCommand";
- private static final String ALLOCATE_ACTION = "Allocate";
- private static final String FREE_ACTION = "Free";
-
- private final ObjectMapper objectMapper = new ObjectMapper();
-
- private PrintStream resultsStream = System.out;
- private MemoryAdvisor memoryAdvisor;
- private ServiceCommunicationHelper serviceCommunicationHelper;
- private Map<String, Object> params;
- private ServiceState serviceState;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
-
- Intent launchIntent = getIntent();
-
- Map<String, Object> params1 = null;
- if ("com.google.intent.action.TEST_LOOP".equals(launchIntent.getAction())) {
- // Parameters for an automatic run have been set via Firebase Test Loop.
- Uri logFile = launchIntent.getData();
- if (logFile != null) {
- String logPath = logFile.getEncodedPath();
- if (logPath != null) {
- Log.i(TAG, "Log file " + logPath);
- try {
- resultsStream = new PrintStream(
- Objects.requireNonNull(getContentResolver().openOutputStream(logFile)));
- } catch (FileNotFoundException e) {
- throw new IllegalStateException(e);
- }
- }
- }
- try {
- params1 = objectMapper.readValue(readFile("/sdcard/params.json"), Map.class);
- } catch (IOException e) {
- throw new IllegalStateException(e);
- }
- }
-
- if (launchIntent.hasExtra("Params")) {
- // Parameters for an automatic run have been set via Intent.
- try {
- params1 = objectMapper.readValue(
- Objects.requireNonNull(launchIntent.getStringExtra("Params")), Map.class);
- } catch (JsonProcessingException e) {
- throw new IllegalStateException(e);
- }
- }
-
- if (params1 == null) {
- // Must be manually launched. Get the parameters from the local default.json.
- try {
- params1 = objectMapper.readValue(readStream(getAssets().open("default.json")), Map.class);
- } catch (IOException e) {
- throw new IllegalStateException(e);
- }
- }
- if (resultsStream == System.out) {
- // This run is not running on Firebase. Determine the filename.
- List<Object> coordinates = (List<Object>) params1.get("coordinates");
- StringBuilder coordsString = new StringBuilder();
- for (int coordinateNumber = 0; coordinateNumber != coordinates.size(); coordinateNumber++) {
- coordsString.append("_").append(coordinates.get(coordinateNumber));
- }
- String fileName = getExternalFilesDir(null) + "/results" + coordsString + ".json";
- if (!new File(fileName).exists()) {
- // We deliberately do not overwrite the result for the case where Android automatically
- // relaunches the intent following a crash.
- try {
- resultsStream = new PrintStream(fileName);
- } catch (FileNotFoundException e) {
- throw new IllegalStateException(e);
- }
- }
- }
-
- params = flattenParams(params1);
- serviceCommunicationHelper = new ServiceCommunicationHelper(this);
- serviceState = ServiceState.DEALLOCATED;
-
- // Setting up broadcast receiver
- BroadcastReceiver receiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- Map<String, Object> report = new LinkedHashMap<>();
- report.put("time", System.currentTimeMillis());
- if (intent.getBooleanExtra(CRASHED_BEFORE, false)) {
- report.put("serviceCrashed", true);
- }
- Map<String, Object> testMetrics = new LinkedHashMap<>();
- testMetrics.put(
- "serviceTotalMemory", BYTES_IN_MEGABYTE * intent.getIntExtra(TOTAL_MEMORY_MB, 0));
- report.put("testMetrics", testMetrics);
- try {
- resultsStream.println(objectMapper.writeValueAsString(report));
- } catch (JsonProcessingException e) {
- throw new IllegalStateException(e);
- }
-
- switch (serviceState) {
- case ALLOCATING_MEMORY:
- serviceState = ServiceState.ALLOCATED;
-
- new Thread() {
- @Override
- public void run() {
- try {
- Thread.sleep(BACKGROUND_PRESSURE_PERIOD_SECONDS * 1000);
- } catch (Exception e) {
- if (e instanceof InterruptedException) {
- Thread.currentThread().interrupt();
- }
- throw new IllegalStateException(e);
- }
- serviceState = ServiceState.FREEING_MEMORY;
- serviceCommunicationHelper.freeServerMemory();
- }
- }.start();
-
- break;
- case FREEING_MEMORY:
- serviceState = ServiceState.DEALLOCATED;
-
- new Thread() {
- @Override
- public void run() {
- try {
- Thread.sleep(BACKGROUND_PRESSURE_PERIOD_SECONDS * 1000);
- } catch (Exception e) {
- if (e instanceof InterruptedException) {
- Thread.currentThread().interrupt();
- }
- throw new IllegalStateException(e);
- }
- serviceState = ServiceState.ALLOCATING_MEMORY;
- serviceCommunicationHelper.allocateServerMemory(BACKGROUND_MEMORY_PRESSURE_MB);
- }
- }.start();
-
- break;
- default:
- }
- }
- };
- registerReceiver(receiver, new IntentFilter("com.google.gamesdk.grabber.RETURN"));
-
- Map<String, Object> report = new LinkedHashMap<>();
- report.put("time", System.currentTimeMillis());
- report.put("params", params1);
-
- TestSurface testSurface = findViewById(R.id.glsurfaceView);
- testSurface.setVisibility(View.GONE);
-
- PackageInfo packageInfo = null;
- try {
- packageInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
- report.put("version", packageInfo.versionCode);
- } catch (PackageManager.NameNotFoundException e) {
- Log.i(TAG, "Could not get package information", e);
- }
-
- if (Boolean.TRUE.equals(params.get("serviceBlocker"))) {
- activateServiceBlocker();
- }
-
- if (Boolean.TRUE.equals(params.get("firebaseBlocker"))) {
- activateFirebaseBlocker();
- }
-
- try {
- resultsStream.println(objectMapper.writeValueAsString(report));
- } catch (JsonProcessingException e) {
- throw new IllegalStateException(e);
- }
-
- memoryAdvisor = new MemoryAdvisor(this, (Map<String, Object>) params.get("advisorParameters"));
-
- new LogMonitor(line -> {
- if (line.contains("Out of memory")) {
- Map<String, Object> report1 = new LinkedHashMap<>();
- Collection<Object> lines = new ArrayList<>();
- lines.add(line);
- report1.put("criticalLogLines", lines);
- report1.put("time", System.currentTimeMillis());
- try {
- resultsStream.println(objectMapper.writeValueAsString(report1));
- } catch (JsonProcessingException e) {
- throw new IllegalStateException(e);
- }
- }
- });
-
- Map<String, Object> report1 = new LinkedHashMap<>();
- report1.put("deviceInfo", memoryAdvisor.getDeviceInfo());
- try {
- resultsStream.println(objectMapper.writeValueAsString(report1));
- } catch (JsonProcessingException e) {
- throw new IllegalStateException(e);
- }
-
- Map<String, Object> switchTest = (Map<String, Object>) params.get("switchTest");
- if (switchTest != null) {
- scheduleAppSwitch(switchTest);
- }
-
- String paramsString;
- try {
- paramsString = objectMapper.writeValueAsString(params);
- } catch (JsonProcessingException e) {
- throw new IllegalStateException(e);
- }
-
- WebView webView = findViewById(R.id.webView);
-
- new MemoryWatcher(memoryAdvisor, 250,
- new MemoryTest(this, memoryAdvisor, findViewById(R.id.glsurfaceView), params, report0 -> {
- String reportString;
- try {
- reportString = objectMapper.writeValueAsString(report0);
- } catch (JsonProcessingException e) {
- throw new IllegalStateException(e);
- }
- resultsStream.println(reportString);
- if (Boolean.TRUE.equals(report0.get("exiting"))) {
- resultsStream.close();
- finish();
- } else {
- runOnUiThread(()
- -> webView.loadData(reportString + System.lineSeparator()
- + System.lineSeparator() + paramsString,
- "text/plain; charset=utf-8", "UTF-8"));
- }
- }));
- }
-
- @Override
- protected void onResume() {
- super.onResume();
-
- Map<String, Object> report = new LinkedHashMap<>();
- report.put("activityPaused", false);
- report.put("time", System.currentTimeMillis());
- try {
- resultsStream.println(objectMapper.writeValueAsString(report));
- } catch (JsonProcessingException e) {
- throw new IllegalStateException(e);
- }
- }
-
- @Override
- protected void onPause() {
- super.onPause();
-
- Map<String, Object> report = new LinkedHashMap<>();
- report.put("activityPaused", true);
- report.put("time", System.currentTimeMillis());
- try {
- resultsStream.println(objectMapper.writeValueAsString(report));
- } catch (JsonProcessingException e) {
- throw new IllegalStateException(e);
- }
- }
-
- @Override
- protected void onDestroy() {
- Map<String, Object> report = new LinkedHashMap<>();
- report.put("onDestroy", true);
- report.put("time", System.currentTimeMillis());
- try {
- resultsStream.println(objectMapper.writeValueAsString(report));
- } catch (JsonProcessingException e) {
- throw new IllegalStateException(e);
- }
- super.onDestroy();
- }
-
- @Override
- public void onTrimMemory(int level) {
- memoryAdvisor.setOnTrim(level);
- super.onTrimMemory(level);
- }
-
- @Override
- protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
- super.onActivityResult(requestCode, resultCode, data);
- }
-
- private void scheduleAppSwitch(Map<String, Object> switchTest) {
- new Timer().schedule(new TimerTask() {
- @Override
- public void run() {
- Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
- File file =
- new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)
- + File.separator + "pic.jpg");
- String authority = getApplicationContext().getPackageName() + ".provider";
- Uri uriForFile = FileProvider.getUriForFile(MainActivity.this, authority, file);
- intent.putExtra(MediaStore.EXTRA_OUTPUT, uriForFile);
- startActivityForResult(intent, 1);
- new Timer().schedule(new TimerTask() {
- @Override
- public void run() {
- finishActivity(1);
- scheduleAppSwitch(switchTest);
- }
- }, getDuration(getOrDefault(switchTest, "returnDuration", "60S")));
- }
- }, getDuration(getOrDefault(switchTest, "launchDuration", "30S")));
- }
-
- private void activateServiceBlocker() {
- serviceState = ServiceState.ALLOCATING_MEMORY;
- serviceCommunicationHelper.allocateServerMemory(BACKGROUND_MEMORY_PRESSURE_MB);
- }
-
- private void activateFirebaseBlocker() {
- new Thread() {
- @Override
- public void run() {
- Log.v(MEMORY_BLOCKER, FREE_ACTION);
- while (true) {
- Log.v(MEMORY_BLOCKER, ALLOCATE_ACTION + " " + BACKGROUND_MEMORY_PRESSURE_MB);
- {
- Map<String, Object> report = new LinkedHashMap<>();
- report.put("time", System.currentTimeMillis());
- Map<String, Object> testMetrics = new LinkedHashMap<>();
- testMetrics.put(
- "serviceTotalMemory", BYTES_IN_MEGABYTE * BACKGROUND_MEMORY_PRESSURE_MB);
- report.put("testMetrics", testMetrics);
- try {
- resultsStream.println(objectMapper.writeValueAsString(report));
- } catch (JsonProcessingException e) {
- throw new IllegalStateException(e);
- }
- }
- try {
- Thread.sleep(BACKGROUND_PRESSURE_PERIOD_SECONDS * 1000);
- } catch (Exception e) {
- if (e instanceof InterruptedException) {
- Thread.currentThread().interrupt();
- }
- throw new IllegalStateException(e);
- }
- Log.v(MEMORY_BLOCKER, FREE_ACTION);
- {
- Map<String, Object> report = new LinkedHashMap<>();
- report.put("time", System.currentTimeMillis());
- Map<String, Object> testMetrics = new LinkedHashMap<>();
- testMetrics.put("serviceTotalMemory", 0);
- report.put("testMetrics", testMetrics);
- try {
- resultsStream.println(objectMapper.writeValueAsString(report));
- } catch (JsonProcessingException e) {
- throw new IllegalStateException(e);
- }
- }
- try {
- Thread.sleep(BACKGROUND_PRESSURE_PERIOD_SECONDS * 1000);
- } catch (Exception e) {
- if (e instanceof InterruptedException) {
- Thread.currentThread().interrupt();
- }
- throw new IllegalStateException(e);
- }
- }
- }
- }.start();
- }
-
- enum ServiceState {
- ALLOCATING_MEMORY,
- ALLOCATED,
- FREEING_MEMORY,
- DEALLOCATED,
- }
-}
diff --git a/test/istresser/app/src/main/java/net/jimblackler/istresser/ServiceCommunicationHelper.java b/test/istresser/app/src/main/java/net/jimblackler/istresser/ServiceCommunicationHelper.java
deleted file mode 100644
index fd89cd6..0000000
--- a/test/istresser/app/src/main/java/net/jimblackler/istresser/ServiceCommunicationHelper.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package net.jimblackler.istresser;
-
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.os.Build.VERSION;
-import android.os.Build.VERSION_CODES;
-import android.util.Log;
-
-class ServiceCommunicationHelper {
- static final String CRASHED_BEFORE = "crashed_before";
- static final String TOTAL_MEMORY_MB = "total_memory_mb";
- private static final String ACTION_TYPE = "action";
- private static final String QUERY_ACTION = "query";
- private static final String ALLOCATE_MEMORY_ACTION = "allocate";
- private static final String FREE_MEMORY_ACTION = "free";
- private static final String FIRST_TIME = "first_time";
- private static final String TAG = MainActivity.class.getSimpleName();
- private final Context context;
- private boolean isFirstTime;
-
- ServiceCommunicationHelper(Context context) {
- this.context = context;
- isFirstTime = true;
- }
-
- void allocateServerMemory(int megabytes) {
- if (VERSION.SDK_INT >= VERSION_CODES.O) {
- Intent intent = new Intent();
- intent.setComponent(new ComponentName(
- "com.google.gamesdk.grabber", "com.google.gamesdk.grabber.MemoryPressureService"));
- intent.putExtra(ACTION_TYPE, ALLOCATE_MEMORY_ACTION);
- intent.putExtra(TOTAL_MEMORY_MB, megabytes);
- intent.putExtra(FIRST_TIME, isFirstTime);
- isFirstTime = false;
- context.startForegroundService(intent);
- } else {
- Log.w(TAG, "Unable to request server memory, version is below 26");
- }
- }
-
- void queryServerMemory() {
- if (VERSION.SDK_INT >= VERSION_CODES.O) {
- Intent intent = new Intent();
- intent.setComponent(new ComponentName(
- "com.google.gamesdk.grabber", "com.google.gamesdk.grabber.MemoryPressureService"));
- intent.putExtra(ACTION_TYPE, QUERY_ACTION);
- intent.putExtra(FIRST_TIME, isFirstTime);
- isFirstTime = false;
- context.startForegroundService(intent);
- } else {
- Log.w(TAG, "Unable to query server memory, version is below 26");
- }
- }
-
- void freeServerMemory() {
- if (VERSION.SDK_INT >= VERSION_CODES.O) {
- Intent intent = new Intent();
- intent.setComponent(new ComponentName(
- "com.google.gamesdk.grabber", "com.google.gamesdk.grabber.MemoryPressureService"));
- intent.putExtra(ACTION_TYPE, FREE_MEMORY_ACTION);
- intent.putExtra(FIRST_TIME, isFirstTime);
- isFirstTime = false;
- context.startForegroundService(intent);
- } else {
- Log.w(TAG, "Unable to free server memory, version is below 26");
- }
- }
-}
diff --git a/test/istresser/app/src/main/res/layout/activity_main.xml b/test/istresser/app/src/main/res/layout/activity_main.xml
deleted file mode 100644
index c13dbe1..0000000
--- a/test/istresser/app/src/main/res/layout/activity_main.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:keepScreenOn="true"
- android:orientation="vertical"
- tools:context=".MainActivity">
-
- <com.google.android.apps.internal.games.memorytest.TestSurface
- android:id="@+id/glsurfaceView"
- android:layout_width="200dp"
- android:layout_height="20dp" />
-
- <WebView android:id="@+id/webView"
- android:layout_width="200dp"
- android:layout_height="match_parent" />
-
-</TableLayout>
\ No newline at end of file
diff --git a/test/istresser/app/src/main/res/values/colors.xml b/test/istresser/app/src/main/res/values/colors.xml
deleted file mode 100644
index 69b2233..0000000
--- a/test/istresser/app/src/main/res/values/colors.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
- <color name="colorPrimary">#008577</color>
- <color name="colorPrimaryDark">#00574B</color>
- <color name="colorAccent">#D81B60</color>
-</resources>
diff --git a/test/istresser/app/src/main/res/values/strings.xml b/test/istresser/app/src/main/res/values/strings.xml
deleted file mode 100644
index 095bcdd..0000000
--- a/test/istresser/app/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-<resources>
- <string name="app_name">IStresser</string>
-</resources>
diff --git a/test/istresser/app/src/main/res/values/styles.xml b/test/istresser/app/src/main/res/values/styles.xml
deleted file mode 100644
index 00a5c09..0000000
--- a/test/istresser/app/src/main/res/values/styles.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-<resources>
-
- <style name="AppTheme" parent="@android:style/Theme.DeviceDefault">
- <item name="android:textSize">16sp</item>
- </style>
-
- <style name="TableCell">
- <item name="android:padding">8sp</item>
- </style>
-</resources>
diff --git a/test/istresser/app/src/main/res/xml/file_paths.xml b/test/istresser/app/src/main/res/xml/file_paths.xml
deleted file mode 100644
index 61248eb..0000000
--- a/test/istresser/app/src/main/res/xml/file_paths.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<paths xmlns:android="http://schemas.android.com/apk/res/android">
- <external-path name="external_files" path="."/>
-</paths>
\ No newline at end of file
diff --git a/test/istresser/build.gradle b/test/istresser/build.gradle
deleted file mode 100644
index 59a592b..0000000
--- a/test/istresser/build.gradle
+++ /dev/null
@@ -1,30 +0,0 @@
-// Top-level build file where you can add configuration options common to all sub-projects/modules.
-
-buildscript {
- repositories {
- google()
- mavenCentral()
-
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:4.2.2'
-
- // NOTE: Do not place your application dependencies here; they belong
- // in the individual module build.gradle files
- }
-}
-
-allprojects {
- repositories {
- google()
- mavenCentral()
- maven {
- url 'https://jitpack.io'
- }
- mavenLocal()
- }
-}
-
-task clean(type: Delete) {
- delete rootProject.buildDir
-}
diff --git a/test/istresser/build.sh b/test/istresser/build.sh
deleted file mode 100755
index 64f32f9..0000000
--- a/test/istresser/build.sh
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/bin/bash
-set -e # Exit on error
-export ANDROID_HOME=`pwd`/../../../prebuilts/sdk
-export ANDROID_NDK_HOME=`pwd`/../../../prebuilts/ndk/r17
-mkdir "$ANDROID_HOME/licenses" || true
-echo "d56f5187479451eabf01fb78af6dfcb131a6481e" > "$ANDROID_HOME/licenses/android-sdk-license"
-echo "24333f8a63b6825ea9c5514f83c2829b004d1fee" >> "$ANDROID_HOME/licenses/android-sdk-license"
-
-pushd ../memoryadvice
-./build.sh
-popd
-
-./gradlew build
diff --git a/test/istresser/gradle.properties b/test/istresser/gradle.properties
deleted file mode 100644
index 2510a2d..0000000
--- a/test/istresser/gradle.properties
+++ /dev/null
@@ -1,3 +0,0 @@
-android.enableJetifier=true
-android.useAndroidX=true
-org.gradle.jvmargs=-Xmx4608m
\ No newline at end of file
diff --git a/test/istresser/gradle.xml b/test/istresser/gradle.xml
deleted file mode 100644
index 7ac24c7..0000000
--- a/test/istresser/gradle.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
- <component name="GradleSettings">
- <option name="linkedExternalProjectsSettings">
- <GradleProjectSettings>
- <option name="distributionType" value="DEFAULT_WRAPPED" />
- <option name="externalProjectPath" value="$PROJECT_DIR$" />
- <option name="modules">
- <set>
- <option value="$PROJECT_DIR$" />
- <option value="$PROJECT_DIR$/app" />
- </set>
- </option>
- <option name="resolveModulePerSourceSet" value="false" />
- </GradleProjectSettings>
- </option>
- </component>
-</project>
\ No newline at end of file
diff --git a/test/istresser/gradle/wrapper/gradle-wrapper.jar b/test/istresser/gradle/wrapper/gradle-wrapper.jar
deleted file mode 100644
index 29953ea..0000000
--- a/test/istresser/gradle/wrapper/gradle-wrapper.jar
+++ /dev/null
Binary files differ
diff --git a/test/istresser/gradle/wrapper/gradle-wrapper.properties b/test/istresser/gradle/wrapper/gradle-wrapper.properties
deleted file mode 100644
index 7e75b8e..0000000
--- a/test/istresser/gradle/wrapper/gradle-wrapper.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-#Fri Nov 22 11:41:36 CET 2019
-distributionBase=GRADLE_USER_HOME
-distributionPath=wrapper/dists
-zipStoreBase=GRADLE_USER_HOME
-zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.1-all.zip
diff --git a/test/istresser/gradlew b/test/istresser/gradlew
deleted file mode 100755
index cccdd3d..0000000
--- a/test/istresser/gradlew
+++ /dev/null
@@ -1,172 +0,0 @@
-#!/usr/bin/env sh
-
-##############################################################################
-##
-## Gradle start up script for UN*X
-##
-##############################################################################
-
-# Attempt to set APP_HOME
-# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >/dev/null
-APP_HOME="`pwd -P`"
-cd "$SAVED" >/dev/null
-
-APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
-
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
-
-# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD="maximum"
-
-warn () {
- echo "$*"
-}
-
-die () {
- echo
- echo "$*"
- echo
- exit 1
-}
-
-# OS specific support (must be 'true' or 'false').
-cygwin=false
-msys=false
-darwin=false
-nonstop=false
-case "`uname`" in
- CYGWIN* )
- cygwin=true
- ;;
- Darwin* )
- darwin=true
- ;;
- MINGW* )
- msys=true
- ;;
- NONSTOP* )
- nonstop=true
- ;;
-esac
-
-CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
-
-# Determine the Java command to use to start the JVM.
-if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
- # IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
- else
- JAVACMD="$JAVA_HOME/bin/java"
- fi
- if [ ! -x "$JAVACMD" ] ; then
- die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
- fi
-else
- JAVACMD="java"
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
-fi
-
-# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
- MAX_FD_LIMIT=`ulimit -H -n`
- if [ $? -eq 0 ] ; then
- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
- MAX_FD="$MAX_FD_LIMIT"
- fi
- ulimit -n $MAX_FD
- if [ $? -ne 0 ] ; then
- warn "Could not set maximum file descriptor limit: $MAX_FD"
- fi
- else
- warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
- fi
-fi
-
-# For Darwin, add options to specify how the application appears in the dock
-if $darwin; then
- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
-fi
-
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
- APP_HOME=`cygpath --path --mixed "$APP_HOME"`
- CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
- JAVACMD=`cygpath --unix "$JAVACMD"`
-
- # We build the pattern for arguments to be converted via cygpath
- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
- SEP=""
- for dir in $ROOTDIRSRAW ; do
- ROOTDIRS="$ROOTDIRS$SEP$dir"
- SEP="|"
- done
- OURCYGPATTERN="(^($ROOTDIRS))"
- # Add a user-defined pattern to the cygpath arguments
- if [ "$GRADLE_CYGPATTERN" != "" ] ; then
- OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
- fi
- # Now convert the arguments - kludge to limit ourselves to /bin/sh
- i=0
- for arg in "$@" ; do
- CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
- CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
-
- if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
- eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
- else
- eval `echo args$i`="\"$arg\""
- fi
- i=$((i+1))
- done
- case $i in
- (0) set -- ;;
- (1) set -- "$args0" ;;
- (2) set -- "$args0" "$args1" ;;
- (3) set -- "$args0" "$args1" "$args2" ;;
- (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
- esac
-fi
-
-# Escape application args
-save () {
- for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
- echo " "
-}
-APP_ARGS=$(save "$@")
-
-# Collect all arguments for the java command, following the shell quoting and substitution rules
-eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
-
-# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
-if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
- cd "$(dirname "$0")"
-fi
-
-exec "$JAVACMD" "$@"
diff --git a/test/istresser/gradlew.bat b/test/istresser/gradlew.bat
deleted file mode 100644
index e95643d..0000000
--- a/test/istresser/gradlew.bat
+++ /dev/null
@@ -1,84 +0,0 @@
-@if "%DEBUG%" == "" @echo off
-@rem ##########################################################################
-@rem
-@rem Gradle startup script for Windows
-@rem
-@rem ##########################################################################
-
-@rem Set local scope for the variables with windows NT shell
-if "%OS%"=="Windows_NT" setlocal
-
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-set APP_BASE_NAME=%~n0
-set APP_HOME=%DIRNAME%
-
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
-
-@rem Find java.exe
-if defined JAVA_HOME goto findJavaFromJavaHome
-
-set JAVA_EXE=java.exe
-%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
-
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:findJavaFromJavaHome
-set JAVA_HOME=%JAVA_HOME:"=%
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-
-if exist "%JAVA_EXE%" goto init
-
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:init
-@rem Get command-line arguments, handling Windows variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-
-:execute
-@rem Setup the command line
-
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
-
-@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
-
-:end
-@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
-
-:fail
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
-rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
-
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
-
-:omega
diff --git a/test/istresser/modules.xml b/test/istresser/modules.xml
deleted file mode 100644
index 7ab309e..0000000
--- a/test/istresser/modules.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
- <component name="ProjectModuleManager">
- <modules>
- <module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
- <module fileurl="file://$PROJECT_DIR$/istresser.iml" filepath="$PROJECT_DIR$/istresser.iml" />
- </modules>
- </component>
-</project>
\ No newline at end of file
diff --git a/test/istresser/settings.gradle b/test/istresser/settings.gradle
deleted file mode 100644
index e7b4def..0000000
--- a/test/istresser/settings.gradle
+++ /dev/null
@@ -1 +0,0 @@
-include ':app'
diff --git a/test/memoryadvice/.gitignore b/test/memoryadvice/.gitignore
deleted file mode 100644
index bb83369..0000000
--- a/test/memoryadvice/.gitignore
+++ /dev/null
@@ -1,18 +0,0 @@
-*.iml
-.gradle
-/app/.cxx
-/local.properties
-/.idea/caches
-/.idea/libraries
-/.idea/modules.xml
-/.idea/workspace.xml
-/.idea/navEditor.xml
-/.idea/assetWizardSettings.xml
-.DS_Store
-/build
-/captures
-/caches
-/codeStyles
-/libraries
-/shelf
-.externalNativeBuild
diff --git a/test/memoryadvice/README.md b/test/memoryadvice/README.md
deleted file mode 100644
index ec9d08a..0000000
--- a/test/memoryadvice/README.md
+++ /dev/null
@@ -1,629 +0,0 @@
-# About the library
-
-The Android Memory Assistance API is an experimental library to help
-applications avoid exceeding safe limits of memory use on devices. It can be
-considered an alternative to using
-[onTrimMemory](https://developer.android.com/reference/android/content/ComponentCallbacks2#onTrimMemory\(int\))
-events to manage memory limits.
-
-It provides an estimate of the percentage of potential total memory resources
-used at that moment.
-
-# Specifics and limitations
-
-The library is compatible with API level 19 (Android 4.4 / KitKat) and higher.
-The library gathers metrics from a few different sources but has no special
-access to the Android OS. These sources already available to apps, but not all
-will be familiar to developers. The library is standalone with no dependencies
-beyond the Android SDK
-
-The metric sources available are currently:
-
-* The file `/proc/meminfo` for values such as `Active`, `Active(anon)`.
- `Active(file)`, `AnonPages`, `MemAvailable`, `MemFree`, `VmData`, `VmRSS`,
- `CommitLimit`, `HighTotal`, `LowTotal` and `MemTotal`.
-
-* The file `/proc/(pid)/status` for values such as `VmRSS` and `VmSize`.
-
-* `ActivityManager.getMemoryInfo()` for values such as `totalMem`,
- `threshold`, `availMem` and `lowmemory`.
-
-* The file `/proc/(pid)/oom_score`
-
-* `Debug.getNativeHeapAllocatedSize()`
-
-* `ActivityManager.getProcessMemoryInfo()`. It is not recommended for
- real-time use due to the high cost of calls and being rate throttled to one
- call per five minutes on newer devices.
-
-These signals are combined with a machine learning model trained from real user
-devices in order to generate the usage estimate.
-
-The library is only intended for use while applications are running in the
-foreground (currently operated by users). (In the event that the application is
-put into the background, this will be reported in the `MemoryState`.)
-
-"Memory" means specifically native heap memory allocated by malloc, and graphics
-memory allocated by the OpenGL ES and Vulkan Graphics APIs. (Note: Memory is
-only one limit affecting graphics use; for example, the number of active GL
-allocations is limited to the value `vm.max_map_count` (65536 on most devices).
-However, memory is the only resource that this library attempts to track.)
-
-If the preferred metrics or suitable lab readings are not available on any
-device for some reason, then alternatives will be used instead.
-
-The advice is given on a best effort basis without guarantees. The methods used
-to generate this advice are quite simple. The library was built having studied
-all available signals to determine which ones act as reliable predictors of
-memory overload. The value added by the library is that these methods have been
-found in lab tests to be effective,
-
-The library is experimental until the assumption is proven that devices will
-behave similarly to other devices with the same hardware and version of Android.
-
-The API is intended for use by native applications (i.e., applications that are
-written primarily in C/C++) but is itself written in Java. (As long as Android
-platform calls are needed, such as those based on ActivityManager, some Java
-components will be required in the library.)
-
-Currently the API will not work effectively for applications that run in 32 bit
-mode on devices that have 64 bit mode available (in other words where 32 bit
-mode is "forced"). This is because the stress tests that calibrate the library
-are run in 64 bit mode wherever available.
-
-# API capabilities
-
-The API can be called at any time to discover:
-
-* A memory warning signal that indicates whether significant allocation should
- stop ("yellow"), or memory should be freed ("red").
-
-* A collection of raw memory metrics that can be captured for diagnostic
- purposes.
-
-The library offers an optional class `MemoryWatcher` that can perform the task
-of polling the `MemoryAdvisor` on behalf of the application; calling back the
-application when the advice state changes at a rate selected by the application.
-
-Otherwise, the choice of polling rate is left to the developer, to strike the
-correct balance between calling cost (this varies significantly by device but
-the ballpark is between 1 and 3 ms per call) and the rate of memory allocation
-performed by the app (higher rate allows a more timely reaction to warnings ).
-The API does not cache or rate limit, nor does it use a timer or other thread
-mechanism.
-
-All this information is provided as a Java map to allow easy integration across
-language barriers, C++, Java, and in the case of Unity projects, C# and to allow
-capture of all data using telemetry for diagnostic purposes without devising a
-separate schema for the telemetry.
-
-The library provides methods that can be called to get simple recommendations
-from the map returned. However, as long as the library is experimental, this
-interface is not guaranteed to be stable.
-
-# Recommended strategies
-
-The library will only be of use if client applications can vary the amount of
-memory used. The variation could take the form of model detail, texture detail,
-optional enhancements such as particle effects or shadows. Audio assets could be
-reduced in fidelity, or dropped entirely.
-
-Games must be able to vary memory used at startup, at runtime, or both.
-
-## Startup strategies
-
-If the application has a range of increasing quality assets and can estimate the
-memory footprint of each option, it can query the library for the estimated
-amount of memory remaining and select the best quality options that fit. Models
-of increasing detail could be loaded until the yellow signal was received. At
-this point, the application could stop increasing the quality of assets to avoid
-making further significant allocations.
-
-## Runtime strategies
-
-Games could react to the "red" signal by unloading assets such as audio,
-particle effects, or shadows, reducing screen resolution, or reducing texture
-resolution. These can be restored when no more memory warnings (including
-"yellow" signal) are received.
-
-# Limitations of estimates
-
-Specific memory quantity estimates are currently a highly experimental part of
-the library, as estimates may be inaccurate for combinations of devices that we
-have not seen in lab testing.
-
-They may suggest a lower limit than can be allocated by an application in
-practice, because:
-
-* Different types of memory allocation (e.g. heap allocation vs allocation via
- graphics API) experience different limits, MB for MB. The library is
- pessimistic so will report the lower figure.
-
-* The memory advice library is pessimistic about the effects of zram
- compression on memory availability. Allocated memory that is both rarely
- used, and has compressible contents (e.g. contains repeated data) can be
- compressed by [zram](https://en.wikipedia.org/wiki/Zram) on Android. In
- extreme cases this could even result in apps apparently allocating more
- memory that was actually present on the device.
-
-The estimate is of remaining memory to allocate. This may change over time
-affected by other activity on the device. After memory has been allocated by the
-app, further calls may receive more accurate results than calls made at the
-start of the app's lifetime.
-
-# API specifics
-
-## Adding the library to an Android project
-
-The library is published on
-[Google's Maven repository](https://maven.google.com/web/index.html?q=com.google.android.games#com.google.android.games:memory-advice:0.25).
-
-In the application root `build.gradle` file, ensure `google()` is specified as a
-repository for the project, as well as `jitpack.io` for some of its
-dependencies. For example:
-
-```gradle
-allprojects {
- repositories {
- google()
- mavenCentral()
- maven {
- url 'https://jitpack.io'
- }
- }
-}
-```
-
-In the application module's `build.gradle` file, add an `implementation` line to
-the `dependencies` section:
-
-```gradle
-dependencies {
- // ..
- implementation 'com.google.android.games:memory-advice:0.25'
-
-}
-```
-
-Since the library has *AndroidX* dependencies, it is necessary to enable
-*AndroidX* in the application, if it is not already. Instructions can be
-[found here](https://developer.android.com/jetpack/androidx/migrate).
-
-### Building the library from source
-
-If you prefer to build your own version of the library, get the
-[repo tool](https://gerrit.googlesource.com/git-repo/) and sync the Games SDK
-project
-[games-sdk project](https://android.googlesource.com/platform/frameworks/opt/gamesdk/+/refs/heads/master);
-
-```bash
-repo init -u https://android.googlesource.com/platform/manifest -b my-branch
-```
-
-Built with `gradle publishToMavenLocal` and add `mavenLocal()` to `repositories`
-in the `build.gradle` of clients.
-
-### Code
-
-In your main activity, initialize a single memoryAdviser object for the lifetime
-of your app.
-
-```java
-import android.app.Activity;
-import android.os.Bundle;
-import com.google.android.apps.internal.games.memoryadvice.MemoryAdvisor;
-
-class MyActivity extends Activity {
- private MemoryAdvisor memoryAdvisor;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- // ...
- memoryAdvisor = new MemoryAdvisor(this);
- }
-}
-```
-
-At some frequency, call the memory advisor to get recommendations. The choice of
-frequency should reflect the cost of calling `getAdvice()`; approximately 5 to
-20 milliseconds per call.
-
-```java
-import android.app.Activity;
-import com.google.android.apps.internal.games.memoryadvice.MemoryAdvisor;
-
-class MyActivity extends Activity {
- private MemoryAdvisor memoryAdvisor;
- // ...
- void myMethod() {
- Map<String, Object> advice = memoryAdvisor.getAdvice();
- // ...
- }
-}
-```
-
-One option is to call the library back with the object to interpret the
-recommendations.
-
-```java
-import android.app.Activity;
-import com.google.android.apps.internal.games.memoryadvice.MemoryAdvisor;
-
-class MyActivity extends Activity {
- private MemoryAdvisor memoryAdvisor;
- // ...
- void myMethod() {
- Map<String, Object> advice = memoryAdvisor.getAdvice();
- MemoryAdvisor.MemoryState memoryState = MemoryAdvisor.getMemoryState(advice);
- switch (memoryState) {
- case OK:
- // The application can safely allocate significant memory.
- break;
- case APPROACHING_LIMIT:
- // The application should not allocate significant memory.
- break;
- case CRITICAL:
- // The application should free memory as soon as possible, until the memory state changes.
- break;
- case BACKGROUNDED:
- // The application has been put into the background.
- break;
- }
- }
-}
-```
-
-Another options is to initialize a `MemoryWatcher` object. This will call back
-the application when the memory warning changes. In this example the fixed
-sample rate is 1/4 second, or 250 milliseconds.
-
-```java
-import android.app.Activity;
-import com.google.android.apps.internal.games.memoryadvice.MemoryAdvisor;
-import com.google.android.apps.internal.games.memoryadvice.MemoryWatcher;
-import java.util.Map;
-
-class MyActivity extends Activity {
- private MemoryAdvisor memoryAdvisor;
- // ...
- void myMethod() {
- Map<String, Object> advice = memoryAdvisor.getAdvice();
- MemoryWatcher memoryWatcher =
- new MemoryWatcher(memoryAdvisor, 250, new MemoryWatcher.DefaultClient() {
- @Override
- public void newState(MemoryAdvisor.MemoryState memoryState) {
- switch (memoryState) {
- case OK:
- // The application can safely allocate significant memory.
- break;
- case APPROACHING_LIMIT:
- // The application should not allocate significant memory.
- break;
- case CRITICAL:
- // The application should free memory as soon as possible, until the memory state
- // changes.
- break;
- case BACKGROUNDED:
- // The application has been put into the background.
- break;
- }
- }
- });
- }
-}
-```
-
-Call the library back with the object to get an estimate in bytes of the memory
-that can safely be allocated by the application.
-
-```java
-import android.app.Activity;
-import com.google.android.apps.internal.games.memoryadvice.MemoryAdvisor;
-
-class MainActivity extends Activity {
- private MemoryAdvisor memoryAdvisor;
- // ...
- void myMethod() {
- Map<String, Object> advice = memoryAdvisor.getAdvice();
- long availabilityEstimate = MemoryAdvisor.availabilityEstimate(advice);
- // ...
- }
-}
-```
-
-## Telemetry / debugging info
-
-Logging and debugging telemetry can be obtained from the advisor object.
-Information about the device itself:
-
-```java
-import android.app.Activity;
-import android.os.Bundle;
-import com.google.android.apps.internal.games.memoryadvice.MemoryAdvisor;
-
-class MyActivity extends Activity {
- private MemoryAdvisor memoryAdvisor;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- // ...
- memoryAdvisor = new MemoryAdvisor(this);
- Map<String, Object> deviceInfo = memoryAdvisor.getDeviceInfo(MainActivity.this);
- // Now convert the deviceInfo to a string and log it.
- }
-}
-```
-
-The data returned by `getAdvice()`:
-
-```java
-import android.app.Activity;
-import com.google.android.apps.internal.games.memoryadvice.MemoryAdvisor;
-
-class MyActivity extends Activity {
- private MemoryAdvisor memoryAdvisor;
- // ...
- void myMethod() {
- Map<String, Object> advice = memoryAdvisor.getAdvice();
- // Now convert the advice object to a string and log it.
- }
-}
-```
-
-## Unity integration
-
-1. In Android Studio, build the library
- [memoryadvice](https://android.googlesource.com/platform/frameworks/opt/gamesdk/+/refs/heads/master/test/memoryadvice/).
-2. Drag the generated AAR (e.g.
- `gamesdk/test/memoryadvice/memoryadvice/build/outputs/aar/memoryadvice-debug.aar`)
- into the Assets folder of your Unity project. See
- [Unity instructions](https://docs.unity3d.com/Manual/AndroidAARPlugins.html)
- for including Android libraries in projects.
-3. Optional: add the
- [JSON Object package](https://assetstore.unity.com/packages/tools/input-management/json-object-710)
- to your Unity project.
-4. Copy
- [UnityMemoryHandler.cs](https://android.googlesource.com/platform/frameworks/opt/gamesdk/+/refs/heads/master/test/unitymemory/UnityMemoryHandler.cs)
- and drag the script into the Scripts folder of your Unity project.
-5. Create a new Game Object in your game scene, and drag the
- `UnityMemoryHandler.cs` script from your Assets folder to the new Game
- Object to associate it with the script.
-6. Customize the script as required.
-
-## Reporting bugs
-
-Email [jimblackler@google.com](mailto:jimblackler@google.com) Please include the
-output from memoryAdvisor.getDeviceInfo().toString().
-
-# Appendix
-
-## Metrics groups
-
-This is a comprehensive list of all the memory groups available, and the metrics
-contained in those groups.
-
-### "debug"
-
-Metrics obtained from `android.os.debug`.
-
-* `nativeHeapAllocatedSize`
-
- From `Debug.getNativeHeapAllocatedSize()`
-
-* `NativeHeapFreeSize`
-
- From `Debug.getNativeHeapFreeSize()`
-
-* `NativeHeapSize`
-
- From `Debug.getNativeHeapSize()`
-
-* `Pss`
-
- From `Debug.getNativeHeapSize()`
-
-#### Timing
-
-Average 0.388 milliseconds.
-
-### "MemoryInfo"
-
-Metrics obtained from `android.app.ActivityManager.MemoryInfo`.
-
-* `availMem`
-
- From `memoryInfo.availMem`
-
-* `lowMemory`
-
- From `memoryInfo.lowMemory`
-
-* `totalMem`
-
- From `memoryInfo.totalMem`
-
-* `threshold`
-
- From `memoryInfo.threshold`
-
-#### Timing
-
-Average 0.907 milliseconds.
-
-### "ActivityManager"
-
-From `android.app.ActivityManager`.
-
-* `MemoryClass`
-
- From `activityManager.getMemoryClass()`
-
-* `LargeMemoryClass`
-
- From `activityManager.getLargeMemoryClass()`
-
-* `LowRamDevice`
-
- From `activityManager.isLowRamDevice()`
-
-These values are all constant so only taken at startup.
-
-### "proc"
-
-* `oom_score`
-
- From `proc/oom_score`.
-
-#### Timing
-
-Average 0.711 milliseconds.
-
-### "summary"
-
-From `android.os.Debug.MemoryInfo[]`.
-
-This metric group is not recommended for use as it is very expensive to obtain
-and is only availble in a throttled form on newer Android versions.
-
-All fields via `android.app.ActivityManager.getProcessMemoryInfo`
-
-* `summary.java-heap`
-
-* `summary.native-heap`
-
-* `summary.code`
-
-* `summary.stack`
-
-* `summary.graphics`
-
-* `summary.private-other`
-
-* `summary.system`
-
-* `summary.total-pss`
-
-* `summary.total-swap`
-
-#### Timing
-
-Average 76.485 milliseconds.
-
-### "memInfo"
-
-From `/proc/meminfo`.
-
-Fields are different per device, but examples include:
-
-* `Active`
-
-* `Active(anon)`
-
-* `Active(file)`
-
-* `AnonPages`
-
-* `Bounce`
-
-* `Buffers`
-
-* `Cached`
-
-* `CmaTotal`
-
-* `CommitLimit`
-
-* `Committed_AS`
-
-* `Dirty`
-
-* `Inactive`
-
-* `Inactive(anon)`
-
-* `Inactive(file)`
-
-* `KernelStack`
-
-* `Mapped`
-
-* `MemAvailable`
-
-* `MemFree`
-
-* `MemTotal`
-
-* `Mlocked`
-
-* `NFS_Unstable`
-
-* `PageTables`
-
-* `SReclaimable`
-
-* `SUnreclaim`
-
-* `Shmem`
-
-* `Slab`
-
-* `SwapCached`
-
-* `SwapFree`
-
-* `SwapTotal`
-
-* `Unevictable`
-
-* `VmallocChunk`
-
-* `VmallocTotal`
-
-* `VmallocUsed`
-
-* `Writeback`
-
-* `WritebackTmp`
-
-#### Timing
-
-Average 3.313 milliseconds.
-
-### "status"
-
-From `/proc/(pid)/status`.
-
-Fields are different per device, but examples include:
-
-* `VmData`
-
-* `VmExe`
-
-* `VmHWM`
-
-* `VmLck`
-
-* `VmLib`
-
-* `VmPMD`
-
-* `VmPTE`
-
-* `VmPeak`
-
-* `VmPin`
-
-* `VmRSS`
-
-* `VmSize`
-
-* `VmStk`
-
-* `VmSwap`
-
-#### Timing
-
-Average 4.318 milliseconds.
-
-### Notes on timing
-
-Figures are based on 150+ lab devices, excluding outlier. The measurement is the
-average time it takes for the library to obtain all these metrics.
diff --git a/test/memoryadvice/build.gradle b/test/memoryadvice/build.gradle
deleted file mode 100644
index cdac029..0000000
--- a/test/memoryadvice/build.gradle
+++ /dev/null
@@ -1,28 +0,0 @@
-// Top-level build file where you can add configuration options common to all sub-projects/modules.
-
-buildscript {
-
- repositories {
- google()
- mavenCentral()
-
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:4.2.2'
-
- // NOTE: Do not place your application dependencies here; they belong
- // in the individual module build.gradle files
- }
-}
-
-allprojects {
- repositories {
- google()
- mavenCentral()
- maven { url 'https://jitpack.io' }
- }
-}
-
-task clean(type: Delete) {
- delete rootProject.buildDir
-}
diff --git a/test/memoryadvice/build.sh b/test/memoryadvice/build.sh
deleted file mode 100755
index 1c2efb6..0000000
--- a/test/memoryadvice/build.sh
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/bin/bash
-set -e # Exit on error
-export ANDROID_HOME=`pwd`/../../../prebuilts/sdk
-export ANDROID_NDK_HOME=`pwd`/../../../prebuilts/ndk/r17
-mkdir "$ANDROID_HOME/licenses" || true
-echo "d56f5187479451eabf01fb78af6dfcb131a6481e" > "$ANDROID_HOME/licenses/android-sdk-license"
-echo "24333f8a63b6825ea9c5514f83c2829b004d1fee" >> "$ANDROID_HOME/licenses/android-sdk-license"
-
-pushd memoryadvice_common
-../gradlew build publishToMavenLocal
-popd
-
-pushd memoryadvice
-../gradlew build publishToMavenLocal
-popd
-
-pushd memorytest
-../gradlew build publishToMavenLocal
-popd
\ No newline at end of file
diff --git a/test/memoryadvice/gradle.properties b/test/memoryadvice/gradle.properties
deleted file mode 100644
index 199d16e..0000000
--- a/test/memoryadvice/gradle.properties
+++ /dev/null
@@ -1,20 +0,0 @@
-# Project-wide Gradle settings.
-# IDE (e.g. Android Studio) users:
-# Gradle settings configured through the IDE *will override*
-# any settings specified in this file.
-# For more details on how to configure your build environment visit
-# http://www.gradle.org/docs/current/userguide/build_environment.html
-# Specifies the JVM arguments used for the daemon process.
-# The setting is particularly useful for tweaking memory settings.
-org.gradle.jvmargs=-Xmx1536m
-# When configured, Gradle will run in incubating parallel mode.
-# This option should only be used with decoupled projects. More details, visit
-# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
-# org.gradle.parallel=true
-# AndroidX package structure to make it clearer which packages are bundled with the
-# Android operating system, and which are packaged with your app's APK
-# https://developer.android.com/topic/libraries/support-library/androidx-rn
-android.useAndroidX=true
-# Automatically convert third-party libraries to use AndroidX
-android.enableJetifier=true
-
diff --git a/test/memoryadvice/gradle/wrapper/gradle-wrapper.properties b/test/memoryadvice/gradle/wrapper/gradle-wrapper.properties
deleted file mode 100644
index dd70d80..0000000
--- a/test/memoryadvice/gradle/wrapper/gradle-wrapper.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-#Tue Jul 07 18:13:03 BST 2020
-distributionBase=GRADLE_USER_HOME
-distributionPath=wrapper/dists
-zipStoreBase=GRADLE_USER_HOME
-zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
diff --git a/test/memoryadvice/memoryadvice/.gitignore b/test/memoryadvice/memoryadvice/.gitignore
deleted file mode 100644
index a991ad6..0000000
--- a/test/memoryadvice/memoryadvice/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-/build
-/debug
-.cxx
\ No newline at end of file
diff --git a/test/memoryadvice/memoryadvice/build.gradle b/test/memoryadvice/memoryadvice/build.gradle
deleted file mode 100644
index f072060..0000000
--- a/test/memoryadvice/memoryadvice/build.gradle
+++ /dev/null
@@ -1,91 +0,0 @@
-plugins {
- id 'com.android.library'
- id 'maven-publish'
-}
-
-android {
- compileSdkVersion 29
-
- defaultConfig {
- minSdkVersion 19
- versionCode 9
- // LINT.IfChange
- versionName '0.25'
- // LINT.ThenChange(../README.md)
- multiDexEnabled true
- testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
- }
-
- externalNativeBuild {
- cmake {
- path "src/main/cpp/CMakeLists.txt"
- }
- }
-
- compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_8
- targetCompatibility JavaVersion.VERSION_1_8
- }
-
- buildTypes {
- debug {
- testCoverageEnabled true
- }
- }
-}
-
-dependencies {
- implementation project(path: ':memoryadvice_common')
- implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
- implementation 'androidx.multidex:multidex:2.0.1'
- implementation 'com.fasterxml.jackson.core:jackson-databind:2.12.2'
- implementation 'org.tensorflow:tensorflow-lite:2.4.0'
- androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
- androidTestImplementation 'androidx.test.ext:junit:1.1.2'
- androidTestImplementation 'com.google.guava:guava:30.1.1-android'
- androidTestImplementation 'net.jimblackler.jsonschemafriend:core:0.10.5'
-}
-
-task sourceJar(type: Jar) {
- from android.sourceSets.main.java.srcDirs
- classifier 'sources'
-}
-
-task javadoc(type: Javadoc) {
- source = android.sourceSets.main.java.srcDirs
- exclude "**/AndroidManifest.xml"
- failOnError false
-}
-
-task javadocJar(type: Jar, dependsOn: javadoc) {
- from javadoc.destinationDir
- classifier 'javadoc'
-}
-
-afterEvaluate {
- publishing {
- publications {
- release(MavenPublication) {
- from components.release
- groupId = 'com.google.android.games'
- artifactId = 'memory-advice'
- version = android.defaultConfig.versionName
- artifact(sourceJar)
- artifact(javadocJar)
- pom {
- name = 'The Android Memory Assistance API'
- url = 'https://android.googlesource.com/platform/frameworks/opt/gamesdk/+/refs/heads/master/test/memoryadvice'
- description = 'An experimental library to help applications avoid exceeding ' +
- 'safe limits of memory use on devices.'
- licenses {
- license {
- name = 'The Apache Software License, Version 2.0'
- url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
- distribution = 'repo'
- }
- }
- }
- }
- }
- }
-}
diff --git a/test/memoryadvice/memoryadvice/src/androidTest/java/com/google/android/apps/internal/games/memoryadvice/AdvisorTest.java b/test/memoryadvice/memoryadvice/src/androidTest/java/com/google/android/apps/internal/games/memoryadvice/AdvisorTest.java
deleted file mode 100644
index d9110d9..0000000
--- a/test/memoryadvice/memoryadvice/src/androidTest/java/com/google/android/apps/internal/games/memoryadvice/AdvisorTest.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package com.google.android.apps.internal.games.memoryadvice;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-
-import androidx.test.ext.junit.runners.AndroidJUnit4;
-import androidx.test.platform.app.InstrumentationRegistry;
-import com.google.android.apps.internal.games.memoryadvice_common.Schemas;
-import com.google.common.collect.ImmutableMap;
-import java.util.Map;
-import net.jimblackler.jsonschemafriend.GenerationException;
-import net.jimblackler.jsonschemafriend.Schema;
-import net.jimblackler.jsonschemafriend.SchemaException;
-import net.jimblackler.jsonschemafriend.SchemaStore;
-import net.jimblackler.jsonschemafriend.Validator;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-@RunWith(AndroidJUnit4.class)
-public class AdvisorTest {
- private final Validator validator;
- private final Schema advisorParametersSchema;
-
- public AdvisorTest() throws GenerationException {
- SchemaStore schemaStore = new SchemaStore();
- advisorParametersSchema =
- schemaStore.loadSchema(Schemas.getSchema("advisorParameters.schema.json"));
- validator = new Validator();
- }
-
- @Test
- public void intitialize() throws SchemaException {
- ImmutableMap<String, Object> params =
- ImmutableMap.of("metrics", ImmutableMap.of("baseline", ImmutableMap.of()));
- validator.validate(advisorParametersSchema, params);
- MemoryAdvisor memoryAdvisor =
- new MemoryAdvisor(InstrumentationRegistry.getInstrumentation().getTargetContext(), params);
- }
-
- @Test
- public void predictRealtime() throws SchemaException {
- ImmutableMap<String, Object> params = ImmutableMap.of("metrics",
- ImmutableMap.of("baseline", ImmutableMap.of("debug", true, "meminfo", true, "status", true),
- "variable", ImmutableMap.of("predictRealtime", true, "debug", true, "proc", true)));
- validator.validate(advisorParametersSchema, params);
- MemoryAdvisor memoryAdvisor =
- new MemoryAdvisor(InstrumentationRegistry.getInstrumentation().getTargetContext(), params);
- Map<String, Object> advice = memoryAdvisor.getAdvice();
- Map<String, Object> metrics = (Map<String, Object>) advice.get("metrics");
- assertThat(metrics.containsKey("predictedUsage"), is(true));
- }
-
- @Test
- public void availableRealtime() throws SchemaException {
- ImmutableMap<String, Object> params = ImmutableMap.of("metrics",
- ImmutableMap.of("constant",
- ImmutableMap.of("ActivityManager", true, "MemoryInfo", true, "meminfo", true),
- "baseline",
- ImmutableMap.of(
- "debug", true, "meminfo", true, "proc", true, "status", true, "MemoryInfo", true),
- "variable", ImmutableMap.of("availableRealtime", true, "debug", true, "proc", true)));
- validator.validate(advisorParametersSchema, params);
- MemoryAdvisor memoryAdvisor =
- new MemoryAdvisor(InstrumentationRegistry.getInstrumentation().getTargetContext(), params);
- Map<String, Object> advice = memoryAdvisor.getAdvice();
- Map<String, Object> metrics = (Map<String, Object>) advice.get("metrics");
- assertThat(metrics.containsKey("predictedAvailable"), is(true));
- }
-}
\ No newline at end of file
diff --git a/test/memoryadvice/memoryadvice/src/androidTest/java/com/google/android/apps/internal/games/memoryadvice/GetMemoryMetricsTest.java b/test/memoryadvice/memoryadvice/src/androidTest/java/com/google/android/apps/internal/games/memoryadvice/GetMemoryMetricsTest.java
deleted file mode 100644
index 11495f7..0000000
--- a/test/memoryadvice/memoryadvice/src/androidTest/java/com/google/android/apps/internal/games/memoryadvice/GetMemoryMetricsTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package com.google.android.apps.internal.games.memoryadvice;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.IsNull.notNullValue;
-
-import androidx.test.ext.junit.runners.AndroidJUnit4;
-import androidx.test.platform.app.InstrumentationRegistry;
-import com.google.android.apps.internal.games.memoryadvice_common.Schemas;
-import com.google.common.collect.ImmutableMap;
-import java.util.Map;
-import net.jimblackler.jsonschemafriend.GenerationException;
-import net.jimblackler.jsonschemafriend.Schema;
-import net.jimblackler.jsonschemafriend.SchemaException;
-import net.jimblackler.jsonschemafriend.SchemaStore;
-import net.jimblackler.jsonschemafriend.ValidationException;
-import net.jimblackler.jsonschemafriend.Validator;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-@RunWith(AndroidJUnit4.class)
-public class GetMemoryMetricsTest {
- private final Validator validator;
- private final Schema monitorParametersSchema;
-
- public GetMemoryMetricsTest() throws GenerationException {
- SchemaStore schemaStore = new SchemaStore();
- monitorParametersSchema =
- schemaStore.loadSchema(Schemas.getSchema("monitorParameters.schema.json"));
- validator = new Validator();
- }
-
- @Test
- public void debugStats() throws SchemaException {
- ImmutableMap<String, Object> variable = ImmutableMap.of("debug", true);
- Map<String, Object> metrics = getMetrics(variable);
- Map<String, Object> debug = (Map<String, Object>) metrics.get("debug");
- assertThat(debug, notNullValue());
- assertThat(debug.get("NativeHeapAllocatedSize"), notNullValue());
- }
-
- private Map<String, Object> getMetrics(ImmutableMap<String, Object> variable)
- throws ValidationException {
- ImmutableMap<String, Object> metrics =
- ImmutableMap.of("variable", variable, "baseline", ImmutableMap.of());
- validator.validate(monitorParametersSchema, metrics);
- MemoryMonitor memoryMonitor =
- new MemoryMonitor(InstrumentationRegistry.getInstrumentation().getTargetContext(), metrics);
- return memoryMonitor.getMemoryMetrics(variable);
- }
-}
\ No newline at end of file
diff --git a/test/memoryadvice/memoryadvice/src/androidTest/java/com/google/android/apps/internal/games/memoryadvice/MonitorTest.java b/test/memoryadvice/memoryadvice/src/androidTest/java/com/google/android/apps/internal/games/memoryadvice/MonitorTest.java
deleted file mode 100644
index 9adca9c..0000000
--- a/test/memoryadvice/memoryadvice/src/androidTest/java/com/google/android/apps/internal/games/memoryadvice/MonitorTest.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package com.google.android.apps.internal.games.memoryadvice;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.greaterThan;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.lessThan;
-import static org.hamcrest.Matchers.notNullValue;
-
-import androidx.test.ext.junit.runners.AndroidJUnit4;
-import androidx.test.platform.app.InstrumentationRegistry;
-import com.google.android.apps.internal.games.memoryadvice_common.Schemas;
-import com.google.common.collect.ImmutableMap;
-import java.util.Map;
-import net.jimblackler.jsonschemafriend.GenerationException;
-import net.jimblackler.jsonschemafriend.Schema;
-import net.jimblackler.jsonschemafriend.SchemaException;
-import net.jimblackler.jsonschemafriend.SchemaStore;
-import net.jimblackler.jsonschemafriend.Validator;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-@RunWith(AndroidJUnit4.class)
-public class MonitorTest {
- private final Validator validator;
- private final Schema monitorParametersSchema;
- private final Schema metricsResultsSchema;
-
- public MonitorTest() throws GenerationException {
- SchemaStore schemaStore = new SchemaStore();
- monitorParametersSchema =
- schemaStore.loadSchema(Schemas.getSchema("monitorParameters.schema.json"));
- metricsResultsSchema = schemaStore.loadSchema(Schemas.getSchema("metricsResults.schema.json"));
- validator = new Validator();
- }
-
- @Test
- public void nullFields() throws SchemaException {
- ImmutableMap<String, Object> params = ImmutableMap.of();
- validator.validate(monitorParametersSchema, params);
- MemoryMonitor memoryMonitor =
- new MemoryMonitor(InstrumentationRegistry.getInstrumentation().getTargetContext(), null);
-
- Map<String, Object> memoryMetrics = memoryMonitor.getMemoryMetrics(null);
- validator.validate(metricsResultsSchema, memoryMetrics);
-
- // The only data we are guaranteed to get back is the sample time.
- Map<String, Object> meta = (Map<String, Object>) memoryMetrics.get("meta");
- assertThat(meta, notNullValue());
- assertThat(meta.containsKey("time"), is(true));
- }
-}
\ No newline at end of file
diff --git a/test/memoryadvice/memoryadvice/src/androidTest/java/com/google/android/apps/internal/games/memoryadvice/UtilsTest.java b/test/memoryadvice/memoryadvice/src/androidTest/java/com/google/android/apps/internal/games/memoryadvice/UtilsTest.java
deleted file mode 100644
index 2af93b4..0000000
--- a/test/memoryadvice/memoryadvice/src/androidTest/java/com/google/android/apps/internal/games/memoryadvice/UtilsTest.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package com.google.android.apps.internal.games.memoryadvice;
-
-import static com.google.android.apps.internal.games.memoryadvice.Utils.processMemFormatFile;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.greaterThan;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.lessThan;
-
-import androidx.test.ext.junit.runners.AndroidJUnit4;
-import java.util.HashMap;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-@RunWith(AndroidJUnit4.class)
-public class UtilsTest {
- static final int BYTES_IN_KILOBYTE = 1024;
- static final int BYTES_IN_MEGABYTE = BYTES_IN_KILOBYTE * 1024;
- static final int BYTES_IN_GIGABYTE = BYTES_IN_MEGABYTE * 1024;
-
- @Test
- public void testProcessMemFormatFile() {
- HashMap<String, Long> output = new HashMap<>();
- processMemFormatFile("/proc/meminfo", output::put);
- // There's no CTS definition of what should be in proc/meminfo but we can expect MemTotal to be
- // there and to have a value between 500K and 100G.
- assertThat(output.containsKey("MemTotal"), is(true));
- long memTotal = output.get("MemTotal");
- assertThat(memTotal, greaterThan(500L * BYTES_IN_KILOBYTE));
- assertThat(memTotal, lessThan(100L * BYTES_IN_GIGABYTE));
- }
-}
\ No newline at end of file
diff --git a/test/memoryadvice/memoryadvice/src/main/AndroidManifest.xml b/test/memoryadvice/memoryadvice/src/main/AndroidManifest.xml
deleted file mode 100644
index a45659d..0000000
--- a/test/memoryadvice/memoryadvice/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.google.android.apps.internal.games.memoryadvice">
- <uses-permission android:name="android.permission.INTERNET" />
- <application>
- <service android:name="com.google.android.apps.internal.games.memoryadvice.CanaryService"
- android:process=":com.google.android.apps.internal.games.memoryadvice.CanaryProcess" />
- </application>
-</manifest>
diff --git a/test/memoryadvice/memoryadvice/src/main/cpp/CMakeLists.txt b/test/memoryadvice/memoryadvice/src/main/cpp/CMakeLists.txt
deleted file mode 100644
index e2f9216..0000000
--- a/test/memoryadvice/memoryadvice/src/main/cpp/CMakeLists.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-cmake_minimum_required(VERSION 3.4.1)
-
-add_library(
- try-alloc-lib
- SHARED
- try-alloc.cc)
-
-target_link_libraries(
- try-alloc-lib)
diff --git a/test/memoryadvice/memoryadvice/src/main/cpp/try-alloc.cc b/test/memoryadvice/memoryadvice/src/main/cpp/try-alloc.cc
deleted file mode 100644
index 055cd1b..0000000
--- a/test/memoryadvice/memoryadvice/src/main/cpp/try-alloc.cc
+++ /dev/null
@@ -1,63 +0,0 @@
-// This file provides the native functions for the TryAllocTester.
-
-#include <jni.h>
-#include <stdlib.h>
-
-extern "C" JNIEXPORT jboolean JNICALL
-Java_com_google_android_apps_internal_games_memoryadvice_TryAllocTester_tryAlloc(
- JNIEnv *env, jclass clazz, jint bytes) {
- size_t byte_count = (size_t)bytes;
- char *data = (char *)malloc(byte_count);
- if (data) {
- free(data);
- return true;
- }
- return false;
-}
-
-static constexpr uint32_t kLcgPrime1 = 214013;
-static constexpr uint32_t kLcgPrime2 = 2531011;
-
-/**
- * Fill a specified area of memory with pseudo-random data and verify it was
- * correctly written.
- * @param addr The memory location to begin writing.
- * @param byte_len The number of bytes.
- * @return true if the memory was successfully written and verfied.
- */
-bool LcgFill(void *addr, size_t byte_len) {
- int i = rand();
- uint32_t lcg_current = (uint32_t)i;
- uint32_t *data = (uint32_t *)addr;
- size_t word_len = byte_len / 4;
- for (size_t word_count = 0; word_count < word_len; ++word_count) {
- lcg_current *= kLcgPrime1;
- lcg_current += kLcgPrime2;
- data[word_count] = lcg_current;
- }
- // Read back written data.
- lcg_current = (uint32_t)i;
- for (size_t word_count = 0; word_count < word_len; ++word_count) {
- lcg_current *= kLcgPrime1;
- lcg_current += kLcgPrime2;
- if (data[word_count] != lcg_current) {
- return false;
- }
- }
- return true;
-}
-
-extern "C" JNIEXPORT jboolean JNICALL
-Java_com_google_android_apps_internal_games_memoryadvice_TryAllocTester_occupyMemory(
- JNIEnv *env, jclass clazz, jint bytes) {
- size_t byte_count = (size_t)bytes;
- char *data = (char *)malloc(byte_count);
- if (!data) {
- return false;
- }
- bool filled = LcgFill(data, byte_count);
- if (!filled) {
- free(data);
- }
- return filled;
-}
\ No newline at end of file
diff --git a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/BuildInfo.java b/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/BuildInfo.java
deleted file mode 100644
index bca714b..0000000
--- a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/BuildInfo.java
+++ /dev/null
@@ -1,102 +0,0 @@
-package com.google.android.apps.internal.games.memoryadvice;
-
-import android.content.Context;
-import android.content.pm.FeatureInfo;
-import android.content.pm.PackageManager;
-import android.os.Build;
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-/**
- * A class to provide information about the current Android build to an application in JSON
- * format.
- */
-class BuildInfo {
- private static final String TAG = BuildInfo.class.getSimpleName();
-
- /**
- * Copies the Android build data into a JSON object.
- *
- * @param context The Android context.
- * @return A map containing the Android build data.
- */
- static Map<String, Object> getBuild(Context context) {
- Map<String, Object> build = new LinkedHashMap<>();
- build.put("fields", getStaticFields(Build.class));
- build.put("version", getStaticFields(Build.VERSION.class));
- build.put("features", getFeatures(context));
- build.put("library", getStaticFields(BuildConfig.class));
- build.put("system", getSystem());
- return build;
- }
-
- private static Map<String, Object> getSystem() {
- Map<String, Object> system = new LinkedHashMap<>();
- Properties properties = System.getProperties();
- for (String propertyName : properties.stringPropertyNames()) {
- system.put(propertyName, properties.getProperty(propertyName));
- }
- return system;
- }
-
- /**
- * Use reflection to copy all the static fields from the specified class into a JSON object.
- *
- * @param aClass The class to copy static fields from.
- * @return the fields in a map.
- */
- private static Map<String, Object> getStaticFields(Class<?> aClass) {
- Map<String, Object> object = new LinkedHashMap<>();
- for (Field field : aClass.getFields()) {
- if (!java.lang.reflect.Modifier.isStatic(field.getModifiers())) {
- continue;
- }
- try {
- object.put(field.getName(), field.get(null));
- } catch (IllegalAccessException e) {
- // Silent by design.
- }
- }
- return object;
- }
-
- /**
- * Convert the system features into a map.
- *
- * @param context The current context.
- * @return The system features in a map.
- */
- private static Map<String, Object> getFeatures(Context context) {
- Map<String, Object> features = new LinkedHashMap<>();
- PackageManager packageManager = context.getPackageManager();
-
- Map<String, Object> named = new LinkedHashMap<>();
- List<Object> unnamed = new ArrayList<>();
-
- for (FeatureInfo featureInfo : packageManager.getSystemAvailableFeatures()) {
- Map<String, Object> feature = new LinkedHashMap<>();
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && featureInfo.version != 0) {
- feature.put("version", featureInfo.version);
- }
- if (featureInfo.flags != 0) {
- feature.put("flags", featureInfo.flags);
- }
- if (featureInfo.reqGlEsVersion != FeatureInfo.GL_ES_VERSION_UNDEFINED) {
- feature.put("reqGlEsVersion", featureInfo.reqGlEsVersion);
- }
- if (featureInfo.name == null) {
- unnamed.add(feature);
- } else {
- named.put(featureInfo.name, feature);
- }
- }
- features.put("named", named);
- features.put("unnamed", unnamed);
-
- return features;
- }
-}
diff --git a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/ByteArrayUtils.java b/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/ByteArrayUtils.java
deleted file mode 100644
index f1dda19..0000000
--- a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/ByteArrayUtils.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package com.google.android.apps.internal.games.memoryadvice;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.ByteBuffer;
-
-class ByteArrayUtils {
- /**
- * Copies a stream to a direct byte buffer.
- * @param inputStream An input stream.
- * @return The contents of the stream in a direct byte buffer.
- */
- static ByteBuffer streamToDirectByteBuffer(InputStream inputStream) throws IOException {
- byte[] bytes = streamToByteArray(inputStream);
- ByteBuffer byteBuffer = ByteBuffer.allocateDirect(bytes.length);
- byteBuffer.put(bytes);
- return byteBuffer;
- }
-
- /**
- * Copies a stream to a byte array.
- * @param input An input stream.
- * @return The contents of the stream as a byte array.
- */
- static byte[] streamToByteArray(InputStream input) throws IOException {
- try (ByteArrayOutputStream output = new ByteArrayOutputStream()) {
- byte[] buffer = new byte[1024];
- int bytesRead;
- while ((bytesRead = input.read(buffer)) != -1) {
- output.write(buffer, 0, bytesRead);
- }
- return output.toByteArray();
- }
- }
-}
diff --git a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/CanaryProcessTester.java b/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/CanaryProcessTester.java
deleted file mode 100644
index 9e0664f..0000000
--- a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/CanaryProcessTester.java
+++ /dev/null
@@ -1,60 +0,0 @@
-package com.google.android.apps.internal.games.memoryadvice;
-
-import static com.google.android.apps.internal.games.memoryadvice_common.ConfigUtils.getMemoryQuantity;
-import static com.google.android.apps.internal.games.memoryadvice_common.ConfigUtils.getOrDefault;
-
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.ServiceConnection;
-import android.os.IBinder;
-import android.util.Log;
-import java.util.Map;
-
-/**
- * A method of predicting critical memory pressure ahead of time, by creating a service that
- * allocates a significant quantity of memory, that will be killed by the system when memory is
- * becoming scarce. This occurrence can be detected easily as the connection will be disconnected.
- */
-class CanaryProcessTester {
- private static final String TAG = CanaryProcessTester.class.getSimpleName();
-
- private final Context context;
- private final Map<String, Object> params;
- private ServiceConnection serviceConnection;
-
- CanaryProcessTester(Context context, Map<String, Object> params) {
- this.context = context;
- this.params = params;
- reset();
- }
-
- /**
- * Returns true if the connection has been lost, and therefore a low memory situation is likely
- * to be in effect.
- *
- * @return If a low memory situation is likely to be in effect.
- */
- public boolean warning() {
- return serviceConnection == null;
- }
-
- public void reset() {
- Intent launchIntent = new Intent(context, CanaryService.class);
- launchIntent.putExtra("memory", (int) getMemoryQuantity(getOrDefault(params, "memory", "32M")));
- serviceConnection = new ServiceConnection() {
- public void onServiceConnected(ComponentName name, IBinder service) {
- Log.i(TAG, "onServiceConnected");
- }
-
- public void onServiceDisconnected(ComponentName name) {
- Log.i(TAG, "onServiceDisconnected");
- context.unbindService(serviceConnection);
- serviceConnection = null;
- }
- };
-
- context.startService(launchIntent);
- context.bindService(launchIntent, serviceConnection, Context.BIND_ALLOW_OOM_MANAGEMENT);
- }
-}
diff --git a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/CanaryService.java b/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/CanaryService.java
deleted file mode 100644
index 005cd8e..0000000
--- a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/CanaryService.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package com.google.android.apps.internal.games.memoryadvice;
-
-import android.app.Service;
-import android.content.Intent;
-import android.os.Binder;
-import android.os.IBinder;
-import android.util.Log;
-
-/**
- * The service associated with the CanaryProcessTester. It consumes memory specifically to make it
- * a target for the platform to kill when memory is becoming low.
- */
-public class CanaryService extends Service {
- private static final String TAG = CanaryService.class.getSimpleName();
-
- @Override
- public int onStartCommand(Intent intent, int flags, int startId) {
- return START_NOT_STICKY;
- }
-
- @Override
- public IBinder onBind(Intent intent) {
- int memory = intent.getIntExtra("memory", 0);
- if (!TryAllocTester.occupyMemory(memory)) {
- Log.e(TAG, "occupyMemory failed to allocate");
- }
- return new Binder();
- }
-}
diff --git a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/DeviceProfile.java b/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/DeviceProfile.java
deleted file mode 100644
index 54f382e..0000000
--- a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/DeviceProfile.java
+++ /dev/null
@@ -1,153 +0,0 @@
-package com.google.android.apps.internal.games.memoryadvice;
-
-import android.os.Build;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.SortedSet;
-import java.util.TreeSet;
-
-class DeviceProfile {
- /**
- * Return the first index where two strings differ.
- *
- * @param a The first string to compare.
- * @param b The second string to compare.
- * @return The first index where the two strings have a different character, or either terminate.
- */
- private static int mismatchIndex(CharSequence a, CharSequence b) {
- int index = 0;
- while (true) {
- if (index >= a.length() || index >= b.length()) {
- return index;
- }
- if (a.charAt(index) != b.charAt(index)) {
- return index;
- }
- index++;
- }
- }
-
- /**
- * This method finds the device with the most similar fingerprint string.
- *
- * @param lookup The lookup table.
- * @return The selected device.
- */
- private static String matchByFingerprint(Map<String, Object> lookup) {
- int bestScore = -1;
- String best = null;
- for (String key : lookup.keySet()) {
- int score = mismatchIndex(Build.FINGERPRINT, key);
- if (score > bestScore) {
- bestScore = score;
- best = key;
- }
- }
- return best;
- }
-
- /**
- * this method finds the device with the most similar baseline metrics.
- *
- * @param lookup The lookup table.
- * @param baseline The current device metrics baseline.
- * @return The selected device.
- */
- private static String matchByBaseline(Map<String, Object> lookup, Map<String, Object> baseline) {
- Map<String, SortedSet<Long>> baselineValuesTable = buildBaselineValuesTable(lookup);
-
- float bestScore = Float.MAX_VALUE;
- String best = null;
-
- for (Map.Entry<String, Object> entry : lookup.entrySet()) {
- String key = entry.getKey();
- Map<String, Object> limits = (Map<String, Object>) entry.getValue();
- Map<String, Object> prospectBaseline = (Map<String, Object>) limits.get("baseline");
-
- float totalScore = 0;
- int totalUnion = 0;
- for (Map.Entry<String, Object> e : prospectBaseline.entrySet()) {
- Map<String, Object> prospectBaselineGroup = (Map<String, Object>) e.getValue();
- Map<String, Object> baselineGroup = (Map<String, Object>) baseline.get(e.getKey());
- if (baselineGroup == null) {
- break;
- }
- for (Map.Entry<String, Object> entry1 : prospectBaselineGroup.entrySet()) {
- String metric = entry1.getKey();
- Number baselineMetric = (Number) baselineGroup.get(metric);
- if (baselineMetric == null) {
- continue;
- }
- totalUnion++;
- SortedSet<Long> values = baselineValuesTable.get(metric);
- int prospectPosition =
- getPositionInList(values, ((Number) entry1.getValue()).longValue());
- int ownPosition = getPositionInList(values, baselineMetric.longValue());
- float score = (float) Math.abs(prospectPosition - ownPosition) / values.size();
- totalScore += score;
- }
- }
-
- if (totalUnion > 0) {
- totalScore /= totalUnion;
- }
-
- if (totalScore < bestScore) {
- bestScore = totalScore;
- best = key;
- }
- }
- return best;
- }
-
- /**
- * Finds the position of the first value exceeding the supplied value, in a sorted list.
- *
- * @param values The sorted list.
- * @param value The value to find the position of.
- * @return the position of the first value exceeding the supplied value.
- */
- private static int getPositionInList(Iterable<Long> values, long value) {
- Iterator<Long> it = values.iterator();
- int count = 0;
- while (it.hasNext()) {
- if (it.next() > value) {
- break;
- }
- count++;
- }
- return count;
- }
-
- /**
- * For each metric in the lookup table, get a sorted list of values as seen for devices' baseline
- * values.
- *
- * @param lookup The device lookup table.
- * @return A dictionary of sorted values indexed by metric name.
- */
- private static Map<String, SortedSet<Long>> buildBaselineValuesTable(Map<String, Object> lookup) {
- Map<String, SortedSet<Long>> table = new HashMap<>();
- for (Object o : lookup.values()) {
- Map<String, Object> limits = (Map<String, Object>) o;
- Map<String, Object> prospectBaseline = (Map<String, Object>) limits.get("baseline");
- if (prospectBaseline == null) {
- continue;
- }
- for (Object o1 : prospectBaseline.values()) {
- Map<String, Object> group = (Map<String, Object>) o1;
- for (Map.Entry<String, Object> entry : group.entrySet()) {
- String metric = entry.getKey();
- SortedSet<Long> metricValues = table.get(metric);
- if (metricValues == null) {
- metricValues = new TreeSet<>();
- table.put(metric, metricValues);
- }
- metricValues.add(((Number) entry.getValue()).longValue());
- }
- }
- }
- return table;
- }
-}
diff --git a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/Evaluator.java b/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/Evaluator.java
deleted file mode 100644
index bb21cd6..0000000
--- a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/Evaluator.java
+++ /dev/null
@@ -1,114 +0,0 @@
-package com.google.android.apps.internal.games.memoryadvice;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * An evaluator to allow expressions with basic arithmetic operators to be evaluated.
- */
-class Evaluator {
- private final Map<String, NodeBoolean> cache = new HashMap<>();
-
- /**
- * Evaluate a boolean expression.
- * @param formula The formula to evaluate.
- * @param lookup A callback to evaluate variable expressions.
- * @return The result of the evaluation.
- * @throws LookupException If the suppled variable cannot be evaluated.
- */
- boolean evaluate(String formula, Lookup lookup) throws LookupException {
- NodeBoolean node = cache.get(formula);
- if (node == null) {
- node = parseBoolean(formula);
- cache.put(formula, node);
- }
- return node.evaluate(lookup);
- }
-
- /**
- * Compile a boolean expression.
- * @param formula The text formula to compile.
- * @return The root of the expression tree.
- */
- private static NodeBoolean parseBoolean(String formula) {
- formula = formula.trim();
- {
- String[] split = splitFormula(formula, '>');
- if (split.length == 2) {
- return new NodeGreaterThan(parseDouble(split[0]), parseDouble(split[1]));
- }
- }
- {
- String[] split = splitFormula(formula, '<');
- if (split.length == 2) {
- return new NodeLessThan(parseDouble(split[0]), parseDouble(split[1]));
- }
- }
- return null;
- }
-
- /**
- * Compile a floating point (double) expression.
- * @param formula The text formula to compile.
- * @return The root of the expression tree.
- */
- private static NodeDouble parseDouble(String formula) {
- formula = formula.trim();
- if (formula.charAt(0) == '(' && formula.charAt(formula.length() - 1) == ')') {
- return parseDouble(formula.substring(1, formula.length() - 1));
- }
-
- {
- String[] split = splitFormula(formula, '+');
- if (split.length == 2) {
- return new NodeAdd(parseDouble(split[0]), parseDouble(split[1]));
- }
- }
- {
- String[] split = splitFormula(formula, '-');
- if (split.length == 2) {
- return new NodeSubtract(parseDouble(split[0]), parseDouble(split[1]));
- }
- }
- {
- String[] split = splitFormula(formula, '*');
- if (split.length == 2) {
- return new NodeMultiply(parseDouble(split[0]), parseDouble(split[1]));
- }
- }
-
- {
- String[] split = splitFormula(formula, '/');
- if (split.length == 2) {
- return new NodeDivide(parseDouble(split[0]), parseDouble(split[1]));
- }
- }
-
- try {
- double v = Double.parseDouble(formula);
- return new NodeDoubleLiteral(v);
- } catch (NumberFormatException ex) {
- // Ignored by design.
- }
-
- return new NodeDoubleParameter(formula);
- }
-
- /**
- * Split a formula by an operator character, provided it's not inside brackets.
- */
- private static String[] splitFormula(String formula, char splitOn) {
- int bracketCount = 0;
- for (int idx = 0; idx != formula.length(); idx++) {
- char c = formula.charAt(idx);
- if (c == '(') {
- bracketCount++;
- } else if (c == ')') {
- bracketCount--;
- } else if (c == splitOn && bracketCount == 0) {
- return new String[] {formula.substring(0, idx), formula.substring(idx + 1)};
- }
- }
- return new String[] {};
- }
-}
diff --git a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/JsonUtils.java b/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/JsonUtils.java
deleted file mode 100644
index f8b9aee..0000000
--- a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/JsonUtils.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package com.google.android.apps.internal.games.memoryadvice;
-
-import java.util.Map;
-
-class JsonUtils {
- /**
- * Performs a simple path lookup on a map.
- * @param path A path separated by forward slashes, and beginning with a forward slash.
- * @param object The object found in the object at the supplied path.
- */
- public static <T> T getFromPath(String path, Map<String, Object> object)
- throws MissingPathException {
- try {
- path = path.substring(1);
- int slash = path.indexOf('/');
-
- if (slash == -1) {
- if (!object.containsKey(path)) {
- throw new MissingPathException();
- }
- return (T) object.get(path);
- }
- String nextPart = path.substring(0, slash);
- Map<String, Object> nextObject = (Map<String, Object>) object.get(nextPart);
- if (nextObject == null) {
- throw new MissingPathException();
- }
-
- return getFromPath(path.substring(slash), nextObject);
- } catch (MissingPathException ex) {
- throw new MissingPathException("Missing path: " + path);
- }
- }
-}
diff --git a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/Lookup.java b/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/Lookup.java
deleted file mode 100644
index 2157ed8..0000000
--- a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/Lookup.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package com.google.android.apps.internal.games.memoryadvice;
-
-/**
- * An interface for evaluating variables during a formula evaluation.
- */
-interface Lookup {
- Double lookup(String parameter) throws LookupException;
-}
diff --git a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/LookupException.java b/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/LookupException.java
deleted file mode 100644
index 6a1505e..0000000
--- a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/LookupException.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package com.google.android.apps.internal.games.memoryadvice;
-
-/**
- * Denotes an error that occurred during variable expression evaluation.
- */
-class LookupException extends Exception {
- LookupException(String message) {
- super(message);
- }
-}
diff --git a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/MapTester.java b/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/MapTester.java
deleted file mode 100644
index ee89422..0000000
--- a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/MapTester.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package com.google.android.apps.internal.games.memoryadvice;
-
-import android.util.Log;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.nio.MappedByteBuffer;
-import java.nio.channels.FileChannel;
-
-/**
- * A class to use a small memory mapped file as a memory warning canary. When the file has been
- * unloaded it is a signal that memory is running low on the device.
- */
-class MapTester {
- private static final String TAG = MapTester.class.getSimpleName();
-
- private MappedByteBuffer map;
-
- /**
- * Make a new map tester.
- *
- * @param directory The (ideally temporary) folder in which the file should be created.
- */
- MapTester(File directory) {
- try {
- File mapFile = File.createTempFile("mapped", ".txt", directory);
-
- try (FileWriter out = new FileWriter(mapFile);
- BufferedWriter writer = new BufferedWriter(out)) {
- writer.write("_");
- }
-
- try (FileInputStream stream = new FileInputStream(mapFile);
- FileChannel channel = stream.getChannel()) {
- map = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size());
- }
-
- reset();
- } catch (IOException ex) {
- Log.w(TAG, ex);
- }
- }
-
- void reset() {
- if (map != null) {
- map.load();
- }
- }
-
- boolean warning() {
- if (map == null) {
- return false;
- }
- return !map.isLoaded();
- }
-}
diff --git a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/MemoryAdvisor.java b/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/MemoryAdvisor.java
deleted file mode 100644
index b2c0ba0..0000000
--- a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/MemoryAdvisor.java
+++ /dev/null
@@ -1,385 +0,0 @@
-package com.google.android.apps.internal.games.memoryadvice;
-
-import static com.google.android.apps.internal.games.memoryadvice_common.ConfigUtils.getMemoryQuantity;
-
-import android.content.Context;
-import android.content.res.AssetManager;
-import android.util.Log;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Wrapper class for methods related to memory advice.
- */
-public class MemoryAdvisor {
- private static final String TAG = MemoryMonitor.class.getSimpleName();
- private static final long BYTES_IN_KILOBYTE = 1024;
- private static final long BYTES_IN_MEGABYTE = BYTES_IN_KILOBYTE * 1024;
- private static final long BYTES_IN_GIGABYTE = BYTES_IN_MEGABYTE * 1024;
-
- private final Map<String, Object> params;
- private final MemoryMonitor memoryMonitor;
- private final Map<String, Object> build;
- private Map<String, Object> baseline;
- private final Evaluator evaluator = new Evaluator();
- private Predictor realtimePredictor;
- private Predictor availablePredictor;
-
- /**
- * Create an Android memory advice fetcher.
- *
- * @param context The Android context to employ.
- */
- public MemoryAdvisor(Context context) {
- this(context, getDefaultParams(context.getAssets()));
- }
-
- /**
- * Create an Android memory advice fetcher.
- *
- * @param context The Android context to employ.
- * @param params The active configuration; described by advisorParameters.schema.json.
- * @throws MemoryAdvisorException
- */
- public MemoryAdvisor(Context context, Map<String, Object> params) {
- Map<String, Object> metrics = (Map<String, Object>) params.get("metrics");
- memoryMonitor = new MemoryMonitor(context, metrics);
- this.params = params;
- build = BuildInfo.getBuild(context);
-
- Map<String, Object> baselineSpec = (Map<String, Object>) metrics.get("baseline");
- baseline = new LinkedHashMap<>();
- if (baselineSpec == null) {
- baseline = null;
- } else {
- baseline = memoryMonitor.getMemoryMetrics(baselineSpec);
- Map<String, Object> constant = (Map<String, Object>) metrics.get("constant");
- if (constant != null) {
- baseline.put("constant", memoryMonitor.getMemoryMetrics(constant));
- }
- }
- }
-
- /**
- * Get the library's default parameters. These can be selectively modified by the application and
- * passed back in to the constructor.
- *
- * @param assets The AssetManager used to fetch the default parameter file.
- * @return The default parameters as a JSON object.
- */
- private static Map<String, Object> getDefaultParams(AssetManager assets) {
- Map<String, Object> params;
- try {
- params = new ObjectMapper().reader().readValue(
- assets.open("memoryadvice/default.json"), Map.class);
- } catch (IOException ex) {
- Log.e(TAG, "Problem getting default params", ex);
- params = new LinkedHashMap<>();
- }
- return params;
- }
-
- /**
- * Returns 'true' if there are any low memory warnings in the advice object.
- *
- * @param advice The advice object returned by getAdvice().
- * @return if there are any low memory warnings in the advice object.
- * @deprecated since 0.7. Use getMemoryState() instead.
- */
- @Deprecated
- public static boolean anyWarnings(Map<String, Object> advice) {
- Collection<Object> warnings = (Collection<Object>) advice.get("warnings");
- return warnings != null && !warnings.isEmpty();
- }
-
- /**
- * Returns an estimate for the amount of memory that can safely be allocated,
- * in bytes.
- *
- * @param advice The advice object returned by getAdvice().
- * @return an estimate for the amount of memory that can safely be allocated,
- * in bytes. 0 if no estimate is available.
- */
- public static long availabilityEstimate(Map<String, Object> advice) {
- Map<String, Object> metrics = (Map<String, Object>) advice.get("metrics");
- Object predictedUsage = metrics.get("predictedAvailable");
- if (predictedUsage instanceof Number) {
- return ((Number) predictedUsage).longValue();
- }
- return 0L;
- }
-
- /**
- * Return 'true' if there are any 'red' (critical) warnings in the advice object.
- *
- * @param advice The advice object returned by getAdvice().
- * @return if there are any 'red' (critical) warnings in the advice object.
- * @deprecated since 0.7. Use getMemoryState() instead.
- */
- @Deprecated
- public static boolean anyRedWarnings(Map<String, Object> advice) {
- List<Object> warnings = (List<Object>) advice.get("warnings");
- if (warnings == null) {
- return false;
- }
-
- for (int idx = 0; idx != warnings.size(); idx++) {
- Map<String, Object> warning = (Map<String, Object>) warnings.get(idx);
- if (warning != null && "red".equals(warning.get("level"))) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Get the memory state from an advice object returned by the Memory Advisor.
- *
- * @param advice The object to analyze for the memory state.
- * @return The current memory state.
- */
- public static MemoryState getMemoryState(Map<String, Object> advice) {
- if (Boolean.TRUE.equals(advice.get("backgrounded"))) {
- return MemoryState.BACKGROUNDED;
- }
- Collection<Map<String, Object>> warnings =
- (Collection<Map<String, Object>>) advice.get("warnings");
- if (warnings == null || warnings.isEmpty()) {
- return MemoryState.OK;
- }
- for (Map<String, Object> warning : warnings) {
- if (warning != null && "red".equals(warning.get("level"))) {
- return MemoryState.CRITICAL;
- }
- }
- return MemoryState.APPROACHING_LIMIT;
- }
-
- /**
- * Find a Number in a tree of Java objects, even when it is nested in sub-dictionaries in the
- * object.
- *
- * @param object The object to search.
- * @param key The key of the Number to find.
- * @return The value of the Number.
- */
- private static Number getValue(Map<String, Object> object, String key) {
- if (object.containsKey(key)) {
- return (Number) object.get(key);
- }
- for (Object value : object.values()) {
- if (value instanceof Map) {
- Number value1 = getValue((Map<String, Object>) value, key);
- if (value1 != null) {
- return value1;
- }
- }
- }
- return null;
- }
-
- /**
- * The value the advisor returns when asked for memory pressure on the device through the
- * getSignal method. GREEN indicates it is safe to allocate further, YELLOW indicates further
- * allocation shouldn't happen, and RED indicates high memory pressure.
- */
- public Map<String, Object> getAdvice() throws MemoryAdvisorException {
- Map<String, Object> results = new LinkedHashMap<>();
-
- Map<String, Object> metricsParams = (Map<String, Object>) params.get("metrics");
-
- Map<String, Object> metricsSpec = (Map<String, Object>) metricsParams.get("variable");
- Map<String, Object> metrics = memoryMonitor.getMemoryMetrics(metricsSpec);
- boolean recordTimings = Boolean.TRUE.equals(metricsSpec.get("timings"));
- if (Boolean.TRUE.equals(metricsSpec.get("predictRealtime"))) {
- if (realtimePredictor == null) {
- realtimePredictor = new Predictor("/realtime.tflite", "/realtime_features.json");
- }
-
- long time1 = System.nanoTime();
- Map<String, Object> data = new LinkedHashMap<>();
- data.put("baseline", baseline);
- data.put("build", build);
- data.put("sample", metrics);
- try {
- metrics.put("predictedUsage", realtimePredictor.predict(data));
- } catch (MissingPathException e) {
- throw new MemoryAdvisorException(e);
- }
-
- if (recordTimings) {
- Map<String, Object> meta1 = new LinkedHashMap<>();
- meta1.put("duration", System.nanoTime() - time1);
- metrics.put("_predictedUsageMeta", meta1);
- }
- }
-
- if (Boolean.TRUE.equals(metricsSpec.get("availableRealtime"))) {
- if (availablePredictor == null) {
- availablePredictor = new Predictor("/available.tflite", "/available_features.json");
- }
-
- long time1 = System.nanoTime();
- Map<String, Object> data = new LinkedHashMap<>();
- data.put("baseline", baseline);
- data.put("build", build);
- data.put("sample", metrics);
-
- try {
- metrics.put(
- "predictedAvailable", (long) (BYTES_IN_GIGABYTE * availablePredictor.predict(data)));
- } catch (MissingPathException e) {
- throw new MemoryAdvisorException(e);
- }
-
- if (recordTimings) {
- Map<String, Object> meta1 = new LinkedHashMap<>();
- meta1.put("duration", System.nanoTime() - time1);
- metrics.put("_predictedAvailableMeta", meta1);
- }
- }
-
- results.put("metrics", metrics);
-
- Map<String, Object> heuristics = (Map<String, Object>) params.get("heuristics");
- if (heuristics != null) {
- Collection<Object> warnings = new ArrayList<>();
- Object try1 = heuristics.get("try");
- if (try1 != null && !TryAllocTester.tryAlloc((int) getMemoryQuantity(try1))) {
- Map<String, Object> warning = new LinkedHashMap<>();
- warning.put("try", try1);
- warning.put("level", "red");
- warnings.add(warning);
- }
-
- if (metrics != null) {
- Object lowMemory = heuristics.get("lowMemory");
- if (lowMemory != null) {
- Map<String, Object> memoryInfo = (Map<String, Object>) metrics.get("MemoryInfo");
- if (memoryInfo != null && Boolean.TRUE.equals(memoryInfo.get("lowMemory"))) {
- Map<String, Object> warning = new LinkedHashMap<>();
- warning.put("lowMemory", lowMemory);
- warning.put("level", "red");
- warnings.add(warning);
- }
- }
-
- Object mapTester = heuristics.get("mapTester");
- if (mapTester != null && Boolean.TRUE.equals(metrics.get("mapTester"))) {
- Map<String, Object> warning = new LinkedHashMap<>();
- warning.put("mapTester", mapTester);
- warning.put("level", "red");
- warnings.add(warning);
- }
-
- Object canaryProcessTester = heuristics.get("canaryProcessTester");
- if (canaryProcessTester != null && metrics.containsKey("canaryProcessTester")) {
- Map<String, Object> warning = new LinkedHashMap<>();
- warning.put("canaryProcessTester", canaryProcessTester);
- warning.put("level", "red");
- warnings.add(warning);
- }
-
- Object onTrim = heuristics.get("onTrim");
- Number onTrim1 = (Number) metrics.get("onTrim");
- if (onTrim != null && onTrim1 != null && onTrim1.longValue() > 0) {
- Map<String, Object> warning = new LinkedHashMap<>();
- warning.put("onTrim", onTrim);
- warning.put("level", "red");
- warnings.add(warning);
- }
- }
-
- Map<String, Object> allFormulas = (Map<String, Object>) heuristics.get("formulas");
- if (allFormulas != null) {
- for (Map.Entry<String, Object> entry : allFormulas.entrySet()) {
- List<String> formulas = (List<String>) entry.getValue();
- for (int idx = 0; idx != formulas.size(); idx++) {
- String formula = formulas.get(idx);
- try {
- if (evaluator.evaluate(formula, key1 -> {
- Map<String, Object> dictionary;
- if (key1.startsWith("baseline.")) {
- key1 = key1.substring("baseline.".length());
- dictionary = baseline;
- } else {
- dictionary = metrics;
- }
- Number value = getValue(dictionary, key1);
- if (value == null) {
- throw new LookupException(key1 + " not defined");
- }
- return value.doubleValue();
- })) {
- Map<String, Object> warning = new LinkedHashMap<>();
- warning.put("formula", formula);
- warning.put("level", entry.getKey());
- warnings.add(warning);
- }
- } catch (LookupException ex) {
- Log.w(TAG, ex);
- }
- }
- }
- }
-
- if (!warnings.isEmpty()) {
- results.put("warnings", warnings);
- }
- }
-
- return results;
- }
-
- public void setOnTrim(int level) {
- memoryMonitor.setOnTrim(level);
- }
-
- /**
- * Fetch information about the device.
- *
- * @return Information about the device, in a map.
- */
- public Map<String, Object> getDeviceInfo() {
- Map<String, Object> deviceInfo = new LinkedHashMap<>();
- deviceInfo.put("build", build);
- deviceInfo.put("baseline", baseline);
- deviceInfo.put("params", params);
- return deviceInfo;
- }
-
- /**
- * Advice passed from the memory advisor to the application about the state of memory.
- */
- public enum MemoryState {
- /**
- * The memory state cannot be determined.
- */
- UNKNOWN,
-
- /**
- * The application can safely allocate significant memory.
- */
- OK,
-
- /**
- * The application should not allocate significant memory.
- */
- APPROACHING_LIMIT,
-
- /**
- * The application should free memory as soon as possible, until the memory state changes.
- */
- CRITICAL,
-
- /**
- * The application is backgrounded. The library does not make advice in this state.
- */
- BACKGROUNDED
- }
-}
diff --git a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/MemoryAdvisorException.java b/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/MemoryAdvisorException.java
deleted file mode 100644
index 6ee7211..0000000
--- a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/MemoryAdvisorException.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package com.google.android.apps.internal.games.memoryadvice;
-
-/**
- * Internal or configuration errors in the Memory Advisor.
- */
-class MemoryAdvisorException extends RuntimeException {
- MemoryAdvisorException(String message) {
- super(message);
- }
-
- MemoryAdvisorException(Throwable cause) {
- super(cause);
- }
-
- MemoryAdvisorException(String message, Throwable cause) {
- super(message, cause);
- }
-}
diff --git a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/MemoryMonitor.java b/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/MemoryMonitor.java
deleted file mode 100644
index 384cf70..0000000
--- a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/MemoryMonitor.java
+++ /dev/null
@@ -1,317 +0,0 @@
-package com.google.android.apps.internal.games.memoryadvice;
-
-import static com.google.android.apps.internal.games.memoryadvice.Utils.getOomScore;
-import static com.google.android.apps.internal.games.memoryadvice.Utils.processMemFormatFile;
-
-import android.app.ActivityManager;
-import android.content.Context;
-import android.os.Build;
-import android.os.Debug;
-import android.os.Process;
-import androidx.lifecycle.Lifecycle;
-import androidx.lifecycle.LifecycleObserver;
-import androidx.lifecycle.OnLifecycleEvent;
-import androidx.lifecycle.ProcessLifecycleOwner;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-/**
- * A class to provide metrics of current memory usage to an application in JSON format.
- */
-class MemoryMonitor {
- private static final String TAG = MemoryMonitor.class.getSimpleName();
-
- private static final long BYTES_IN_KILOBYTE = 1024;
- private static final long BYTES_IN_MEGABYTE = BYTES_IN_KILOBYTE * 1024;
- private final MapTester mapTester;
- private final ActivityManager activityManager;
- private final CanaryProcessTester canaryProcessTester;
- private boolean appBackgrounded;
- private int latestOnTrimLevel;
- private final int pid = Process.myPid();
-
- /**
- * Create an Android memory metrics fetcher.
- *
- * @param context The Android context to employ.
- * @param metrics The constant metrics to fetch - constant and variable.
- */
- MemoryMonitor(Context context, Map<String, Object> metrics) {
- mapTester = new MapTester(context.getCacheDir());
- activityManager = (ActivityManager) context.getSystemService((Context.ACTIVITY_SERVICE));
-
- if (metrics != null) {
- Map<String, Object> variable = (Map<String, Object>) metrics.get("variable");
- if (variable != null) {
- Map<String, Object> canaryProcessParams =
- (Map<String, Object>) variable.get("canaryProcessTester");
- if (canaryProcessParams == null) {
- canaryProcessTester = null;
- } else {
- canaryProcessTester = new CanaryProcessTester(context, canaryProcessParams);
- }
- } else {
- canaryProcessTester = null;
- }
- } else {
- canaryProcessTester = null;
- }
-
- ProcessLifecycleOwner.get().getLifecycle().addObserver(new LifecycleObserver() {
- @OnLifecycleEvent(Lifecycle.Event.ON_STOP)
- public void onAppBackgrounded() {
- appBackgrounded = true;
- }
-
- @OnLifecycleEvent(Lifecycle.Event.ON_START)
- public void onAppForegrounded() {
- appBackgrounded = false;
- }
- });
- }
-
- /**
- * Gets Android memory metrics.
- *
- * @param fields The fields to fetch in a JSON dictionary.
- * @return A map containing current memory metrics.
- */
- public Map<String, Object> getMemoryMetrics(Map<String, Object> fields) {
- Map<String, Object> report = new LinkedHashMap<>();
-
- Map<String, Object> _meta = new LinkedHashMap<>();
- _meta.put("time", System.currentTimeMillis());
-
- if (mapTester.warning()) {
- report.put("mapTester", true);
- mapTester.reset();
- }
-
- if (canaryProcessTester != null && canaryProcessTester.warning()) {
- report.put("canaryProcessTester", "red");
- canaryProcessTester.reset();
- }
-
- if (appBackgrounded) {
- report.put("backgrounded", true);
- }
-
- if (latestOnTrimLevel > 0) {
- report.put("onTrim", latestOnTrimLevel);
- latestOnTrimLevel = 0;
- }
-
- if (fields == null) {
- // All remaining data requires a fields spec.
- return report;
- }
-
- boolean recordTimings = Boolean.TRUE.equals(fields.get("timings"));
- Object debugFieldsValue = fields.get("debug");
- if (debugFieldsValue != null) {
- long time = System.nanoTime();
- Map<String, Object> metricsOut = new LinkedHashMap<>();
- Map<String, Object> debug =
- debugFieldsValue instanceof Map ? (Map<String, Object>) debugFieldsValue : null;
- boolean allFields = Boolean.TRUE.equals(debugFieldsValue);
- if (allFields || debug != null) {
- if (allFields || Boolean.TRUE.equals(debug.get("nativeHeapAllocatedSize"))) {
- metricsOut.put("NativeHeapAllocatedSize", Debug.getNativeHeapAllocatedSize());
- }
- if (allFields || Boolean.TRUE.equals(debug.get("NativeHeapFreeSize"))) {
- metricsOut.put("NativeHeapFreeSize", Debug.getNativeHeapFreeSize());
- }
- if (allFields || Boolean.TRUE.equals(debug.get("NativeHeapSize"))) {
- metricsOut.put("NativeHeapSize", Debug.getNativeHeapSize());
- }
- if (allFields || Boolean.TRUE.equals(debug.get("Pss"))) {
- metricsOut.put("Pss", Debug.getPss() * BYTES_IN_KILOBYTE);
- }
- }
- if (recordTimings) {
- Map<String, Object> meta = new LinkedHashMap<>();
- meta.put("duration", System.nanoTime() - time);
- metricsOut.put("_meta", meta);
- }
- report.put("debug", metricsOut);
- }
-
- Object memoryInfoValue = fields.get("MemoryInfo");
- if (memoryInfoValue != null) {
- long time = System.nanoTime();
- Map<String, Object> memoryInfoFields =
- memoryInfoValue instanceof Map ? (Map<String, Object>) memoryInfoValue : null;
- boolean allFields = Boolean.TRUE.equals(memoryInfoValue);
- if (allFields || (memoryInfoFields != null && !memoryInfoFields.isEmpty())) {
- Map<String, Object> metricsOut = new LinkedHashMap<>();
- ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
- activityManager.getMemoryInfo(memoryInfo);
- if (allFields || Boolean.TRUE.equals(memoryInfoFields.get("availMem"))) {
- metricsOut.put("availMem", memoryInfo.availMem);
- }
- if (memoryInfo.lowMemory
- && (allFields || Boolean.TRUE.equals(memoryInfoFields.get("lowMemory")))) {
- metricsOut.put("lowMemory", true);
- }
- if (allFields || Boolean.TRUE.equals(memoryInfoFields.get("totalMem"))) {
- metricsOut.put("totalMem", memoryInfo.totalMem);
- }
- if (allFields || Boolean.TRUE.equals(memoryInfoFields.get("threshold"))) {
- metricsOut.put("threshold", memoryInfo.threshold);
- }
-
- if (recordTimings) {
- Map<String, Object> meta = new LinkedHashMap<>();
- meta.put("duration", System.nanoTime() - time);
- metricsOut.put("_meta", meta);
- }
- report.put("MemoryInfo", metricsOut);
- }
- }
-
- Object activityManagerValue = fields.get("ActivityManager");
- if (activityManagerValue != null) {
- Map<String, Object> activityManagerFields =
- activityManagerValue instanceof Map ? (Map<String, Object>) activityManagerValue : null;
- boolean allFields = Boolean.TRUE.equals(activityManagerValue);
- if (allFields || activityManagerFields != null) {
- if (allFields || Boolean.TRUE.equals(activityManagerFields.get("MemoryClass"))) {
- report.put("MemoryClass", activityManager.getMemoryClass() * BYTES_IN_MEGABYTE);
- }
- if (allFields || Boolean.TRUE.equals(activityManagerFields.get("LargeMemoryClass"))) {
- report.put("LargeMemoryClass", activityManager.getLargeMemoryClass() * BYTES_IN_MEGABYTE);
- }
- if (allFields || Boolean.TRUE.equals(activityManagerFields.get("LowRamDevice"))) {
- report.put("LowRamDevice", activityManager.isLowRamDevice());
- }
- }
- }
-
- Object procFieldsValue = fields.get("proc");
- if (procFieldsValue != null) {
- long time = System.nanoTime();
- Map<String, Object> procFields =
- procFieldsValue instanceof Map ? (Map<String, Object>) procFieldsValue : null;
- boolean allFields = Boolean.TRUE.equals(procFieldsValue);
- Map<String, Object> metricsOut = new LinkedHashMap<>();
- if (allFields || (procFields != null && Boolean.TRUE.equals(procFields.get("oom_score")))) {
- metricsOut.put("oom_score", getOomScore(pid));
- }
- if (recordTimings) {
- Map<String, Object> meta = new LinkedHashMap<>();
- meta.put("duration", System.nanoTime() - time);
- metricsOut.put("_meta", meta);
- }
- report.put("proc", metricsOut);
- }
-
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && fields.containsKey("summary")) {
- long time = System.nanoTime();
- Object summaryValue = fields.get("summary");
- Map<String, Object> summary =
- summaryValue instanceof Map ? (Map<String, Object>) summaryValue : null;
- boolean allFields = Boolean.TRUE.equals(summaryValue);
- if (allFields || (summary != null && !summary.isEmpty())) {
- Debug.MemoryInfo[] debugMemoryInfos = activityManager.getProcessMemoryInfo(new int[] {pid});
- Map<String, Object> metricsOut = new LinkedHashMap<>();
- for (Debug.MemoryInfo debugMemoryInfo : debugMemoryInfos) {
- for (Map.Entry<String, String> entry : debugMemoryInfo.getMemoryStats().entrySet()) {
- String key = entry.getKey();
- if (allFields || summary.containsKey(key)) {
- long value = Long.parseLong(entry.getValue()) * BYTES_IN_KILOBYTE;
- Number number = (Number) metricsOut.get(key);
- metricsOut.put(key, number == null ? value : number.longValue() + value);
- }
- }
- }
-
- if (recordTimings) {
- Map<String, Object> meta = new LinkedHashMap<>();
- meta.put("duration", System.nanoTime() - time);
- metricsOut.put("_meta", meta);
- }
- report.put("summary", metricsOut);
- }
- }
-
- if (fields.containsKey("meminfo")) {
- long time = System.nanoTime();
- Object meminfoFieldsValue = fields.get("meminfo");
- Map<String, Object> meminfoFields =
- meminfoFieldsValue instanceof Map ? (Map<String, Object>) meminfoFieldsValue : null;
- boolean allFields = Boolean.TRUE.equals(meminfoFieldsValue);
- if (allFields || (meminfoFields != null && !meminfoFields.isEmpty())) {
- Map<String, Object> metricsOut = new LinkedHashMap<>();
- processMemFormatFile("/proc/meminfo", (key, bytes) -> {
- if (allFields || Boolean.TRUE.equals(meminfoFields.get(key))) {
- metricsOut.put(key, bytes);
- }
- });
-
- if (recordTimings) {
- Map<String, Object> meta = new LinkedHashMap<>();
- meta.put("duration", System.nanoTime() - time);
- metricsOut.put("_meta", meta);
- }
- report.put("meminfo", metricsOut);
- }
- }
-
- if (fields.containsKey("smaps_rollup")) {
- long time = System.nanoTime();
- Object smapsRollupFieldsValue = fields.get("smaps_rollup");
- Map<String, Object> smapsRollupFields = smapsRollupFieldsValue instanceof Map
- ? (Map<String, Object>) smapsRollupFieldsValue
- : null;
- boolean allFields = Boolean.TRUE.equals(smapsRollupFieldsValue);
- if (allFields || (smapsRollupFields != null && !smapsRollupFields.isEmpty())) {
- Map<String, Object> metricsOut = new LinkedHashMap<>();
- processMemFormatFile("/proc/" + pid + "/smaps_rollup", (key, bytes) -> {
- if (allFields || Boolean.TRUE.equals(smapsRollupFields.get(key))) {
- metricsOut.put(key, bytes);
- }
- });
-
- if (recordTimings) {
- Map<String, Object> meta = new LinkedHashMap<>();
- meta.put("duration", System.nanoTime() - time);
- metricsOut.put("_meta", meta);
- }
- report.put("smaps_rollup", metricsOut);
- }
- }
-
- if (fields.containsKey("status")) {
- long time = System.nanoTime();
- Object statusValue = fields.get("status");
- Map<String, Object> status =
- statusValue instanceof Map ? (Map<String, Object>) statusValue : null;
- boolean allFields = Boolean.TRUE.equals(statusValue);
- if (allFields || (status != null && !status.isEmpty())) {
- Map<String, Object> metricsOut = new LinkedHashMap<>();
- processMemFormatFile("/proc/" + pid + "/status", (key, bytes) -> {
- if (allFields || Boolean.TRUE.equals(status.get(key))) {
- metricsOut.put(key, bytes);
- }
- });
-
- if (recordTimings) {
- Map<String, Object> meta = new LinkedHashMap<>();
- meta.put("duration", System.nanoTime() - time);
- metricsOut.put("_meta", meta);
- }
- report.put("status", metricsOut);
- }
- }
-
- _meta.put("endTime", System.currentTimeMillis());
- report.put("meta", _meta);
- return report;
- }
-
- public void setOnTrim(int level) {
- if (level > latestOnTrimLevel) {
- latestOnTrimLevel = level;
- }
- }
-}
diff --git a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/MemoryWatcher.java b/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/MemoryWatcher.java
deleted file mode 100644
index 0515862..0000000
--- a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/MemoryWatcher.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package com.google.android.apps.internal.games.memoryadvice;
-
-import java.io.Closeable;
-import java.util.Map;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-
-/**
- * A MemoryWatcher automatically polls the memory advisor and calls back a client a soon as possible
- * when the state changes.
- */
-public class MemoryWatcher implements Closeable {
- private final Runnable runner;
-
- private MemoryAdvisor.MemoryState lastReportedState = MemoryAdvisor.MemoryState.UNKNOWN;
- private boolean interrupt;
-
- /**
- * Create a MemoryWatcher object. This calls back the supplied client when the memory state
- * changes.
- *
- * @param memoryAdvisor The memory advisor object to employ.
- * @param delay Delay between polls.
- * @param client The client to call back when the state changes.
- */
- public MemoryWatcher(MemoryAdvisor memoryAdvisor, long delay, Client client) {
- ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(
- runnable -> Executors.defaultThreadFactory().newThread(runnable));
-
- runner = new Runnable() {
- @Override
- public void run() {
- if (interrupt) {
- return;
- }
- Map<String, Object> advice = memoryAdvisor.getAdvice();
- client.receiveAdvice(advice);
- MemoryAdvisor.MemoryState memoryState = MemoryAdvisor.getMemoryState(advice);
- if (memoryState != lastReportedState) {
- lastReportedState = memoryState;
- client.newState(memoryState);
- }
- scheduledExecutorService.schedule(runner, delay, TimeUnit.MILLISECONDS);
- }
- };
- runner.run();
- }
-
- @Override
- public void close() {
- interrupt = true;
- }
-
- /**
- * A client for the MemoryWatcher class.
- */
- public interface Client {
- void newState(MemoryAdvisor.MemoryState state);
- void receiveAdvice(Map<String, Object> advice);
- }
-
- /**
- * A client for the MemoryWatcher class, which allows only the methods required to be overridden.
- */
- public abstract static class DefaultClient implements Client {
- @Override
- public void newState(MemoryAdvisor.MemoryState state) {}
-
- @Override
- public void receiveAdvice(Map<String, Object> advice) {}
- }
-}
diff --git a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/MissingPathException.java b/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/MissingPathException.java
deleted file mode 100644
index 7594510..0000000
--- a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/MissingPathException.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package com.google.android.apps.internal.games.memoryadvice;
-
-class MissingPathException extends Exception {
- MissingPathException() {}
-
- MissingPathException(String s) {
- super(s);
- }
-}
diff --git a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/NodeAdd.java b/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/NodeAdd.java
deleted file mode 100644
index 62177a2..0000000
--- a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/NodeAdd.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.google.android.apps.internal.games.memoryadvice;
-
-class NodeAdd extends NodeDouble {
- private final NodeDouble left;
- private final NodeDouble right;
-
- NodeAdd(NodeDouble left, NodeDouble right) {
- this.left = left;
- this.right = right;
- }
-
- @Override
- Double evaluate(Lookup lookup) throws LookupException {
- return left.evaluate(lookup) + right.evaluate(lookup);
- }
-}
diff --git a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/NodeBoolean.java b/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/NodeBoolean.java
deleted file mode 100644
index 1b41bd5..0000000
--- a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/NodeBoolean.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package com.google.android.apps.internal.games.memoryadvice;
-
-abstract class NodeBoolean {
- abstract boolean evaluate(Lookup lookup) throws LookupException;
-}
diff --git a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/NodeDivide.java b/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/NodeDivide.java
deleted file mode 100644
index cdff105..0000000
--- a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/NodeDivide.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.google.android.apps.internal.games.memoryadvice;
-
-class NodeDivide extends NodeDouble {
- private final NodeDouble left;
- private final NodeDouble right;
-
- NodeDivide(NodeDouble left, NodeDouble right) {
- this.left = left;
- this.right = right;
- }
-
- @Override
- Double evaluate(Lookup lookup) throws LookupException {
- return left.evaluate(lookup) / right.evaluate(lookup);
- }
-}
diff --git a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/NodeDouble.java b/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/NodeDouble.java
deleted file mode 100644
index f429b45..0000000
--- a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/NodeDouble.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package com.google.android.apps.internal.games.memoryadvice;
-
-abstract class NodeDouble {
- abstract Double evaluate(Lookup lookup) throws LookupException;
-}
diff --git a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/NodeDoubleLiteral.java b/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/NodeDoubleLiteral.java
deleted file mode 100644
index 63bc5ca..0000000
--- a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/NodeDoubleLiteral.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package com.google.android.apps.internal.games.memoryadvice;
-
-class NodeDoubleLiteral extends NodeDouble {
- private final double value;
-
- NodeDoubleLiteral(double value) {
- this.value = value;
- }
-
- @Override
- Double evaluate(Lookup lookup) {
- return value;
- }
-}
diff --git a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/NodeDoubleParameter.java b/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/NodeDoubleParameter.java
deleted file mode 100644
index 428e54f..0000000
--- a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/NodeDoubleParameter.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package com.google.android.apps.internal.games.memoryadvice;
-
-class NodeDoubleParameter extends NodeDouble {
- private final String parameter;
-
- NodeDoubleParameter(String parameter) {
- this.parameter = parameter;
- }
-
- @Override
- Double evaluate(Lookup lookup) throws LookupException {
- return lookup.lookup(parameter);
- }
-}
diff --git a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/NodeGreaterThan.java b/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/NodeGreaterThan.java
deleted file mode 100644
index 9b61e33..0000000
--- a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/NodeGreaterThan.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.google.android.apps.internal.games.memoryadvice;
-
-class NodeGreaterThan extends NodeBoolean {
- private final NodeDouble left;
- private final NodeDouble right;
-
- NodeGreaterThan(NodeDouble left, NodeDouble right) {
- this.left = left;
- this.right = right;
- }
-
- @Override
- boolean evaluate(Lookup lookup) throws LookupException {
- return left.evaluate(lookup) > right.evaluate(lookup);
- }
-}
diff --git a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/NodeLessThan.java b/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/NodeLessThan.java
deleted file mode 100644
index ddbc999..0000000
--- a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/NodeLessThan.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.google.android.apps.internal.games.memoryadvice;
-
-class NodeLessThan extends NodeBoolean {
- private final NodeDouble left;
- private final NodeDouble right;
-
- NodeLessThan(NodeDouble left, NodeDouble right) {
- this.left = left;
- this.right = right;
- }
-
- @Override
- boolean evaluate(Lookup lookup) throws LookupException {
- return left.evaluate(lookup) < right.evaluate(lookup);
- }
-}
diff --git a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/NodeMultiply.java b/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/NodeMultiply.java
deleted file mode 100644
index 4205e54..0000000
--- a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/NodeMultiply.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.google.android.apps.internal.games.memoryadvice;
-
-class NodeMultiply extends NodeDouble {
- private final NodeDouble left;
- private final NodeDouble right;
-
- NodeMultiply(NodeDouble left, NodeDouble right) {
- this.left = left;
- this.right = right;
- }
-
- @Override
- Double evaluate(Lookup lookup) throws LookupException {
- return left.evaluate(lookup) * right.evaluate(lookup);
- }
-}
diff --git a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/NodeSubtract.java b/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/NodeSubtract.java
deleted file mode 100644
index 5ea75ef..0000000
--- a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/NodeSubtract.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.google.android.apps.internal.games.memoryadvice;
-
-class NodeSubtract extends NodeDouble {
- private final NodeDouble left;
- private final NodeDouble right;
-
- NodeSubtract(NodeDouble left, NodeDouble right) {
- this.left = left;
- this.right = right;
- }
-
- @Override
- Double evaluate(Lookup lookup) throws LookupException {
- return left.evaluate(lookup) - right.evaluate(lookup);
- }
-}
diff --git a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/Predictor.java b/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/Predictor.java
deleted file mode 100644
index bb7c003..0000000
--- a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/Predictor.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package com.google.android.apps.internal.games.memoryadvice;
-
-import static com.google.android.apps.internal.games.memoryadvice.ByteArrayUtils.streamToDirectByteBuffer;
-import static com.google.android.apps.internal.games.memoryadvice.JsonUtils.getFromPath;
-import static com.google.android.apps.internal.games.memoryadvice_common.StreamUtils.readStream;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.FloatBuffer;
-import java.util.List;
-import java.util.Map;
-import org.tensorflow.lite.Interpreter;
-
-class Predictor {
- private final Interpreter interpreter;
- private final List<String> features;
-
- /**
- * Construct a prediction service using the model found at the specified resource name and the
- * feature list found at the specified resurce name.
- * @param model The resource path of the TensorFlow Lite model.
- * @param features The resource path of the features.
- */
- Predictor(String model, String features) {
- try {
- this.features = new ObjectMapper().reader().readValue(
- Predictor.class.getResourceAsStream(features), List.class);
- } catch (IOException e) {
- throw new IllegalStateException(e);
- }
-
- try (InputStream inputStream = Predictor.class.getResourceAsStream(model)) {
- interpreter = new Interpreter(streamToDirectByteBuffer(inputStream));
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
- /**
- * Invoke the TensorFlow Lite model after extracting the features from the input data.
- * @param data The map containing the input set.
- * @return The prediction.
- */
- float predict(Map<String, Object> data) throws MissingPathException {
- float[] featuresArray = new float[features.size()];
- for (int idx = 0; idx != features.size(); idx++) {
- String feature = features.get(idx);
- Object o = getFromPath(feature, data);
- float value;
- if (o instanceof Boolean) {
- value = (Boolean) o ? 1.0f : 0.0f;
- } else {
- value = ((Number) o).floatValue();
- }
- featuresArray[idx] = value;
- }
-
- FloatBuffer output = FloatBuffer.allocate(1);
- interpreter.run(featuresArray, output);
- return output.get(0);
- }
-}
diff --git a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/TryAllocTester.java b/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/TryAllocTester.java
deleted file mode 100644
index 3f979ad..0000000
--- a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/TryAllocTester.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.google.android.apps.internal.games.memoryadvice;
-
-class TryAllocTester {
- static {
- System.loadLibrary("try-alloc-lib");
- }
-
- /**
- * Attempt to allocate memory on the native heap, then if successful immediately release it and
- * return 'true'. Otherwise return 'false'.
- *
- * @param bytes The number of bytes to allocate.
- * @return 'true' if the allocation attempt was successful.
- */
- static native boolean tryAlloc(int bytes);
-
- /**
- * Allocate memory and fill it with data that is unlikely to be compressible.
- *
- * @param bytes The number of bytes to allocate.
- * @return 'true' if the allocation attempt was successful.
- */
- static native boolean occupyMemory(int bytes);
-}
diff --git a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/Utils.java b/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/Utils.java
deleted file mode 100644
index 078faae..0000000
--- a/test/memoryadvice/memoryadvice/src/main/java/com/google/android/apps/internal/games/memoryadvice/Utils.java
+++ /dev/null
@@ -1,70 +0,0 @@
-package com.google.android.apps.internal.games.memoryadvice;
-
-import android.util.Log;
-import com.google.android.apps.internal.games.memoryadvice_common.StreamUtils;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.util.Objects;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * A helper class with static methods to help with Heuristics and file IO
- */
-public class Utils {
- private static final String TAG = Utils.class.getSimpleName();
- private static final Pattern MEMORY_REGEX = Pattern.compile("([a-zA-Z()_]+)[^\\d]*(\\d+) kB.*\n");
-
- /**
- * Loads all text from the specified file and returns the result as a string.
- *
- * @param filename The name of the file to read.
- * @return All of the text from the file.
- * @throws IOException Thrown if a read error occurs.
- */
- public static String readFile(String filename) throws IOException {
- try (FileInputStream inputStream = new FileInputStream(filename)) {
- return StreamUtils.readStream(inputStream);
- }
- }
-
- /**
- * Returns the OOM score associated with a process.
- *
- * @param pid The process ID (pid).
- * @return The OOM score, or -1 if the score cannot be obtained.
- */
- static int getOomScore(int pid) {
- try {
- return Integer.parseInt(readFile(("/proc/" + pid) + "/oom_score"));
- } catch (IOException | NumberFormatException e) {
- return -1;
- }
- }
-
- /**
- * Extracts values from a Linux memory summary format file, converting kB values to bytes.
- *
- * @param filename The file to read.
- * @param client The client to receive values.
- */
- static void processMemFormatFile(String filename, MemFormatClient client) {
- try {
- String meminfoText = readFile(filename);
- Matcher matcher = MEMORY_REGEX.matcher(meminfoText);
- while (matcher.find()) {
- client.receive(
- matcher.group(1), Long.parseLong(Objects.requireNonNull(matcher.group(2))) * 1024);
- }
- } catch (IOException e) {
- Log.w(TAG, "Failed to read " + filename);
- }
- }
-
- /**
- * A receiver of Linux memory file data.
- */
- interface MemFormatClient {
- void receive(String key, long bytes);
- }
-}
diff --git a/test/memoryadvice/memoryadvice/src/main/resources/available.tflite b/test/memoryadvice/memoryadvice/src/main/resources/available.tflite
deleted file mode 100644
index 24b2745..0000000
--- a/test/memoryadvice/memoryadvice/src/main/resources/available.tflite
+++ /dev/null
Binary files differ
diff --git a/test/memoryadvice/memoryadvice/src/main/resources/available_features.json b/test/memoryadvice/memoryadvice/src/main/resources/available_features.json
deleted file mode 100644
index 825b9de..0000000
--- a/test/memoryadvice/memoryadvice/src/main/resources/available_features.json
+++ /dev/null
@@ -1,64 +0,0 @@
-[
- "/baseline/MemoryInfo/availMem",
- "/baseline/MemoryInfo/threshold",
- "/baseline/MemoryInfo/totalMem",
- "/baseline/constant/LargeMemoryClass",
- "/baseline/constant/LowRamDevice",
- "/baseline/constant/MemoryClass",
- "/baseline/constant/MemoryInfo/threshold",
- "/baseline/constant/MemoryInfo/totalMem",
- "/baseline/constant/meminfo/CommitLimit",
- "/baseline/constant/meminfo/MemTotal",
- "/baseline/debug/NativeHeapAllocatedSize",
- "/baseline/debug/NativeHeapFreeSize",
- "/baseline/debug/NativeHeapSize",
- "/baseline/debug/Pss",
- "/baseline/meminfo/Active",
- "/baseline/meminfo/Active(anon)",
- "/baseline/meminfo/Active(file)",
- "/baseline/meminfo/AnonPages",
- "/baseline/meminfo/Bounce",
- "/baseline/meminfo/Buffers",
- "/baseline/meminfo/Cached",
- "/baseline/meminfo/CommitLimit",
- "/baseline/meminfo/Committed_AS",
- "/baseline/meminfo/Dirty",
- "/baseline/meminfo/Inactive",
- "/baseline/meminfo/Inactive(anon)",
- "/baseline/meminfo/Inactive(file)",
- "/baseline/meminfo/KernelStack",
- "/baseline/meminfo/Mapped",
- "/baseline/meminfo/MemFree",
- "/baseline/meminfo/MemTotal",
- "/baseline/meminfo/Mlocked",
- "/baseline/meminfo/NFS_Unstable",
- "/baseline/meminfo/PageTables",
- "/baseline/meminfo/SReclaimable",
- "/baseline/meminfo/SUnreclaim",
- "/baseline/meminfo/Shmem",
- "/baseline/meminfo/Slab",
- "/baseline/meminfo/SwapCached",
- "/baseline/meminfo/SwapFree",
- "/baseline/meminfo/SwapTotal",
- "/baseline/meminfo/Unevictable",
- "/baseline/meminfo/VmallocTotal",
- "/baseline/meminfo/VmallocUsed",
- "/baseline/meminfo/Writeback",
- "/baseline/meminfo/WritebackTmp",
- "/baseline/proc/oom_score",
- "/baseline/status/VmData",
- "/baseline/status/VmExe",
- "/baseline/status/VmHWM",
- "/baseline/status/VmLck",
- "/baseline/status/VmLib",
- "/baseline/status/VmPTE",
- "/baseline/status/VmPeak",
- "/baseline/status/VmPin",
- "/baseline/status/VmRSS",
- "/baseline/status/VmSize",
- "/baseline/status/VmStk",
- "/baseline/status/VmSwap",
- "/build/version/SDK_INT",
- "/sample/debug/Pss",
- "/sample/proc/oom_score"
-]
\ No newline at end of file
diff --git a/test/memoryadvice/memoryadvice/src/main/resources/oom.tflite b/test/memoryadvice/memoryadvice/src/main/resources/oom.tflite
deleted file mode 100644
index 690e2cf..0000000
--- a/test/memoryadvice/memoryadvice/src/main/resources/oom.tflite
+++ /dev/null
Binary files differ
diff --git a/test/memoryadvice/memoryadvice/src/main/resources/realtime_features.json b/test/memoryadvice/memoryadvice/src/main/resources/realtime_features.json
deleted file mode 100644
index f4a9a84..0000000
--- a/test/memoryadvice/memoryadvice/src/main/resources/realtime_features.json
+++ /dev/null
@@ -1,6 +0,0 @@
-[
- "/baseline/constant/MemoryInfo/totalMem",
- "/baseline/meminfo/SwapTotal",
- "/sample/MemoryInfo/availMem",
- "/sample/proc/oom_score"
-]
\ No newline at end of file
diff --git a/test/memoryadvice/memoryadvice_common/.gitignore b/test/memoryadvice/memoryadvice_common/.gitignore
deleted file mode 100644
index 42afabf..0000000
--- a/test/memoryadvice/memoryadvice_common/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/build
\ No newline at end of file
diff --git a/test/memoryadvice/memoryadvice_common/build.gradle b/test/memoryadvice/memoryadvice_common/build.gradle
deleted file mode 100644
index 2ca1a5b..0000000
--- a/test/memoryadvice/memoryadvice_common/build.gradle
+++ /dev/null
@@ -1,52 +0,0 @@
-plugins {
- id 'java-library'
- id 'maven-publish'
-}
-
-java {
- sourceCompatibility JavaVersion.VERSION_1_8
- targetCompatibility JavaVersion.VERSION_1_8
-}
-
-dependencies {
- implementation 'org.json:json:20200518'
- implementation fileTree(dir: 'libs', include: ['*.jar'])
-}
-
-task sourceJar(type: Jar) {
- from sourceSets.main.allJava
- classifier 'sources'
-}
-
-task javadocJar(type: Jar, dependsOn: javadoc) {
- from javadoc.destinationDir
- classifier 'javadoc'
-}
-
-afterEvaluate {
- publishing {
- publications {
- release(MavenPublication) {
- groupId = 'com.google.android.games'
- artifactId = 'memory-advice-common'
- version = '0.24'
- artifact(sourceJar)
- artifact(javadocJar)
- from components.java
- pom {
- name = 'Memory Advice for Java : Common components'
- url = 'https://android.googlesource.com/platform/frameworks/opt/gamesdk/+/refs/heads/master/test/memoryadvice'
- description = 'Parts of the Memory Advice library that are written in Java can be ' +
- 'run in desktop application as well as Android.'
- licenses {
- license {
- name = 'The Apache Software License, Version 2.0'
- url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
- distribution = 'repo'
- }
- }
- }
- }
- }
- }
-}
diff --git a/test/memoryadvice/memoryadvice_common/src/main/java/com/google/android/apps/internal/games/memoryadvice_common/ConfigUtils.java b/test/memoryadvice/memoryadvice_common/src/main/java/com/google/android/apps/internal/games/memoryadvice_common/ConfigUtils.java
deleted file mode 100644
index b8118ee..0000000
--- a/test/memoryadvice/memoryadvice_common/src/main/java/com/google/android/apps/internal/games/memoryadvice_common/ConfigUtils.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package com.google.android.apps.internal.games.memoryadvice_common;
-
-import java.util.Map;
-
-public class ConfigUtils {
- /**
- * Converts a memory quantity value in an object to a number of bytes. If the value is a number,
- * it is interpreted as the number of bytes. If the value is a string, it is converted according
- * to the specified unit. e.g. "36K", "52.5 m", "9.1G". No unit is interpreted as bytes.
- *
- * @param object The object to extract from.
- * @return The equivalent number of bytes.
- */
- public static long getMemoryQuantity(Object object) {
- if (object instanceof Number) {
- return ((Number) object).longValue();
- }
-
- if (object instanceof String) {
- String str = ((String) object).toUpperCase();
- int unitPosition = str.indexOf('K');
- long unitMultiplier = 1024;
- if (unitPosition == -1) {
- unitPosition = str.indexOf('M');
- unitMultiplier *= 1024;
- if (unitPosition == -1) {
- unitPosition = str.indexOf('G');
- unitMultiplier *= 1024;
- if (unitPosition == -1) {
- unitMultiplier = 1;
- }
- }
- }
- float value = Float.parseFloat(str.substring(0, unitPosition));
- return (long) (value * unitMultiplier);
- }
- throw new IllegalArgumentException("Input to getMemoryQuantity neither string or number.");
- }
-
- /**
- * Return the value associated with the key in the given map. If the map does not define
- * the key, return the specified default value.
- * @param object The map to extract the value from.
- * @param key The key associated with the value.
- * @param defaultValue The value to return if the map does not specify the key.
- * @return The associated value, or the defaultValue if the object does not define the key.
- */
- public static Object getOrDefault(Map<String, Object> object, String key, Object defaultValue) {
- return object.containsKey(key) ? object.get(key) : defaultValue;
- }
-}
\ No newline at end of file
diff --git a/test/memoryadvice/memoryadvice_common/src/main/java/com/google/android/apps/internal/games/memoryadvice_common/Schemas.java b/test/memoryadvice/memoryadvice_common/src/main/java/com/google/android/apps/internal/games/memoryadvice_common/Schemas.java
deleted file mode 100644
index 5b8c840..0000000
--- a/test/memoryadvice/memoryadvice_common/src/main/java/com/google/android/apps/internal/games/memoryadvice_common/Schemas.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package com.google.android.apps.internal.games.memoryadvice_common;
-
-import java.net.URL;
-
-public class Schemas {
- /**
- * Supply a schema from the library by name.
- * @param schema The schema filename to obtain.
- * @return The schema in text form.
- */
- public static URL getSchema(String schema) {
- return Schemas.class.getResource("/schemas/" + schema);
- }
-}
diff --git a/test/memoryadvice/memoryadvice_common/src/main/java/com/google/android/apps/internal/games/memoryadvice_common/StreamUtils.java b/test/memoryadvice/memoryadvice_common/src/main/java/com/google/android/apps/internal/games/memoryadvice_common/StreamUtils.java
deleted file mode 100644
index 00cfab2..0000000
--- a/test/memoryadvice/memoryadvice_common/src/main/java/com/google/android/apps/internal/games/memoryadvice_common/StreamUtils.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package com.google.android.apps.internal.games.memoryadvice_common;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.PrintStream;
-
-public class StreamUtils {
- /**
- * Loads all the text from an input string and returns the result as a string.
- *
- * @param inputStream The stream to read.
- * @return All of the text from the stream.
- * @throws IOException Thrown if a read error occurs.
- */
- public static String readStream(InputStream inputStream) throws IOException {
- return readStream(inputStream, null);
- }
-
- /**
- * Loads all the text from an input string and returns the result as a string.
- *
- * @param inputStream The stream to read.
- * @param out Optional stream to output the data as it is read.
- * @return All of the text from the stream.
- * @throws IOException Thrown if a read error occurs.
- */
- public static String readStream(InputStream inputStream, PrintStream out) throws IOException {
- try (InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
- BufferedReader reader = new BufferedReader(inputStreamReader)) {
- String newline = System.lineSeparator();
- StringBuilder output = new StringBuilder();
- String line;
- while ((line = reader.readLine()) != null) {
- if (output.length() > 0) {
- output.append(newline);
- }
- if (out != null) {
- out.println(line);
- }
- output.append(line);
- }
- return output.toString();
- }
- }
-}
diff --git a/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/advice.schema.json b/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/advice.schema.json
deleted file mode 100644
index c5447cf..0000000
--- a/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/advice.schema.json
+++ /dev/null
@@ -1,31 +0,0 @@
-{
- "$schema": "http://json-schema.org/draft-07/schema",
- "title": "Advice",
- "description": "Advice given from the app to the client. Includes information about the current state of memory, as well as predictions and warnings if configured appropriately.",
- "additionalProperties": false,
- "properties": {
- "meta": {
- "type": "object",
- "additionalProperties": false,
- "properties": {
- "duration": {
- "type": "integer",
- "minimum": 0
- }
- }
- },
- "metrics": {
- "$ref": "metricsResults.schema.json"
- },
- "warnings": {
- "type": "array",
- "items": {
- "$ref": "warning.schema.json"
- }
- }
- },
- "required": [
- "metrics"
- ],
- "type": "object"
-}
\ No newline at end of file
diff --git a/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/advisorParameters.schema.json b/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/advisorParameters.schema.json
deleted file mode 100644
index b3cf477..0000000
--- a/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/advisorParameters.schema.json
+++ /dev/null
@@ -1,39 +0,0 @@
-{
- "$schema": "http://json-schema.org/draft-07/schema",
- "title": "Advisor parameters",
- "description": "Configuration for the memory advisor.",
- "additionalProperties": false,
- "properties": {
- "metrics": {
- "$ref": "monitorParameters.schema.json"
- },
- "heuristics": {
- "$ref": "heuristics.schema.json"
- }
- },
- "type": "object",
- "examples": [
- {
- "metrics": {
- "baseline": {
- "debug": true
- },
- "variable": {
- "canaryProcessTester": {
- "memory": "256M"
- }
- }
- },
- "heuristics": {
- "try": "256M",
- "canaryProcessTester": true,
- "VmRSS": {
- "limit": {
- "red": 0.85,
- "yellow": 0.75
- }
- }
- }
- }
- ]
-}
\ No newline at end of file
diff --git a/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/build.schema.json b/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/build.schema.json
deleted file mode 100644
index d1ca28b..0000000
--- a/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/build.schema.json
+++ /dev/null
@@ -1,60 +0,0 @@
-{
- "$schema": "http://json-schema.org/draft-07/schema",
- "title": "Build",
- "description": "Information about the Android build from the device.",
- "type": "object",
- "properties": {
- "features": {
- "type": "object",
- "properties": {
- "named": {
- "type": "object"
- },
- "unnamed": {
- "type": "array",
- "items": {
- "patternProperties": {
- ".*": {
- "type": ["boolean", "integer", "string"]
- }
- }
- }
- }
- },
- "additionalProperties": false
- },
- "library": {
- "type": "object",
- "patternProperties": {
- ".*": {
- "type": ["boolean", "integer", "string"]
- }
- }
- },
- "system": {
- "type": "object",
- "patternProperties": {
- ".*": {
- "type": ["boolean", "integer", "string"]
- }
- }
- },
- "version": {
- "type": "object",
- "patternProperties": {
- ".*": {
- "type": ["array", "boolean", "integer", "string"]
- }
- }
- },
- "fields": {
- "type": "object",
- "patternProperties": {
- ".*": {
- "type": ["array", "boolean", "integer", "string"]
- }
- }
- }
- },
- "additionalProperties": false
-}
\ No newline at end of file
diff --git a/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/canaryProcessTesterSpec.schema.json b/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/canaryProcessTesterSpec.schema.json
deleted file mode 100644
index ca49749..0000000
--- a/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/canaryProcessTesterSpec.schema.json
+++ /dev/null
@@ -1,17 +0,0 @@
-{
- "$schema": "http://json-schema.org/draft-07/schema",
- "anyOf": [
- {
- "type": "boolean"
- },
- {
- "additionalProperties": false,
- "properties": {
- "memory": {
- "$ref": "memoryQuantity.schema.json"
- }
- },
- "type": "object"
- }
- ]
-}
\ No newline at end of file
diff --git a/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/deviceInfo.schema.json b/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/deviceInfo.schema.json
deleted file mode 100644
index da17fed..0000000
--- a/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/deviceInfo.schema.json
+++ /dev/null
@@ -1,24 +0,0 @@
-{
- "$schema": "http://json-schema.org/draft-07/schema",
- "title": "Device Info",
- "description": "Information specific to the device collected at the beginning of the sample.",
- "additionalProperties": false,
- "properties": {
- "baseline": {
- "$ref": "metricsResults.schema.json"
- },
- "build": {
- "$ref": "build.schema.json"
- },
- "deviceProfile": {
- "$ref": "deviceProfile.schema.json"
- },
- "params": {
- "$ref": "advisorParameters.schema.json"
- },
- "predictedOomLimit": {
- "type": "number"
- }
- },
- "type": "object"
-}
\ No newline at end of file
diff --git a/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/deviceProfile.schema.json b/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/deviceProfile.schema.json
deleted file mode 100644
index b1c6aaf..0000000
--- a/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/deviceProfile.schema.json
+++ /dev/null
@@ -1,27 +0,0 @@
-{
- "$schema": "http://json-schema.org/draft-07/schema",
- "title": "Device Profile",
- "description": "Information about the device itself.",
- "type": "object",
- "properties": {
- "fingerprint": {
- "type": "string"
- },
- "limits": {
- "type": "object",
- "additionalProperties": false,
- "properties": {
- "baseline": {
- "$ref": "metricsResults.schema.json"
- },
- "limit": {
- "$ref": "metricsResults.schema.json"
- }
- }
- },
- "matched": {
- "type": "string"
- }
- },
- "additionalProperties": false
-}
\ No newline at end of file
diff --git a/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/duration.schema.json b/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/duration.schema.json
deleted file mode 100644
index e42d3cb..0000000
--- a/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/duration.schema.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "$schema": "http://json-schema.org/draft-07/schema",
- "title": "Duration",
- "description": "A time duration.",
- "anyOf": [
- {
- "minimum": 0,
- "type": "integer"
- },
- {
- "pattern": "[0-9]+[SMHsmh]",
- "type": "string"
- }
- ]
-}
\ No newline at end of file
diff --git a/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/heuristics.schema.json b/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/heuristics.schema.json
deleted file mode 100644
index 0aae8bd..0000000
--- a/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/heuristics.schema.json
+++ /dev/null
@@ -1,50 +0,0 @@
-{
- "$schema": "http://json-schema.org/draft-07/schema",
- "title": "Heuristics",
- "description": "Configuration for a set of memory management (heuristic) techniques.",
- "properties": {
- "try": {
- "description": "A heuristic that attemts to allocate a quantity of memory and fires if it fails.",
- "allOf": [
- {
- "$ref": "memoryQuantity.schema.json"
- }
- ]
- },
- "lowMemory": {
- "description": "A heuristic that fires when `ActivityManager.getMemoryInfo().lowMemory` becomes true.",
- "type": "boolean"
- },
- "mapTester": {
- "description": "A heuristic that fires when a memory mapped file is unloaded.",
- "type": "boolean"
- },
- "canaryProcessTester": {
- "description": "A heuristic that fires when the canary process tester reports the process is lost..",
- "type": "boolean"
- },
- "onTrim": {
- "description": "A heuristic that fires when `Activity.onTrimMemory` events are received.",
- "type": "boolean"
- },
- "formulas": {
- "type": "object",
- "additionalProperties": false,
- "properties": {
- "red": {
- "type": "array",
- "items": {
- "type": "string"
- }
- },
- "yellow": {
- "type": "array",
- "items": {
- "type": "string"
- }
- }
- }
- }
- },
- "type": "object"
-}
\ No newline at end of file
diff --git a/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/launchParams.schema.json b/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/launchParams.schema.json
deleted file mode 100644
index 3ef4787..0000000
--- a/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/launchParams.schema.json
+++ /dev/null
@@ -1,26 +0,0 @@
-{
- "$schema": "http://json-schema.org/draft-07/schema",
- "title": "Launch Parameters",
- "description": "Configuration for a test run.",
- "additionalProperties": false,
- "properties": {
- "tests": {
- "$ref": "testArray.schema.json"
- },
- "coordinates": {
- "type": "array",
- "items": {
- "type": "integer",
- "minimum": 0,
- "maximum": 100
- }
- },
- "run": {
- "type": "string"
- },
- "started": {
- "$ref": "time.schema.json"
- }
- },
- "type": "object"
-}
\ No newline at end of file
diff --git a/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/memoryQuantity.schema.json b/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/memoryQuantity.schema.json
deleted file mode 100644
index f66b63e..0000000
--- a/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/memoryQuantity.schema.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "$schema": "http://json-schema.org/draft-07/schema",
- "title": "Memory Quantity",
- "description": "A quantity of memory, expressed with a unit.",
- "anyOf": [
- {
- "minimum": 0,
- "type": "number",
- "multipleOf": 1.0
- },
- {
- "pattern": "[0-9]+[BKMGbkmg]",
- "type": "string"
- }
- ]
-}
\ No newline at end of file
diff --git a/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/metricsResults.schema.json b/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/metricsResults.schema.json
deleted file mode 100644
index 0e83a02..0000000
--- a/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/metricsResults.schema.json
+++ /dev/null
@@ -1,101 +0,0 @@
-{
- "$schema": "http://json-schema.org/draft-07/schema",
- "title": "Metrics Results",
- "description": "An individual memory state sample recorded on device.",
- "additionalProperties": false,
- "properties": {
- "ActivityManager": {
- "$ref": "metricsResultsGroup.schema.json"
- },
- "canaryProcessTester": {
- "type": "string",
- "enum": ["red", "yellow"]
- },
- "backgrounded": {
- "type": "boolean",
- "default": false
- },
- "constant": {
- "$ref": "#"
- },
- "debug": {
- "$ref": "metricsResultsGroup.schema.json"
- },
- "LargeMemoryClass": {
- "$ref": "memoryQuantity.schema.json"
- },
- "LowRamDevice": {
- "type": "boolean"
- },
- "mapTester": {
- "type": "boolean"
- },
- "meminfo": {
- "$ref": "metricsResultsGroup.schema.json"
- },
- "MemoryClass": {
- "$ref": "memoryQuantity.schema.json"
- },
- "MemoryInfo": {
- "$ref": "metricsResultsGroup.schema.json"
- },
- "DebugMemoryInfo": {
- "$ref": "metricsResultsGroup.schema.json"
- },
- "meta": {
- "additionalProperties": false,
- "properties": {
- "time": {
- "$ref": "time.schema.json"
- }
- },
- "required": [
- "time"
- ],
- "type": "object"
- },
- "onTrim": {
- "minimum": 0,
- "type": "integer"
- },
- "proc": {
- "$ref": "metricsResultsGroup.schema.json"
- },
- "smaps_rollup": {
- "$ref": "metricsResultsGroup.schema.json"
- },
- "status": {
- "$ref": "metricsResultsGroup.schema.json"
- },
- "stressed": {
- "$ref": "metricsResultsGroup.schema.json"
- },
- "summary": {
- "$ref": "metricsResultsGroup.schema.json"
- },
-
- "predictedUsage": {
- "type": "number"
- },
- "_predictedUsageMeta": {
- "properties": {
- "duration": {
- "type": "integer"
- }
- },
- "additionalProperties": false
- },
- "predictedAvailable": {
- "type": "integer"
- },
- "_predictedAvailableMeta": {
- "properties": {
- "duration": {
- "type": "integer"
- }
- },
- "additionalProperties": false
- }
- },
- "type": "object"
-}
\ No newline at end of file
diff --git a/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/metricsResultsGroup.schema.json b/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/metricsResultsGroup.schema.json
deleted file mode 100644
index 328604c..0000000
--- a/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/metricsResultsGroup.schema.json
+++ /dev/null
@@ -1,27 +0,0 @@
-{
- "$schema": "http://json-schema.org/draft-07/schema",
- "title": "Metrics Results Group",
- "description": "A group of related metrics readings.",
- "properties": {
- "_meta": {
- "type": "object",
- "additionalProperties": false,
- "properties": {
- "duration": {
- "type": "integer",
- "minimum": 0
- }
- },
- "required": ["duration"]
- }
- },
- "patternProperties": {
- "^[A-Za-z]+[A-Za-z0-9_]*$": {
- "type": [
- "boolean",
- "integer"
- ]
- }
- },
- "type": "object"
-}
diff --git a/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/metricsSpecGroup.schema.json b/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/metricsSpecGroup.schema.json
deleted file mode 100644
index c3910e7..0000000
--- a/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/metricsSpecGroup.schema.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "$schema": "http://json-schema.org/draft-07/schema",
- "title": "Metrics Spec Group",
- "description": "Specification for a particular metrics group.",
- "anyOf": [
- {
- "type": "boolean"
- },
- {
- "type": "object",
- "patternProperties": {
- "[A-Za-z0-9_]+": {
- "type": [
- "boolean"
- ]
- }
- }
- }
- ]
-}
\ No newline at end of file
diff --git a/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/metricsSpecs.schema.json b/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/metricsSpecs.schema.json
deleted file mode 100644
index cef2f0d..0000000
--- a/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/metricsSpecs.schema.json
+++ /dev/null
@@ -1,106 +0,0 @@
-{
- "$schema": "http://json-schema.org/draft-07/schema",
- "title": "Metrics Specs",
- "description": "Specification for which metrics to collect.",
- "additionalProperties": false,
- "type": "object",
- "properties": {
- "ActivityManager": {
- "description": "Metrics obtained from `android.app.ActivityManager`.",
- "allOf": [
- {
- "$ref": "metricsSpecGroup.schema.json"
- }
- ]
- },
- "debug": {
- "description": "Metrics obtained from android.os.debug.",
- "allOf": [
- {
- "$ref": "metricsSpecGroup.schema.json"
- }
- ]
- },
- "meminfo": {
- "description": "Metrics obtained from `/proc/meminfo`.",
- "allOf": [
- {
- "$ref": "metricsSpecGroup.schema.json"
- }
- ]
- },
- "MemoryInfo": {
- "description": "Metrics obtained from `android.app.ActivityManager.MemoryInfo`.",
- "allOf": [
- {
- "$ref": "metricsSpecGroup.schema.json"
- }
- ]
- },
- "DebugMemoryInfo": {
- "description": "Metrics obtained from `android.os.Debug.MemoryInfo`.",
- "allOf": [
- {
- "$ref": "metricsSpecGroup.schema.json"
- }
- ]
- },
- "proc": {
- "description": "Metrics obtained from `proc` folder",
- "allOf": [
- {
- "$ref": "metricsSpecGroup.schema.json"
- }
- ]
- },
- "smaps_rollup": {
- "description": "Metrics obtained from `/proc/(pid)/smaps_rollup`.",
- "allOf": [
- {
- "$ref": "metricsSpecGroup.schema.json"
- }
- ]
- },
- "status": {
- "description": "Metrics obtained from `/proc/(pid)/status`.",
- "allOf": [
- {
- "$ref": "metricsSpecGroup.schema.json"
- }
- ]
- },
- "summary": {
- "description": "From `android.os.Debug.MemoryInfo[]`.",
- "allOf": [
- {
- "$ref": "metricsSpecGroup.schema.json"
- }
- ]
- },
- "canaryProcessTester": {
- "$ref": "canaryProcessTesterSpec.schema.json"
- },
- "predictRealtime": {
- "type": "boolean"
- },
- "availableRealtime": {
- "type": "boolean"
- },
- "timings": {
- "type": "boolean"
- }
- },
- "examples": [
- {
- "MemoryInfo": {
- "totalMem": true,
- "threshold": true
- },
- "meminfo": true,
- "ActivityManager": true,
- "proc": {
- "oom_score": true
- }
- }
- ]
-}
\ No newline at end of file
diff --git a/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/monitorParameters.schema.json b/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/monitorParameters.schema.json
deleted file mode 100644
index aee8ce4..0000000
--- a/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/monitorParameters.schema.json
+++ /dev/null
@@ -1,52 +0,0 @@
-{
- "description": "Two sets of metrics to collect",
- "additionalProperties": false,
- "properties": {
- "baseline": {
- "description": "Metrics to gather at the beginning of the run.",
- "allOf": [
- {
- "$ref": "metricsSpecs.schema.json"
- }
- ]
- },
- "constant": {
- "description": "Metrics that don't change while an application is running.",
- "allOf": [
- {
- "$ref": "metricsSpecs.schema.json"
- }
- ]
- },
- "variable": {
- "description": "Metrics that can change while an application is running.",
- "allOf": [
- {
- "$ref": "metricsSpecs.schema.json"
- }
- ]
- }
- },
- "type": "object",
- "examples": [
- {
- "constant": {
- "MemoryInfo": {
- "totalMem": true
- },
- "meminfo": {
- "CommitLimit": true,
- "MemTotal": true
- }
- },
- "baseline": {
- "debug": true
- },
- "variable": {
- "debug": true,
- "meminfo": true,
- "proc": true
- }
- }
- ]
-}
\ No newline at end of file
diff --git a/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/params.schema.json b/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/params.schema.json
deleted file mode 100644
index 121f8de..0000000
--- a/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/params.schema.json
+++ /dev/null
@@ -1,113 +0,0 @@
-{
- "$schema": "http://json-schema.org/draft-07/schema",
- "title": "Params",
- "description": "A set of parameters to configure the stress test application.",
- "additionalProperties": false,
- "properties": {
- "apk_base": {
- "type": "string"
- },
- "apk_name": {
- "type": "string"
- },
- "firebase": {
- "type": "object",
- "patternProperties": {
- ".*": {
- "type": ["string", "number", "boolean"]
- }
- }
- },
- "glTest": {
- "$ref": "memoryQuantity.schema.json"
- },
- "malloc": {
- "$ref": "memoryQuantity.schema.json"
- },
- "mallocFixed": {
- "$ref": "memoryQuantity.schema.json"
- },
- "glFixed": {
- "$ref": "memoryQuantity.schema.json"
- },
- "vkTest": {
- "$ref": "memoryQuantity.schema.json"
- },
- "mmapAnon": {
- "properties": {
- "blockSize": {
- "$ref": "memoryQuantity.schema.json"
- },
- "allocPerMillisecond": {
- "$ref": "memoryQuantity.schema.json"
- }
- },
- "type": "object",
- "additionalProperties": false
- },
- "mmapFile": {
- "properties": {
- "count": {
- "type": "integer",
- "minimum": 1
- },
- "fileSize": {
- "$ref": "memoryQuantity.schema.json"
- },
- "blockSize": {
- "$ref": "memoryQuantity.schema.json"
- },
- "allocPerMillisecond": {
- "$ref": "memoryQuantity.schema.json"
- }
- },
- "type": "object",
- "additionalProperties": false
- },
- "maxConsumer": {
- "$ref": "memoryQuantity.schema.json"
- },
- "orientation": {
- "enum": [
- "landscape",
- "portrait"
- ],
- "type": "string"
- },
- "serviceBlocker": {
- "type": "boolean"
- },
- "timeout": {
- "$ref": "duration.schema.json"
- },
- "switchTest": {
- "description": "Enables a test where the stress application is put into the background by launching another app.",
- "additionalProperties": false,
- "properties": {
- "launchDuration": {
- "$ref": "duration.schema.json"
- },
- "returnDuration": {
- "$ref": "duration.schema.json"
- }
- },
- "type": "object"
- },
- "advisorParameters": {
- "$ref": "advisorParameters.schema.json"
- },
- "package": {
- "type": "string"
- },
- "delayBeforeRelease": {
- "$ref": "duration.schema.json"
- },
- "delayAfterRelease": {
- "$ref": "duration.schema.json"
- },
- "memoryToFreePerCycle": {
- "$ref": "memoryQuantity.schema.json"
- }
- },
- "type": "object"
-}
\ No newline at end of file
diff --git a/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/results.schema.json b/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/results.schema.json
deleted file mode 100644
index 5fa4511..0000000
--- a/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/results.schema.json
+++ /dev/null
@@ -1,27 +0,0 @@
-{
- "$schema": "http://json-schema.org/draft-07/schema",
- "title": "Results",
- "description": "A full set of results from a stress test run.",
- "type": "array",
- "items": {
- "$ref": "resultsRow.schema.json"
- },
- "allOf": [
- {
- "items": [
- {
- "required": [
- "extra"
- ]
- }
- ],
- "additionalItems": {
- "properties": {
- "extra": false
- }
- },
- "type": "array"
- }
- ]
-}
-
diff --git a/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/resultsRow.schema.json b/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/resultsRow.schema.json
deleted file mode 100644
index 1b624c3..0000000
--- a/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/resultsRow.schema.json
+++ /dev/null
@@ -1,104 +0,0 @@
-{
- "$schema": "http://json-schema.org/draft-07/schema",
- "title": "Results Row",
- "description": "An individual results row from a stress test run.",
- "additionalProperties": false,
- "properties": {
- "extra": {
- "additionalProperties": false,
- "properties": {
- "fromLauncher": {
- "$ref": "https://raw.githubusercontent.com/googleapis/google-api-go-client/master/testing/v1/testing-api.json#/schemas/AndroidModel"
- },
- "historyId": {
- "pattern": "[a-z0-9.]+",
- "type": "string"
- },
- "resultsPage": {
- "format": "uri-reference"
- },
- "step": {
- "$ref": "https://raw.githubusercontent.com/googleapis/google-api-go-client/master/toolresults/v1beta3/toolresults-api.json#/schemas/Step"
- }
- },
- "type": "object"
- },
- "activityPaused": {
- "type": "boolean",
- "default": false
- },
- "advice": {
- "$ref": "advice.schema.json"
- },
- "allocFailed": {
- "type": "boolean",
- "default": false
- },
- "mmapAnonFailed": {
- "type": "boolean",
- "default": false
- },
- "mmapFileFailed": {
- "type": "boolean",
- "default": false
- },
- "criticalLogLines": {
- "type": "array",
- "items": {
- "type": "string"
- },
- "default": []
- },
- "deviceInfo": {
- "$ref": "deviceInfo.schema.json"
- },
- "exiting": {
- "type": "boolean",
- "default": false
- },
- "failedToClear": {
- "type": "boolean",
- "default": false
- },
- "metrics": {
- "$ref": "metricsResults.schema.json"
- },
- "params": {
- "$ref": "launchParams.schema.json"
- },
- "paused": {
- "type": "boolean",
- "default": false
- },
- "serviceCrashed": {
- "type": "boolean",
- "default": false
- },
- "testMetrics": {
- "additionalProperties": false,
- "properties": {
- "gl_allocated": {
- "type": "integer",
- "minimum": 0
- },
- "nativeAllocatedByTest": {
- "type": "integer",
- "minimum": 0
- },
- "vkAllocatedByTest": {
- "type": "integer",
- "minimum": 0
- }
- },
- "type": "object"
- },
- "time": {
- "$ref": "time.schema.json"
- },
- "version": {
- "minimum": 0,
- "type": "integer"
- }
- },
- "type": "object"
-}
\ No newline at end of file
diff --git a/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/testArray.schema.json b/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/testArray.schema.json
deleted file mode 100644
index 557a2ee..0000000
--- a/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/testArray.schema.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "$schema": "http://json-schema.org/draft-07/schema",
- "title": "Test Array",
- "description": "A multi-dimensional array of partial test parameters, to be combined into multiple single run parameter sets.",
- "items": {
- "items": {
- "$ref": "params.schema.json"
- },
- "minItems": 1,
- "type": "array"
- },
- "minItems": 1,
- "type": "array"
-}
\ No newline at end of file
diff --git a/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/time.schema.json b/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/time.schema.json
deleted file mode 100644
index 89f8d87..0000000
--- a/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/time.schema.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "$schema": "http://json-schema.org/draft-07/schema",
- "title": "Time",
- "description": "A point in time.",
- "type": "integer",
- "format": "uint64",
- "minimum": 1500000000000,
- "maximum": 5000000000000
-}
\ No newline at end of file
diff --git a/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/warning.schema.json b/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/warning.schema.json
deleted file mode 100644
index 3fb82db..0000000
--- a/test/memoryadvice/memoryadvice_common/src/main/resources/schemas/warning.schema.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "$schema": "http://json-schema.org/draft-07/schema",
- "title": "Warning",
- "description": "A memory warning sent by the memory advice library.",
- "type": "object",
- "maxProperties": 2,
- "properties": {
- "level": {
- "enum": ["red", "yellow"]
- }
- },
- "required": ["level"]
-}
\ No newline at end of file
diff --git a/test/memoryadvice/memorytest/.gitignore b/test/memoryadvice/memorytest/.gitignore
deleted file mode 100644
index 42afabf..0000000
--- a/test/memoryadvice/memorytest/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/build
\ No newline at end of file
diff --git a/test/memoryadvice/memorytest/build.gradle b/test/memoryadvice/memorytest/build.gradle
deleted file mode 100644
index acea6bb..0000000
--- a/test/memoryadvice/memorytest/build.gradle
+++ /dev/null
@@ -1,75 +0,0 @@
-plugins {
- id 'com.android.library'
- id 'maven-publish'
-}
-
-android {
- compileSdkVersion 29
-
- defaultConfig {
- minSdkVersion 19
- versionCode 9
- // LINT.IfChange
- versionName '0.24'
- // LINT.ThenChange(../README.md)
- multiDexEnabled true
- testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
- }
-
- externalNativeBuild {
- cmake {
- path "src/main/cpp/CMakeLists.txt"
- }
- }
-
- compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_8
- targetCompatibility JavaVersion.VERSION_1_8
- }
-
- buildTypes {
- debug {
- testCoverageEnabled true
- }
- }
-}
-
-dependencies {
- implementation project(path: ':memoryadvice')
- implementation project(path: ':memoryadvice_common')
- implementation 'commons-io:commons-io:2.6'
-}
-
-task sourceJar(type: Jar) {
- from android.sourceSets.main.java.srcDirs
- classifier 'sources'
-}
-
-task javadoc(type: Javadoc) {
- source = android.sourceSets.main.java.srcDirs
- exclude "**/AndroidManifest.xml"
- failOnError false
-}
-afterEvaluate {
- publishing {
- publications {
- release(MavenPublication) {
- from components.release
- groupId = 'com.google.android.games'
- artifactId = 'memory-test'
- version = android.defaultConfig.versionName
- artifact(sourceJar)
- pom {
- name = 'Memory Advice tests'
- licenses {
- license {
- name = 'The Apache Software License, Version 2.0'
- url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
- distribution = 'repo'
- }
- }
- }
- }
- }
- }
-}
diff --git a/test/memoryadvice/memorytest/src/main/AndroidManifest.xml b/test/memoryadvice/memorytest/src/main/AndroidManifest.xml
deleted file mode 100644
index 05acc7b..0000000
--- a/test/memoryadvice/memorytest/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.google.android.apps.internal.games.memorytest">
-</manifest>
diff --git a/test/memoryadvice/memorytest/src/main/cpp/CMakeLists.txt b/test/memoryadvice/memorytest/src/main/cpp/CMakeLists.txt
deleted file mode 100644
index 701354d..0000000
--- a/test/memoryadvice/memorytest/src/main/cpp/CMakeLists.txt
+++ /dev/null
@@ -1,38 +0,0 @@
-# For more information about using CMake with Android Studio, read the
-# documentation: https://d.android.com/studio/projects/add-native-code.html
-
-# Sets the minimum version of CMake required to build the native library.
-
-cmake_minimum_required(VERSION 3.4.1)
-project(memory-test)
-
-# Creates and names a library, sets it as either STATIC
-# or SHARED, and provides the relative paths to its source code.
-# You can define multiple libraries, and CMake builds them for you.
-# Gradle automatically packages shared libraries with your APK.
-
-add_library( ${PROJECT_NAME} SHARED
- allocator.cc
- consumer.cc
- gl-memory.cc
- gl-utils.cc
- memory.cc
- mmap-allocator.cc
- mmap.cc
- test-renderer.cc
- test-vulkan-renderer.cc
- vk-memory.cc
- vulkan_wrapper/vulkan_wrapper.cpp
-
- memory-test.cc)
-
-# Specifies libraries CMake should link to your target library. You
-# can link multiple libraries, such as libraries you define in this
-# build script, prebuilt third-party libraries, or system libraries.
-
-target_link_libraries( ${PROJECT_NAME}
- android
- GLESv3
- log)
-
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVK_USE_PLATFORM_ANDROID_KHR")
diff --git a/test/memoryadvice/memorytest/src/main/cpp/allocator.cc b/test/memoryadvice/memorytest/src/main/cpp/allocator.cc
deleted file mode 100644
index 4b3e532..0000000
--- a/test/memoryadvice/memorytest/src/main/cpp/allocator.cc
+++ /dev/null
@@ -1,57 +0,0 @@
-#include "allocator.h"
-
-#include <android/log.h>
-
-#include "memory.h"
-
-namespace istresser_allocator {
-
-constexpr char kAppName[] = "memorytest";
-
-bool Allocator::Allocate(uint64_t bytes) {
- mtx.lock();
- bool result = true;
- while (result && bytes > 0) {
- uint64_t byte_count = bytes > SIZE_T_MAX ? SIZE_T_MAX : bytes;
- char *data = (char *)malloc(byte_count);
-
- if (data) {
- allocated.push_back(data);
- allocated_size.push_back(byte_count);
- LcgFill(data, byte_count);
- } else {
- result = false;
- __android_log_print(ANDROID_LOG_WARN, kAppName, "Could not allocate");
- }
- bytes -= byte_count;
- }
-
- mtx.unlock();
- return result;
-}
-
-void Allocator::Release() {
- mtx.lock();
- __android_log_print(ANDROID_LOG_INFO, kAppName, "Freeing entries");
- while (!allocated.empty()) {
- free(allocated.front());
- allocated.pop_front();
- allocated_size.pop_front();
- }
- mtx.unlock();
-}
-
-void Allocator::ReleasePartial(size_t bytes) {
- mtx.lock();
- __android_log_print(ANDROID_LOG_INFO, kAppName, "Freeing entries");
- size_t bytes_freed = 0;
- while (!allocated.empty() && bytes_freed < bytes) {
- free(allocated.front());
- allocated.pop_front();
- bytes_freed += allocated_size.front();
- allocated_size.pop_front();
- }
- mtx.unlock();
-}
-
-} // namespace istresser_allocator
diff --git a/test/memoryadvice/memorytest/src/main/cpp/allocator.h b/test/memoryadvice/memorytest/src/main/cpp/allocator.h
deleted file mode 100644
index 7676626..0000000
--- a/test/memoryadvice/memorytest/src/main/cpp/allocator.h
+++ /dev/null
@@ -1,23 +0,0 @@
-#pragma once
-
-#include <list>
-#include <mutex>
-
-namespace istresser_allocator {
-
-// An object to reserve and free memory.
-class Allocator {
- private:
- std::mutex mtx;
- std::list<char *> allocated;
- std::list<size_t> allocated_size;
-
- public:
- Allocator() = default;
- ~Allocator() = default;
- bool Allocate(uint64_t to_allocate);
- void Release();
- void ReleasePartial(size_t bytes);
-};
-
-} // namespace istresser_allocator
\ No newline at end of file
diff --git a/test/memoryadvice/memorytest/src/main/cpp/consumer.cc b/test/memoryadvice/memorytest/src/main/cpp/consumer.cc
deleted file mode 100644
index da5b345..0000000
--- a/test/memoryadvice/memorytest/src/main/cpp/consumer.cc
+++ /dev/null
@@ -1,62 +0,0 @@
-#include "consumer.h"
-
-#include <EGL/egl.h>
-#include <GLES3/gl32.h>
-
-#include <cmath>
-#include <vector>
-
-#include "android/log.h"
-#include "gl-utils.h"
-#include "memory.h"
-
-#define ALOGE(...) \
- __android_log_print(ANDROID_LOG_ERROR, "GlUtils", __VA_ARGS__)
-
-namespace istresser_consumer {
-
-Consumer::Consumer(int bytes) : vertex_buffer_(0), used_(0) {
- glGenBuffers(1, &vertex_buffer_);
- if (istresser_glutils::CheckGlError("glGenBuffers")) {
- return;
- }
- if (vertex_buffer_ == 0) {
- ALOGE("Could not gen buffers.");
- return;
- }
- glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer_);
- if (istresser_glutils::CheckGlError("glBindBuffer")) {
- return;
- }
- unsigned int num_vertices = bytes / sizeof(GLfloat);
- GLsizeiptr allocateBytes = num_vertices * sizeof(GLfloat);
- GLfloat *data = (GLfloat *)malloc(allocateBytes);
-
- if (!data) {
- ALOGE("Could not malloc for buffer.");
- return;
- }
-
- LcgFill(data, allocateBytes);
-
- glBufferData(GL_ARRAY_BUFFER, allocateBytes, data, GL_STATIC_DRAW);
- free(data);
- if (istresser_glutils::CheckGlError("glBufferData")) {
- ALOGE("Could not create buffers.");
- return;
- }
- used_ = allocateBytes;
-}
-
-Consumer::~Consumer() {
- if (vertex_buffer_ == 0) {
- ALOGE("Consumer was in invalid state - destructor does nothing.");
- return;
- }
- glDeleteBuffers(1, &vertex_buffer_);
- istresser_glutils::CheckGlError("glDeleteBuffers");
-}
-
-int Consumer::GetUsed() { return used_; }
-
-} // namespace istresser_consumer
diff --git a/test/memoryadvice/memorytest/src/main/cpp/consumer.h b/test/memoryadvice/memorytest/src/main/cpp/consumer.h
deleted file mode 100644
index 490a381..0000000
--- a/test/memoryadvice/memorytest/src/main/cpp/consumer.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#pragma once
-#include <GLES3/gl32.h>
-
-namespace istresser_consumer {
-
-// An object to reserve GL memory with glBufferData on construction,
-// and free it on destruction.
-class Consumer {
- public:
- Consumer(int bytes);
- ~Consumer();
-
- int GetUsed();
-
- private:
- GLuint vertex_buffer_{};
- int used_;
-};
-
-} // namespace istresser_consumer
\ No newline at end of file
diff --git a/test/memoryadvice/memorytest/src/main/cpp/gl-memory.cc b/test/memoryadvice/memorytest/src/main/cpp/gl-memory.cc
deleted file mode 100644
index 99f5817..0000000
--- a/test/memoryadvice/memorytest/src/main/cpp/gl-memory.cc
+++ /dev/null
@@ -1,32 +0,0 @@
-// Native entry points for Test Renderer.
-#include <jni.h>
-
-#include "test-renderer.h"
-
-namespace {
-istresser_testrenderer::TestRenderer *test_renderer;
-} // namespace
-
-extern "C" JNIEXPORT void JNICALL
-Java_com_google_android_apps_internal_games_memorytest_MemoryTest_initGl(
- JNIEnv *env, jclass thiz) {
- test_renderer = new istresser_testrenderer::TestRenderer();
-}
-
-extern "C" JNIEXPORT jint JNICALL
-Java_com_google_android_apps_internal_games_memorytest_MemoryTest_nativeDraw(
- JNIEnv *env, jclass clazz, jint toAllocate) {
- if (test_renderer == NULL) {
- return 0;
- } else {
- return test_renderer->Render(toAllocate);
- }
-}
-
-extern "C" JNIEXPORT void JNICALL
-Java_com_google_android_apps_internal_games_memorytest_MemoryTest_release(
- JNIEnv *env, jclass clazz) {
- if (test_renderer != NULL) {
- test_renderer->Release();
- }
-}
diff --git a/test/memoryadvice/memorytest/src/main/cpp/gl-utils.cc b/test/memoryadvice/memorytest/src/main/cpp/gl-utils.cc
deleted file mode 100644
index 99775a7..0000000
--- a/test/memoryadvice/memorytest/src/main/cpp/gl-utils.cc
+++ /dev/null
@@ -1,25 +0,0 @@
-#include "gl-utils.h"
-
-#include <GLES3/gl32.h>
-#include <android/log.h>
-#include <malloc.h>
-
-#define ALOGE(...) \
- __android_log_print(ANDROID_LOG_ERROR, "GlUtils", __VA_ARGS__)
-
-namespace istresser_glutils {
-
-bool CheckGlError(std::string_view funcName) {
- bool result = false;
- while (true) {
- GLint err = glGetError();
- if (err == GL_NO_ERROR) {
- break;
- }
- result = true;
- ALOGE("GL error after %s(): 0x%08x\n", funcName, err);
- }
- return result;
-}
-
-} // namespace istresser_glutils
diff --git a/test/memoryadvice/memorytest/src/main/cpp/gl-utils.h b/test/memoryadvice/memorytest/src/main/cpp/gl-utils.h
deleted file mode 100644
index 1784abf..0000000
--- a/test/memoryadvice/memorytest/src/main/cpp/gl-utils.h
+++ /dev/null
@@ -1,5 +0,0 @@
-#include <string>
-namespace istresser_glutils {
-// Utilities for GLES operation.
-extern bool CheckGlError(std::string_view funcName);
-} // namespace istresser_glutils
diff --git a/test/memoryadvice/memorytest/src/main/cpp/memory-test.cc b/test/memoryadvice/memorytest/src/main/cpp/memory-test.cc
deleted file mode 100644
index 310abc6..0000000
--- a/test/memoryadvice/memorytest/src/main/cpp/memory-test.cc
+++ /dev/null
@@ -1,33 +0,0 @@
-// Native entry points for native memory ('malloc') allocation and deallocation.
-
-#include <jni.h>
-
-#include "allocator.h"
-
-namespace {
-istresser_allocator::Allocator *allocator;
-} // namespace
-
-extern "C" JNIEXPORT void JNICALL
-Java_com_google_android_apps_internal_games_memorytest_MemoryTest_initNative(
- JNIEnv *env, jclass thiz) {
- allocator = new istresser_allocator::Allocator();
-}
-
-extern "C" JNIEXPORT jboolean JNICALL
-Java_com_google_android_apps_internal_games_memorytest_MemoryTest_nativeConsume(
- JNIEnv *env, jclass instance, jlong bytes) {
- return allocator->Allocate(bytes);
-}
-
-extern "C" JNIEXPORT void JNICALL
-Java_com_google_android_apps_internal_games_memorytest_MemoryTest_freeAll(
- JNIEnv *env, jclass instance) {
- return allocator->Release();
-}
-
-extern "C" JNIEXPORT void JNICALL
-Java_com_google_android_apps_internal_games_memorytest_MemoryTest_freeMemory(
- JNIEnv *env, jclass instance, jlong bytes) {
- return allocator->ReleasePartial(bytes);
-}
diff --git a/test/memoryadvice/memorytest/src/main/cpp/memory.cc b/test/memoryadvice/memorytest/src/main/cpp/memory.cc
deleted file mode 100644
index ef8563d..0000000
--- a/test/memoryadvice/memorytest/src/main/cpp/memory.cc
+++ /dev/null
@@ -1,36 +0,0 @@
-#include "memory.h"
-
-#include <stdint.h>
-#include <stdlib.h>
-
-static constexpr uint32_t kLcgPrime1 = 214013;
-static constexpr uint32_t kLcgPrime2 = 2531011;
-
-/**
- * Fill a specified area of memory with pseudo-random data and verify it was
- * correctly written.
- * @param addr The memory location to begin writing.
- * @param byte_len The number of bytes.
- * @return true if the memory was successfully written and verfied.
- */
-bool LcgFill(void *addr, size_t byte_len) {
- int i = rand();
- uint32_t lcg_current = (uint32_t)i;
- uint32_t *data = (uint32_t *)addr;
- size_t word_len = byte_len / 4;
- for (size_t word_count = 0; word_count < word_len; ++word_count) {
- lcg_current *= kLcgPrime1;
- lcg_current += kLcgPrime2;
- data[word_count] = lcg_current;
- }
- // Read back written data.
- lcg_current = (uint32_t)i;
- for (size_t word_count = 0; word_count < word_len; ++word_count) {
- lcg_current *= kLcgPrime1;
- lcg_current += kLcgPrime2;
- if (data[word_count] != lcg_current) {
- return false;
- }
- }
- return true;
-}
diff --git a/test/memoryadvice/memorytest/src/main/cpp/memory.h b/test/memoryadvice/memorytest/src/main/cpp/memory.h
deleted file mode 100644
index a585056..0000000
--- a/test/memoryadvice/memorytest/src/main/cpp/memory.h
+++ /dev/null
@@ -1,3 +0,0 @@
-#include <stddef.h>
-
-bool LcgFill(void *addr, size_t byte_len);
diff --git a/test/memoryadvice/memorytest/src/main/cpp/mmap-allocator.cc b/test/memoryadvice/memorytest/src/main/cpp/mmap-allocator.cc
deleted file mode 100644
index ba1a627..0000000
--- a/test/memoryadvice/memorytest/src/main/cpp/mmap-allocator.cc
+++ /dev/null
@@ -1,106 +0,0 @@
-#include "mmap-allocator.h"
-
-#include <android/log.h>
-#include <fcntl.h> // For open
-#include <limits.h>
-#include <sys/mman.h> // For mmap
-#include <sys/stat.h> // For fstat
-#include <unistd.h>
-
-#include "memory.h"
-
-namespace istresser_mmap_allocator {
-
-constexpr char kAppName[] = "memorytest";
-
-// Read out mmapped memory, so there's no chance some runtime optimization will
-// cause the underlying file not to be read.
-// TODO(b/151615602): confirm in the object file this read actually happens.
-static void ReadAndIgnore(void *addr, size_t byte_len) {
- volatile char val = 0;
- char *ptr = (char *)addr;
- for (size_t i = 0; i < byte_len; ++i) {
- val = ptr[i];
- }
-}
-
-void MmapAllocator::AnonFreeAll() {
- mtx.lock();
- __android_log_print(ANDROID_LOG_INFO, kAppName, "Freeing anon mmap memory");
- while (!mmap_allocated.empty()) {
- if (munmap(mmap_allocated.front(), mmap_allocated_size.front()) != 0) {
- __android_log_print(ANDROID_LOG_INFO, kAppName,
- ": Could not release mmapped memory");
- }
- mmap_allocated.pop_front();
- mmap_allocated_size.pop_front();
- }
- mtx.unlock();
-}
-
-size_t MmapAllocator::Consume(size_t byte_count) {
- // Actual mmapped length will always be a multiple of the page size, so we
- // round up to that in order to account properly.
- int32_t page_size_align = sysconf(_SC_PAGE_SIZE) - 1;
- byte_count = (byte_count + page_size_align) & ~page_size_align;
-
- void *addr = mmap(nullptr, byte_count, PROT_READ | PROT_WRITE,
- MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
- if (addr == MAP_FAILED) {
- __android_log_print(ANDROID_LOG_WARN, kAppName, "Could not mmap");
- } else {
- __android_log_print(ANDROID_LOG_INFO, kAppName, "mmapped %u bytes at %p",
- byte_count, addr);
- LcgFill(addr, byte_count);
- mmap_allocated.push_back(addr);
- mmap_allocated_size.push_back(byte_count);
- }
- return addr != MAP_FAILED ? byte_count : 0;
-}
-
-size_t MmapAllocator::MmapFileConsume(const char *path, size_t bytes,
- long offset) {
- auto addr = MAP_FAILED;
- size_t byte_count = (size_t)bytes;
- size_t byte_offset = (size_t)offset;
-
- // Offset must be a multiple of the page size, so we round down.
- int32_t page_size_align = sysconf(_SC_PAGE_SIZE) - 1;
- byte_offset &= ~page_size_align;
-
- int file = open(path, O_RDONLY);
- __android_log_print(ANDROID_LOG_INFO, kAppName, "open fd is %d", file);
-
- if (file != -1) {
- struct stat sb;
- if (fstat(file, &sb) == -1) {
- __android_log_print(ANDROID_LOG_WARN, kAppName, "mmapFile: fstat failed");
- close(file);
- return 0;
- }
-
- if (byte_offset >= sb.st_size) {
- __android_log_print(ANDROID_LOG_WARN, kAppName,
- "mmapFile: map begins beyond EOF");
- return 0;
- } else if (byte_count + byte_offset > sb.st_size) {
- byte_offset = sb.st_size - byte_count;
- }
-
- addr = mmap(nullptr, byte_count, PROT_READ, MAP_PRIVATE, file, byte_offset);
- if (addr == MAP_FAILED) {
- __android_log_print(ANDROID_LOG_WARN, kAppName,
- "Could not mmap physical file");
- } else {
- __android_log_print(
- ANDROID_LOG_INFO, kAppName,
- "mmapped %zu bytes at %p from physical file %s (offset %zu)",
- byte_count, addr, path, byte_offset);
- ReadAndIgnore(addr, byte_count);
- }
- close(file);
- }
- return addr == MAP_FAILED ? 0 : byte_count;
-}
-
-} // namespace istresser_mmap_allocator
diff --git a/test/memoryadvice/memorytest/src/main/cpp/mmap-allocator.h b/test/memoryadvice/memorytest/src/main/cpp/mmap-allocator.h
deleted file mode 100644
index e7096e2..0000000
--- a/test/memoryadvice/memorytest/src/main/cpp/mmap-allocator.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#pragma once
-
-#include <list>
-#include <mutex>
-
-namespace istresser_mmap_allocator {
-
-// An object to reserve and free mapped memory.
-class MmapAllocator {
- private:
- std::mutex mtx;
- std::list<void *> mmap_allocated;
- std::list<size_t> mmap_allocated_size;
-
- public:
- MmapAllocator() = default;
- ~MmapAllocator() = default;
-
- void AnonFreeAll();
- size_t Consume(size_t bytes);
- size_t MmapFileConsume(const char *path, size_t bytes, long offset);
-};
-
-} // namespace istresser_mmap_allocator
\ No newline at end of file
diff --git a/test/memoryadvice/memorytest/src/main/cpp/mmap.cc b/test/memoryadvice/memorytest/src/main/cpp/mmap.cc
deleted file mode 100644
index a52faa5..0000000
--- a/test/memoryadvice/memorytest/src/main/cpp/mmap.cc
+++ /dev/null
@@ -1,64 +0,0 @@
-// Native entry points for mmap methods.
-#include <jni.h>
-
-#include "memory.h"
-#include "mmap-allocator.h"
-
-namespace {
-constexpr char kAppName[] = "memorytest";
-static constexpr size_t randomFileBufSize = 16 * 1024;
-istresser_mmap_allocator::MmapAllocator *mmap_allocator;
-
-} // namespace
-
-extern "C" JNIEXPORT jboolean JNICALL
-Java_com_google_android_apps_internal_games_memorytest_MemoryTest_writeRandomFile(
- JNIEnv *env, jclass instance, jstring path, jlong total_bytes) {
- char buf[randomFileBufSize];
-
- const char *c_path = env->GetStringUTFChars(path, nullptr);
- if (c_path == nullptr) {
- return false;
- }
-
- FILE *file = fopen(c_path, "w");
- if (file == nullptr) {
- return false;
- }
-
- for (size_t bytes_written = 0; bytes_written < total_bytes;
- bytes_written += randomFileBufSize) {
- LcgFill(buf, randomFileBufSize);
- if (fwrite(buf, 1, randomFileBufSize, file) != randomFileBufSize) {
- return false;
- }
- }
-
- fclose(file);
- return true;
-}
-
-extern "C" JNIEXPORT void JNICALL
-Java_com_google_android_apps_internal_games_memorytest_MemoryTest_initMMap(
- JNIEnv *env, jclass clazz) {
- mmap_allocator = new istresser_mmap_allocator::MmapAllocator();
-}
-
-extern "C" JNIEXPORT void JNICALL
-Java_com_google_android_apps_internal_games_memorytest_MemoryTest_mmapAnonFreeAll(
- JNIEnv *env, jclass instance) {
- mmap_allocator->AnonFreeAll();
-}
-
-extern "C" JNIEXPORT int64_t JNICALL
-Java_com_google_android_apps_internal_games_memorytest_MemoryTest_mmapAnonConsume(
- JNIEnv *env, jclass instance, jlong bytes) {
- return mmap_allocator->Consume(bytes);
-}
-
-extern "C" JNIEXPORT int64_t JNICALL
-Java_com_google_android_apps_internal_games_memorytest_MemoryTest_mmapFileConsume(
- JNIEnv *env, jclass instance, jstring path, jlong bytes, jlong offset) {
- return mmap_allocator->MmapFileConsume(env->GetStringUTFChars(path, nullptr),
- bytes, offset);
-}
\ No newline at end of file
diff --git a/test/memoryadvice/memorytest/src/main/cpp/test-renderer.cc b/test/memoryadvice/memorytest/src/main/cpp/test-renderer.cc
deleted file mode 100644
index 0a3fa80..0000000
--- a/test/memoryadvice/memorytest/src/main/cpp/test-renderer.cc
+++ /dev/null
@@ -1,24 +0,0 @@
-#include "test-renderer.h"
-
-#include <EGL/egl.h>
-#include <GLES3/gl32.h>
-
-#include "consumer.h"
-
-namespace istresser_testrenderer {
-
-void TestRenderer::Release() { consumers_.clear(); }
-
-int TestRenderer::Render(int to_allocate) {
- istresser_consumer::Consumer *consumer =
- new istresser_consumer::Consumer(to_allocate);
- int used = consumer->GetUsed();
- if (used == 0) {
- delete consumer;
- } else {
- consumers_.emplace_back(consumer);
- }
- return used;
-}
-
-} // namespace istresser_testrenderer
diff --git a/test/memoryadvice/memorytest/src/main/cpp/test-renderer.h b/test/memoryadvice/memorytest/src/main/cpp/test-renderer.h
deleted file mode 100644
index b25704c..0000000
--- a/test/memoryadvice/memorytest/src/main/cpp/test-renderer.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#include <list>
-#include <memory>
-
-#include "consumer.h"
-
-namespace istresser_testrenderer {
-// A manager object that uses Consumers to hold GLES memory for the stress test.
-class TestRenderer {
- private:
- std::list<std::unique_ptr<istresser_consumer::Consumer>> consumers_;
-
- public:
- TestRenderer() = default;
-
- ~TestRenderer() = default;
-
- int Render(int to_allocate);
-
- void Release();
-};
-} // namespace istresser_testrenderer
diff --git a/test/memoryadvice/memorytest/src/main/cpp/test-vulkan-renderer.cc b/test/memoryadvice/memorytest/src/main/cpp/test-vulkan-renderer.cc
deleted file mode 100644
index c4c592e..0000000
--- a/test/memoryadvice/memorytest/src/main/cpp/test-vulkan-renderer.cc
+++ /dev/null
@@ -1,156 +0,0 @@
-#include "test-vulkan-renderer.h"
-
-#include <android/log.h>
-
-#include <vector>
-
-constexpr char kAppName[] = "memorytest";
-
-#define CALL_VK(func) \
- if (VK_SUCCESS != (func)) { \
- __android_log_print(ANDROID_LOG_ERROR, kAppName, \
- "Vulkan error. File[%s], line[%d]", __FILE__, \
- __LINE__); \
- assert(false); \
- }
-
-namespace istresser_testvulkanrenderer {
-
-TestVulkanRenderer::TestVulkanRenderer() {
- if (!InitVulkan()) {
- __android_log_print(ANDROID_LOG_INFO, kAppName, "Could not start Vulkan");
- return;
- }
-
- VkApplicationInfo appInfo = {
- .sType = VK_STRUCTURE_TYPE_APPLICATION_INFO,
- .pNext = nullptr,
- .apiVersion = VK_MAKE_VERSION(1, 0, 0),
- .applicationVersion = VK_MAKE_VERSION(1, 0, 0),
- .engineVersion = VK_MAKE_VERSION(1, 0, 0),
- .pApplicationName = kAppName,
- .pEngineName = kAppName,
- };
-
- VkInstanceCreateInfo instanceCreateInfo{
- .sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
- .pNext = nullptr,
- .pApplicationInfo = &appInfo,
- .enabledExtensionCount = 0,
- .ppEnabledExtensionNames = nullptr,
- .enabledLayerCount = 0,
- .ppEnabledLayerNames = nullptr,
- };
- VkInstance instance;
- CALL_VK(vkCreateInstance(&instanceCreateInfo, nullptr, &instance));
-
- uint32_t gpuCount = 0;
- CALL_VK(vkEnumeratePhysicalDevices(instance, &gpuCount, nullptr));
- VkPhysicalDevice tmpGpus[gpuCount];
- CALL_VK(vkEnumeratePhysicalDevices(instance, &gpuCount, tmpGpus));
- physicalDevice = tmpGpus[0];
-
- uint32_t queueFamilyCount;
- vkGetPhysicalDeviceQueueFamilyProperties(physicalDevice, &queueFamilyCount,
- nullptr);
- assert(queueFamilyCount);
- std::vector<VkQueueFamilyProperties> queueFamilyProperties(queueFamilyCount);
- vkGetPhysicalDeviceQueueFamilyProperties(physicalDevice, &queueFamilyCount,
- queueFamilyProperties.data());
-
- uint32_t queueFamilyIndex;
- for (queueFamilyIndex = 0; queueFamilyIndex < queueFamilyCount;
- queueFamilyIndex++) {
- if (queueFamilyProperties[queueFamilyIndex].queueFlags &
- VK_QUEUE_GRAPHICS_BIT) {
- break;
- }
- }
-
- float priorities[] = {1.0f};
-
- VkDeviceQueueCreateInfo queueCreateInfo{
- .sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO,
- .pNext = nullptr,
- .flags = 0,
- .queueCount = 1,
- .queueFamilyIndex = queueFamilyIndex,
- .pQueuePriorities = priorities,
- };
-
- VkDeviceCreateInfo deviceCreateInfo{
- .sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO,
- .pNext = nullptr,
- .queueCreateInfoCount = 1,
- .pQueueCreateInfos = &queueCreateInfo,
- .enabledLayerCount = 0,
- .ppEnabledLayerNames = nullptr,
- .enabledExtensionCount = 0,
- .ppEnabledExtensionNames = nullptr,
- .pEnabledFeatures = nullptr,
- };
-
- CALL_VK(vkCreateDevice(physicalDevice, &deviceCreateInfo, nullptr, &device));
-}
-
-bool TestVulkanRenderer::MapMemoryTypeToIndex(uint32_t typeBits,
- VkFlags requirements_mask,
- uint32_t *typeIndex) {
- VkPhysicalDeviceMemoryProperties memoryProperties;
- vkGetPhysicalDeviceMemoryProperties(physicalDevice, &memoryProperties);
- for (uint32_t i = 0; i < VK_MAX_MEMORY_TYPES; i++) {
- if ((typeBits & 1) == 1) {
- if ((memoryProperties.memoryTypes[i].propertyFlags & requirements_mask) ==
- requirements_mask) {
- *typeIndex = i;
- return true;
- }
- }
- typeBits >>= 1;
- }
- return false;
-}
-
-void TestVulkanRenderer::Release() {
- for (std::list<VkDeviceMemory>::iterator it = deviceMemoryHandles.begin();
- it != deviceMemoryHandles.end(); it++) {
- vkFreeMemory(device, *it, nullptr);
- }
- deviceMemoryHandles.clear();
-}
-
-int64_t TestVulkanRenderer::Allocate(int64_t to_allocate) {
- if (device == VK_NULL_HANDLE) {
- return 0;
- }
- VkMemoryAllocateInfo allocInfo{
- .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
- .pNext = nullptr,
- .allocationSize = (VkDeviceSize)to_allocate,
- .memoryTypeIndex = 0,
- };
-
- MapMemoryTypeToIndex((uint32_t)-1,
- VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
- VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
- &allocInfo.memoryTypeIndex);
-
- VkDeviceMemory deviceMemory;
- VkResult result =
- vkAllocateMemory(device, &allocInfo, nullptr, &deviceMemory);
- if (result != VK_SUCCESS) {
- return 0;
- }
-
- void *data;
- CALL_VK(
- vkMapMemory(device, deviceMemory, 0, allocInfo.allocationSize, 0, &data));
- memset(data, -1, (size_t)to_allocate);
- vkUnmapMemory(device, deviceMemory);
-
- deviceMemoryHandles.push_back(deviceMemory);
-
- return to_allocate;
-}
-
-} // namespace istresser_testvulkanrenderer
diff --git a/test/memoryadvice/memorytest/src/main/cpp/test-vulkan-renderer.h b/test/memoryadvice/memorytest/src/main/cpp/test-vulkan-renderer.h
deleted file mode 100644
index 82d6504..0000000
--- a/test/memoryadvice/memorytest/src/main/cpp/test-vulkan-renderer.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#include <list>
-
-#include "vulkan_wrapper/vulkan_wrapper.h"
-
-namespace istresser_testvulkanrenderer {
-
-// A manager object that allocates memory via the Vulkan API.
-class TestVulkanRenderer {
- private:
- VkPhysicalDevice physicalDevice = VK_NULL_HANDLE;
- VkDevice device = VK_NULL_HANDLE;
- std::list<VkDeviceMemory> deviceMemoryHandles;
-
- bool MapMemoryTypeToIndex(uint32_t typeBits, VkFlags requirements_mask,
- uint32_t *typeIndex);
-
- public:
- TestVulkanRenderer();
-
- ~TestVulkanRenderer() = default;
-
- int64_t Allocate(int64_t to_allocate);
-
- void Release();
-};
-} // namespace istresser_testvulkanrenderer
diff --git a/test/memoryadvice/memorytest/src/main/cpp/vk-memory.cc b/test/memoryadvice/memorytest/src/main/cpp/vk-memory.cc
deleted file mode 100644
index b9a3c6c..0000000
--- a/test/memoryadvice/memorytest/src/main/cpp/vk-memory.cc
+++ /dev/null
@@ -1,26 +0,0 @@
-// Native entry points for Test Vulkan Renderer.
-#include <jni.h>
-
-#include "test-vulkan-renderer.h"
-
-namespace {
-istresser_testvulkanrenderer::TestVulkanRenderer *test_vulkan_renderer;
-} // namespace
-
-extern "C" JNIEXPORT jlong JNICALL
-Java_com_google_android_apps_internal_games_memorytest_MemoryTest_vkAlloc(
- JNIEnv *env, jclass clazz, jlong size) {
- if (test_vulkan_renderer == NULL) {
- test_vulkan_renderer =
- new istresser_testvulkanrenderer::TestVulkanRenderer();
- }
- return test_vulkan_renderer->Allocate(size);
-}
-
-extern "C" JNIEXPORT void JNICALL
-Java_com_google_android_apps_internal_games_memorytest_MemoryTest_vkRelease(
- JNIEnv *env, jclass clazz) {
- if (test_vulkan_renderer != NULL) {
- test_vulkan_renderer->Release();
- }
-}
\ No newline at end of file
diff --git a/test/memoryadvice/memorytest/src/main/cpp/vulkan_wrapper/.clang-format b/test/memoryadvice/memorytest/src/main/cpp/vulkan_wrapper/.clang-format
deleted file mode 100644
index 37f3d57..0000000
--- a/test/memoryadvice/memorytest/src/main/cpp/vulkan_wrapper/.clang-format
+++ /dev/null
@@ -1 +0,0 @@
-DisableFormat: true
\ No newline at end of file
diff --git a/test/memoryadvice/memorytest/src/main/cpp/vulkan_wrapper/vulkan_wrapper.cpp b/test/memoryadvice/memorytest/src/main/cpp/vulkan_wrapper/vulkan_wrapper.cpp
deleted file mode 100644
index e1c0f2b..0000000
--- a/test/memoryadvice/memorytest/src/main/cpp/vulkan_wrapper/vulkan_wrapper.cpp
+++ /dev/null
@@ -1,404 +0,0 @@
-// Copyright 2016 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-// This file is generated.
-#include "vulkan_wrapper.h"
-#include <dlfcn.h>
-
-int InitVulkan(void) {
- void* libvulkan = dlopen("libvulkan.so", RTLD_NOW | RTLD_LOCAL);
- if (!libvulkan)
- return 0;
-
- // Vulkan supported, set function addresses
- vkCreateInstance = reinterpret_cast<PFN_vkCreateInstance>(dlsym(libvulkan, "vkCreateInstance"));
- vkDestroyInstance = reinterpret_cast<PFN_vkDestroyInstance>(dlsym(libvulkan, "vkDestroyInstance"));
- vkEnumeratePhysicalDevices = reinterpret_cast<PFN_vkEnumeratePhysicalDevices>(dlsym(libvulkan, "vkEnumeratePhysicalDevices"));
- vkGetPhysicalDeviceFeatures = reinterpret_cast<PFN_vkGetPhysicalDeviceFeatures>(dlsym(libvulkan, "vkGetPhysicalDeviceFeatures"));
- vkGetPhysicalDeviceFormatProperties = reinterpret_cast<PFN_vkGetPhysicalDeviceFormatProperties>(dlsym(libvulkan, "vkGetPhysicalDeviceFormatProperties"));
- vkGetPhysicalDeviceImageFormatProperties = reinterpret_cast<PFN_vkGetPhysicalDeviceImageFormatProperties>(dlsym(libvulkan, "vkGetPhysicalDeviceImageFormatProperties"));
- vkGetPhysicalDeviceProperties = reinterpret_cast<PFN_vkGetPhysicalDeviceProperties>(dlsym(libvulkan, "vkGetPhysicalDeviceProperties"));
- vkGetPhysicalDeviceQueueFamilyProperties = reinterpret_cast<PFN_vkGetPhysicalDeviceQueueFamilyProperties>(dlsym(libvulkan, "vkGetPhysicalDeviceQueueFamilyProperties"));
- vkGetPhysicalDeviceMemoryProperties = reinterpret_cast<PFN_vkGetPhysicalDeviceMemoryProperties>(dlsym(libvulkan, "vkGetPhysicalDeviceMemoryProperties"));
- vkGetInstanceProcAddr = reinterpret_cast<PFN_vkGetInstanceProcAddr>(dlsym(libvulkan, "vkGetInstanceProcAddr"));
- vkGetDeviceProcAddr = reinterpret_cast<PFN_vkGetDeviceProcAddr>(dlsym(libvulkan, "vkGetDeviceProcAddr"));
- vkCreateDevice = reinterpret_cast<PFN_vkCreateDevice>(dlsym(libvulkan, "vkCreateDevice"));
- vkDestroyDevice = reinterpret_cast<PFN_vkDestroyDevice>(dlsym(libvulkan, "vkDestroyDevice"));
- vkEnumerateInstanceExtensionProperties = reinterpret_cast<PFN_vkEnumerateInstanceExtensionProperties>(dlsym(libvulkan, "vkEnumerateInstanceExtensionProperties"));
- vkEnumerateDeviceExtensionProperties = reinterpret_cast<PFN_vkEnumerateDeviceExtensionProperties>(dlsym(libvulkan, "vkEnumerateDeviceExtensionProperties"));
- vkEnumerateInstanceLayerProperties = reinterpret_cast<PFN_vkEnumerateInstanceLayerProperties>(dlsym(libvulkan, "vkEnumerateInstanceLayerProperties"));
- vkEnumerateDeviceLayerProperties = reinterpret_cast<PFN_vkEnumerateDeviceLayerProperties>(dlsym(libvulkan, "vkEnumerateDeviceLayerProperties"));
- vkGetDeviceQueue = reinterpret_cast<PFN_vkGetDeviceQueue>(dlsym(libvulkan, "vkGetDeviceQueue"));
- vkQueueSubmit = reinterpret_cast<PFN_vkQueueSubmit>(dlsym(libvulkan, "vkQueueSubmit"));
- vkQueueWaitIdle = reinterpret_cast<PFN_vkQueueWaitIdle>(dlsym(libvulkan, "vkQueueWaitIdle"));
- vkDeviceWaitIdle = reinterpret_cast<PFN_vkDeviceWaitIdle>(dlsym(libvulkan, "vkDeviceWaitIdle"));
- vkAllocateMemory = reinterpret_cast<PFN_vkAllocateMemory>(dlsym(libvulkan, "vkAllocateMemory"));
- vkFreeMemory = reinterpret_cast<PFN_vkFreeMemory>(dlsym(libvulkan, "vkFreeMemory"));
- vkMapMemory = reinterpret_cast<PFN_vkMapMemory>(dlsym(libvulkan, "vkMapMemory"));
- vkUnmapMemory = reinterpret_cast<PFN_vkUnmapMemory>(dlsym(libvulkan, "vkUnmapMemory"));
- vkFlushMappedMemoryRanges = reinterpret_cast<PFN_vkFlushMappedMemoryRanges>(dlsym(libvulkan, "vkFlushMappedMemoryRanges"));
- vkInvalidateMappedMemoryRanges = reinterpret_cast<PFN_vkInvalidateMappedMemoryRanges>(dlsym(libvulkan, "vkInvalidateMappedMemoryRanges"));
- vkGetDeviceMemoryCommitment = reinterpret_cast<PFN_vkGetDeviceMemoryCommitment>(dlsym(libvulkan, "vkGetDeviceMemoryCommitment"));
- vkBindBufferMemory = reinterpret_cast<PFN_vkBindBufferMemory>(dlsym(libvulkan, "vkBindBufferMemory"));
- vkBindImageMemory = reinterpret_cast<PFN_vkBindImageMemory>(dlsym(libvulkan, "vkBindImageMemory"));
- vkGetBufferMemoryRequirements = reinterpret_cast<PFN_vkGetBufferMemoryRequirements>(dlsym(libvulkan, "vkGetBufferMemoryRequirements"));
- vkGetImageMemoryRequirements = reinterpret_cast<PFN_vkGetImageMemoryRequirements>(dlsym(libvulkan, "vkGetImageMemoryRequirements"));
- vkGetImageSparseMemoryRequirements = reinterpret_cast<PFN_vkGetImageSparseMemoryRequirements>(dlsym(libvulkan, "vkGetImageSparseMemoryRequirements"));
- vkGetPhysicalDeviceSparseImageFormatProperties = reinterpret_cast<PFN_vkGetPhysicalDeviceSparseImageFormatProperties>(dlsym(libvulkan, "vkGetPhysicalDeviceSparseImageFormatProperties"));
- vkQueueBindSparse = reinterpret_cast<PFN_vkQueueBindSparse>(dlsym(libvulkan, "vkQueueBindSparse"));
- vkCreateFence = reinterpret_cast<PFN_vkCreateFence>(dlsym(libvulkan, "vkCreateFence"));
- vkDestroyFence = reinterpret_cast<PFN_vkDestroyFence>(dlsym(libvulkan, "vkDestroyFence"));
- vkResetFences = reinterpret_cast<PFN_vkResetFences>(dlsym(libvulkan, "vkResetFences"));
- vkGetFenceStatus = reinterpret_cast<PFN_vkGetFenceStatus>(dlsym(libvulkan, "vkGetFenceStatus"));
- vkWaitForFences = reinterpret_cast<PFN_vkWaitForFences>(dlsym(libvulkan, "vkWaitForFences"));
- vkCreateSemaphore = reinterpret_cast<PFN_vkCreateSemaphore>(dlsym(libvulkan, "vkCreateSemaphore"));
- vkDestroySemaphore = reinterpret_cast<PFN_vkDestroySemaphore>(dlsym(libvulkan, "vkDestroySemaphore"));
- vkCreateEvent = reinterpret_cast<PFN_vkCreateEvent>(dlsym(libvulkan, "vkCreateEvent"));
- vkDestroyEvent = reinterpret_cast<PFN_vkDestroyEvent>(dlsym(libvulkan, "vkDestroyEvent"));
- vkGetEventStatus = reinterpret_cast<PFN_vkGetEventStatus>(dlsym(libvulkan, "vkGetEventStatus"));
- vkSetEvent = reinterpret_cast<PFN_vkSetEvent>(dlsym(libvulkan, "vkSetEvent"));
- vkResetEvent = reinterpret_cast<PFN_vkResetEvent>(dlsym(libvulkan, "vkResetEvent"));
- vkCreateQueryPool = reinterpret_cast<PFN_vkCreateQueryPool>(dlsym(libvulkan, "vkCreateQueryPool"));
- vkDestroyQueryPool = reinterpret_cast<PFN_vkDestroyQueryPool>(dlsym(libvulkan, "vkDestroyQueryPool"));
- vkGetQueryPoolResults = reinterpret_cast<PFN_vkGetQueryPoolResults>(dlsym(libvulkan, "vkGetQueryPoolResults"));
- vkCreateBuffer = reinterpret_cast<PFN_vkCreateBuffer>(dlsym(libvulkan, "vkCreateBuffer"));
- vkDestroyBuffer = reinterpret_cast<PFN_vkDestroyBuffer>(dlsym(libvulkan, "vkDestroyBuffer"));
- vkCreateBufferView = reinterpret_cast<PFN_vkCreateBufferView>(dlsym(libvulkan, "vkCreateBufferView"));
- vkDestroyBufferView = reinterpret_cast<PFN_vkDestroyBufferView>(dlsym(libvulkan, "vkDestroyBufferView"));
- vkCreateImage = reinterpret_cast<PFN_vkCreateImage>(dlsym(libvulkan, "vkCreateImage"));
- vkDestroyImage = reinterpret_cast<PFN_vkDestroyImage>(dlsym(libvulkan, "vkDestroyImage"));
- vkGetImageSubresourceLayout = reinterpret_cast<PFN_vkGetImageSubresourceLayout>(dlsym(libvulkan, "vkGetImageSubresourceLayout"));
- vkCreateImageView = reinterpret_cast<PFN_vkCreateImageView>(dlsym(libvulkan, "vkCreateImageView"));
- vkDestroyImageView = reinterpret_cast<PFN_vkDestroyImageView>(dlsym(libvulkan, "vkDestroyImageView"));
- vkCreateShaderModule = reinterpret_cast<PFN_vkCreateShaderModule>(dlsym(libvulkan, "vkCreateShaderModule"));
- vkDestroyShaderModule = reinterpret_cast<PFN_vkDestroyShaderModule>(dlsym(libvulkan, "vkDestroyShaderModule"));
- vkCreatePipelineCache = reinterpret_cast<PFN_vkCreatePipelineCache>(dlsym(libvulkan, "vkCreatePipelineCache"));
- vkDestroyPipelineCache = reinterpret_cast<PFN_vkDestroyPipelineCache>(dlsym(libvulkan, "vkDestroyPipelineCache"));
- vkGetPipelineCacheData = reinterpret_cast<PFN_vkGetPipelineCacheData>(dlsym(libvulkan, "vkGetPipelineCacheData"));
- vkMergePipelineCaches = reinterpret_cast<PFN_vkMergePipelineCaches>(dlsym(libvulkan, "vkMergePipelineCaches"));
- vkCreateGraphicsPipelines = reinterpret_cast<PFN_vkCreateGraphicsPipelines>(dlsym(libvulkan, "vkCreateGraphicsPipelines"));
- vkCreateComputePipelines = reinterpret_cast<PFN_vkCreateComputePipelines>(dlsym(libvulkan, "vkCreateComputePipelines"));
- vkDestroyPipeline = reinterpret_cast<PFN_vkDestroyPipeline>(dlsym(libvulkan, "vkDestroyPipeline"));
- vkCreatePipelineLayout = reinterpret_cast<PFN_vkCreatePipelineLayout>(dlsym(libvulkan, "vkCreatePipelineLayout"));
- vkDestroyPipelineLayout = reinterpret_cast<PFN_vkDestroyPipelineLayout>(dlsym(libvulkan, "vkDestroyPipelineLayout"));
- vkCreateSampler = reinterpret_cast<PFN_vkCreateSampler>(dlsym(libvulkan, "vkCreateSampler"));
- vkDestroySampler = reinterpret_cast<PFN_vkDestroySampler>(dlsym(libvulkan, "vkDestroySampler"));
- vkCreateDescriptorSetLayout = reinterpret_cast<PFN_vkCreateDescriptorSetLayout>(dlsym(libvulkan, "vkCreateDescriptorSetLayout"));
- vkDestroyDescriptorSetLayout = reinterpret_cast<PFN_vkDestroyDescriptorSetLayout>(dlsym(libvulkan, "vkDestroyDescriptorSetLayout"));
- vkCreateDescriptorPool = reinterpret_cast<PFN_vkCreateDescriptorPool>(dlsym(libvulkan, "vkCreateDescriptorPool"));
- vkDestroyDescriptorPool = reinterpret_cast<PFN_vkDestroyDescriptorPool>(dlsym(libvulkan, "vkDestroyDescriptorPool"));
- vkResetDescriptorPool = reinterpret_cast<PFN_vkResetDescriptorPool>(dlsym(libvulkan, "vkResetDescriptorPool"));
- vkAllocateDescriptorSets = reinterpret_cast<PFN_vkAllocateDescriptorSets>(dlsym(libvulkan, "vkAllocateDescriptorSets"));
- vkFreeDescriptorSets = reinterpret_cast<PFN_vkFreeDescriptorSets>(dlsym(libvulkan, "vkFreeDescriptorSets"));
- vkUpdateDescriptorSets = reinterpret_cast<PFN_vkUpdateDescriptorSets>(dlsym(libvulkan, "vkUpdateDescriptorSets"));
- vkCreateFramebuffer = reinterpret_cast<PFN_vkCreateFramebuffer>(dlsym(libvulkan, "vkCreateFramebuffer"));
- vkDestroyFramebuffer = reinterpret_cast<PFN_vkDestroyFramebuffer>(dlsym(libvulkan, "vkDestroyFramebuffer"));
- vkCreateRenderPass = reinterpret_cast<PFN_vkCreateRenderPass>(dlsym(libvulkan, "vkCreateRenderPass"));
- vkDestroyRenderPass = reinterpret_cast<PFN_vkDestroyRenderPass>(dlsym(libvulkan, "vkDestroyRenderPass"));
- vkGetRenderAreaGranularity = reinterpret_cast<PFN_vkGetRenderAreaGranularity>(dlsym(libvulkan, "vkGetRenderAreaGranularity"));
- vkCreateCommandPool = reinterpret_cast<PFN_vkCreateCommandPool>(dlsym(libvulkan, "vkCreateCommandPool"));
- vkDestroyCommandPool = reinterpret_cast<PFN_vkDestroyCommandPool>(dlsym(libvulkan, "vkDestroyCommandPool"));
- vkResetCommandPool = reinterpret_cast<PFN_vkResetCommandPool>(dlsym(libvulkan, "vkResetCommandPool"));
- vkAllocateCommandBuffers = reinterpret_cast<PFN_vkAllocateCommandBuffers>(dlsym(libvulkan, "vkAllocateCommandBuffers"));
- vkFreeCommandBuffers = reinterpret_cast<PFN_vkFreeCommandBuffers>(dlsym(libvulkan, "vkFreeCommandBuffers"));
- vkBeginCommandBuffer = reinterpret_cast<PFN_vkBeginCommandBuffer>(dlsym(libvulkan, "vkBeginCommandBuffer"));
- vkEndCommandBuffer = reinterpret_cast<PFN_vkEndCommandBuffer>(dlsym(libvulkan, "vkEndCommandBuffer"));
- vkResetCommandBuffer = reinterpret_cast<PFN_vkResetCommandBuffer>(dlsym(libvulkan, "vkResetCommandBuffer"));
- vkCmdBindPipeline = reinterpret_cast<PFN_vkCmdBindPipeline>(dlsym(libvulkan, "vkCmdBindPipeline"));
- vkCmdSetViewport = reinterpret_cast<PFN_vkCmdSetViewport>(dlsym(libvulkan, "vkCmdSetViewport"));
- vkCmdSetScissor = reinterpret_cast<PFN_vkCmdSetScissor>(dlsym(libvulkan, "vkCmdSetScissor"));
- vkCmdSetLineWidth = reinterpret_cast<PFN_vkCmdSetLineWidth>(dlsym(libvulkan, "vkCmdSetLineWidth"));
- vkCmdSetDepthBias = reinterpret_cast<PFN_vkCmdSetDepthBias>(dlsym(libvulkan, "vkCmdSetDepthBias"));
- vkCmdSetBlendConstants = reinterpret_cast<PFN_vkCmdSetBlendConstants>(dlsym(libvulkan, "vkCmdSetBlendConstants"));
- vkCmdSetDepthBounds = reinterpret_cast<PFN_vkCmdSetDepthBounds>(dlsym(libvulkan, "vkCmdSetDepthBounds"));
- vkCmdSetStencilCompareMask = reinterpret_cast<PFN_vkCmdSetStencilCompareMask>(dlsym(libvulkan, "vkCmdSetStencilCompareMask"));
- vkCmdSetStencilWriteMask = reinterpret_cast<PFN_vkCmdSetStencilWriteMask>(dlsym(libvulkan, "vkCmdSetStencilWriteMask"));
- vkCmdSetStencilReference = reinterpret_cast<PFN_vkCmdSetStencilReference>(dlsym(libvulkan, "vkCmdSetStencilReference"));
- vkCmdBindDescriptorSets = reinterpret_cast<PFN_vkCmdBindDescriptorSets>(dlsym(libvulkan, "vkCmdBindDescriptorSets"));
- vkCmdBindIndexBuffer = reinterpret_cast<PFN_vkCmdBindIndexBuffer>(dlsym(libvulkan, "vkCmdBindIndexBuffer"));
- vkCmdBindVertexBuffers = reinterpret_cast<PFN_vkCmdBindVertexBuffers>(dlsym(libvulkan, "vkCmdBindVertexBuffers"));
- vkCmdDraw = reinterpret_cast<PFN_vkCmdDraw>(dlsym(libvulkan, "vkCmdDraw"));
- vkCmdDrawIndexed = reinterpret_cast<PFN_vkCmdDrawIndexed>(dlsym(libvulkan, "vkCmdDrawIndexed"));
- vkCmdDrawIndirect = reinterpret_cast<PFN_vkCmdDrawIndirect>(dlsym(libvulkan, "vkCmdDrawIndirect"));
- vkCmdDrawIndexedIndirect = reinterpret_cast<PFN_vkCmdDrawIndexedIndirect>(dlsym(libvulkan, "vkCmdDrawIndexedIndirect"));
- vkCmdDispatch = reinterpret_cast<PFN_vkCmdDispatch>(dlsym(libvulkan, "vkCmdDispatch"));
- vkCmdDispatchIndirect = reinterpret_cast<PFN_vkCmdDispatchIndirect>(dlsym(libvulkan, "vkCmdDispatchIndirect"));
- vkCmdCopyBuffer = reinterpret_cast<PFN_vkCmdCopyBuffer>(dlsym(libvulkan, "vkCmdCopyBuffer"));
- vkCmdCopyImage = reinterpret_cast<PFN_vkCmdCopyImage>(dlsym(libvulkan, "vkCmdCopyImage"));
- vkCmdBlitImage = reinterpret_cast<PFN_vkCmdBlitImage>(dlsym(libvulkan, "vkCmdBlitImage"));
- vkCmdCopyBufferToImage = reinterpret_cast<PFN_vkCmdCopyBufferToImage>(dlsym(libvulkan, "vkCmdCopyBufferToImage"));
- vkCmdCopyImageToBuffer = reinterpret_cast<PFN_vkCmdCopyImageToBuffer>(dlsym(libvulkan, "vkCmdCopyImageToBuffer"));
- vkCmdUpdateBuffer = reinterpret_cast<PFN_vkCmdUpdateBuffer>(dlsym(libvulkan, "vkCmdUpdateBuffer"));
- vkCmdFillBuffer = reinterpret_cast<PFN_vkCmdFillBuffer>(dlsym(libvulkan, "vkCmdFillBuffer"));
- vkCmdClearColorImage = reinterpret_cast<PFN_vkCmdClearColorImage>(dlsym(libvulkan, "vkCmdClearColorImage"));
- vkCmdClearDepthStencilImage = reinterpret_cast<PFN_vkCmdClearDepthStencilImage>(dlsym(libvulkan, "vkCmdClearDepthStencilImage"));
- vkCmdClearAttachments = reinterpret_cast<PFN_vkCmdClearAttachments>(dlsym(libvulkan, "vkCmdClearAttachments"));
- vkCmdResolveImage = reinterpret_cast<PFN_vkCmdResolveImage>(dlsym(libvulkan, "vkCmdResolveImage"));
- vkCmdSetEvent = reinterpret_cast<PFN_vkCmdSetEvent>(dlsym(libvulkan, "vkCmdSetEvent"));
- vkCmdResetEvent = reinterpret_cast<PFN_vkCmdResetEvent>(dlsym(libvulkan, "vkCmdResetEvent"));
- vkCmdWaitEvents = reinterpret_cast<PFN_vkCmdWaitEvents>(dlsym(libvulkan, "vkCmdWaitEvents"));
- vkCmdPipelineBarrier = reinterpret_cast<PFN_vkCmdPipelineBarrier>(dlsym(libvulkan, "vkCmdPipelineBarrier"));
- vkCmdBeginQuery = reinterpret_cast<PFN_vkCmdBeginQuery>(dlsym(libvulkan, "vkCmdBeginQuery"));
- vkCmdEndQuery = reinterpret_cast<PFN_vkCmdEndQuery>(dlsym(libvulkan, "vkCmdEndQuery"));
- vkCmdResetQueryPool = reinterpret_cast<PFN_vkCmdResetQueryPool>(dlsym(libvulkan, "vkCmdResetQueryPool"));
- vkCmdWriteTimestamp = reinterpret_cast<PFN_vkCmdWriteTimestamp>(dlsym(libvulkan, "vkCmdWriteTimestamp"));
- vkCmdCopyQueryPoolResults = reinterpret_cast<PFN_vkCmdCopyQueryPoolResults>(dlsym(libvulkan, "vkCmdCopyQueryPoolResults"));
- vkCmdPushConstants = reinterpret_cast<PFN_vkCmdPushConstants>(dlsym(libvulkan, "vkCmdPushConstants"));
- vkCmdBeginRenderPass = reinterpret_cast<PFN_vkCmdBeginRenderPass>(dlsym(libvulkan, "vkCmdBeginRenderPass"));
- vkCmdNextSubpass = reinterpret_cast<PFN_vkCmdNextSubpass>(dlsym(libvulkan, "vkCmdNextSubpass"));
- vkCmdEndRenderPass = reinterpret_cast<PFN_vkCmdEndRenderPass>(dlsym(libvulkan, "vkCmdEndRenderPass"));
- vkCmdExecuteCommands = reinterpret_cast<PFN_vkCmdExecuteCommands>(dlsym(libvulkan, "vkCmdExecuteCommands"));
- vkDestroySurfaceKHR = reinterpret_cast<PFN_vkDestroySurfaceKHR>(dlsym(libvulkan, "vkDestroySurfaceKHR"));
- vkGetPhysicalDeviceSurfaceSupportKHR = reinterpret_cast<PFN_vkGetPhysicalDeviceSurfaceSupportKHR>(dlsym(libvulkan, "vkGetPhysicalDeviceSurfaceSupportKHR"));
- vkGetPhysicalDeviceSurfaceCapabilitiesKHR = reinterpret_cast<PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR>(dlsym(libvulkan, "vkGetPhysicalDeviceSurfaceCapabilitiesKHR"));
- vkGetPhysicalDeviceSurfaceFormatsKHR = reinterpret_cast<PFN_vkGetPhysicalDeviceSurfaceFormatsKHR>(dlsym(libvulkan, "vkGetPhysicalDeviceSurfaceFormatsKHR"));
- vkGetPhysicalDeviceSurfacePresentModesKHR = reinterpret_cast<PFN_vkGetPhysicalDeviceSurfacePresentModesKHR>(dlsym(libvulkan, "vkGetPhysicalDeviceSurfacePresentModesKHR"));
- vkCreateSwapchainKHR = reinterpret_cast<PFN_vkCreateSwapchainKHR>(dlsym(libvulkan, "vkCreateSwapchainKHR"));
- vkDestroySwapchainKHR = reinterpret_cast<PFN_vkDestroySwapchainKHR>(dlsym(libvulkan, "vkDestroySwapchainKHR"));
- vkGetSwapchainImagesKHR = reinterpret_cast<PFN_vkGetSwapchainImagesKHR>(dlsym(libvulkan, "vkGetSwapchainImagesKHR"));
- vkAcquireNextImageKHR = reinterpret_cast<PFN_vkAcquireNextImageKHR>(dlsym(libvulkan, "vkAcquireNextImageKHR"));
- vkQueuePresentKHR = reinterpret_cast<PFN_vkQueuePresentKHR>(dlsym(libvulkan, "vkQueuePresentKHR"));
- vkGetPhysicalDeviceDisplayPropertiesKHR = reinterpret_cast<PFN_vkGetPhysicalDeviceDisplayPropertiesKHR>(dlsym(libvulkan, "vkGetPhysicalDeviceDisplayPropertiesKHR"));
- vkGetPhysicalDeviceDisplayPlanePropertiesKHR = reinterpret_cast<PFN_vkGetPhysicalDeviceDisplayPlanePropertiesKHR>(dlsym(libvulkan, "vkGetPhysicalDeviceDisplayPlanePropertiesKHR"));
- vkGetDisplayPlaneSupportedDisplaysKHR = reinterpret_cast<PFN_vkGetDisplayPlaneSupportedDisplaysKHR>(dlsym(libvulkan, "vkGetDisplayPlaneSupportedDisplaysKHR"));
- vkGetDisplayModePropertiesKHR = reinterpret_cast<PFN_vkGetDisplayModePropertiesKHR>(dlsym(libvulkan, "vkGetDisplayModePropertiesKHR"));
- vkCreateDisplayModeKHR = reinterpret_cast<PFN_vkCreateDisplayModeKHR>(dlsym(libvulkan, "vkCreateDisplayModeKHR"));
- vkGetDisplayPlaneCapabilitiesKHR = reinterpret_cast<PFN_vkGetDisplayPlaneCapabilitiesKHR>(dlsym(libvulkan, "vkGetDisplayPlaneCapabilitiesKHR"));
- vkCreateDisplayPlaneSurfaceKHR = reinterpret_cast<PFN_vkCreateDisplayPlaneSurfaceKHR>(dlsym(libvulkan, "vkCreateDisplayPlaneSurfaceKHR"));
- vkCreateSharedSwapchainsKHR = reinterpret_cast<PFN_vkCreateSharedSwapchainsKHR>(dlsym(libvulkan, "vkCreateSharedSwapchainsKHR"));
-
-#ifdef VK_USE_PLATFORM_XLIB_KHR
- vkCreateXlibSurfaceKHR = reinterpret_cast<PFN_vkCreateXlibSurfaceKHR>(dlsym(libvulkan, "vkCreateXlibSurfaceKHR"));
- vkGetPhysicalDeviceXlibPresentationSupportKHR = reinterpret_cast<PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR>(dlsym(libvulkan, "vkGetPhysicalDeviceXlibPresentationSupportKHR"));
-#endif
-
-#ifdef VK_USE_PLATFORM_XCB_KHR
- vkCreateXcbSurfaceKHR = reinterpret_cast<PFN_vkCreateXcbSurfaceKHR>(dlsym(libvulkan, "vkCreateXcbSurfaceKHR"));
- vkGetPhysicalDeviceXcbPresentationSupportKHR = reinterpret_cast<PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR>(dlsym(libvulkan, "vkGetPhysicalDeviceXcbPresentationSupportKHR"));
-#endif
-
-#ifdef VK_USE_PLATFORM_WAYLAND_KHR
- vkCreateWaylandSurfaceKHR = reinterpret_cast<PFN_vkCreateWaylandSurfaceKHR>(dlsym(libvulkan, "vkCreateWaylandSurfaceKHR"));
- vkGetPhysicalDeviceWaylandPresentationSupportKHR = reinterpret_cast<PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR>(dlsym(libvulkan, "vkGetPhysicalDeviceWaylandPresentationSupportKHR"));
-#endif
-
-#ifdef VK_USE_PLATFORM_MIR_KHR
- vkCreateMirSurfaceKHR = reinterpret_cast<PFN_vkCreateMirSurfaceKHR>(dlsym(libvulkan, "vkCreateMirSurfaceKHR"));
- vkGetPhysicalDeviceMirPresentationSupportKHR = reinterpret_cast<PFN_vkGetPhysicalDeviceMirPresentationSupportKHR>(dlsym(libvulkan, "vkGetPhysicalDeviceMirPresentationSupportKHR"));
-#endif
-
-#ifdef VK_USE_PLATFORM_ANDROID_KHR
- vkCreateAndroidSurfaceKHR = reinterpret_cast<PFN_vkCreateAndroidSurfaceKHR>(dlsym(libvulkan, "vkCreateAndroidSurfaceKHR"));
-#endif
-
-#ifdef VK_USE_PLATFORM_WIN32_KHR
- vkCreateWin32SurfaceKHR = reinterpret_cast<PFN_vkCreateWin32SurfaceKHR>(dlsym(libvulkan, "vkCreateWin32SurfaceKHR"));
- vkGetPhysicalDeviceWin32PresentationSupportKHR = reinterpret_cast<PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR>(dlsym(libvulkan, "vkGetPhysicalDeviceWin32PresentationSupportKHR"));
-#endif
-#ifdef USE_DEBUG_EXTENSIONS
- vkCreateDebugReportCallbackEXT = reinterpret_cast<PFN_vkCreateDebugReportCallbackEXT>(dlsym(libvulkan, "vkCreateDebugReportCallbackEXT"));
- vkDestroyDebugReportCallbackEXT = reinterpret_cast<PFN_vkDestroyDebugReportCallbackEXT>(dlsym(libvulkan, "vkDestroyDebugReportCallbackEXT"));
- vkDebugReportMessageEXT = reinterpret_cast<PFN_vkDebugReportMessageEXT>(dlsym(libvulkan, "vkDebugReportMessageEXT"));
-#endif
- return 1;
-}
-
-// No Vulkan support, do not set function addresses
-PFN_vkCreateInstance vkCreateInstance;
-PFN_vkDestroyInstance vkDestroyInstance;
-PFN_vkEnumeratePhysicalDevices vkEnumeratePhysicalDevices;
-PFN_vkGetPhysicalDeviceFeatures vkGetPhysicalDeviceFeatures;
-PFN_vkGetPhysicalDeviceFormatProperties vkGetPhysicalDeviceFormatProperties;
-PFN_vkGetPhysicalDeviceImageFormatProperties vkGetPhysicalDeviceImageFormatProperties;
-PFN_vkGetPhysicalDeviceProperties vkGetPhysicalDeviceProperties;
-PFN_vkGetPhysicalDeviceQueueFamilyProperties vkGetPhysicalDeviceQueueFamilyProperties;
-PFN_vkGetPhysicalDeviceMemoryProperties vkGetPhysicalDeviceMemoryProperties;
-PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr;
-PFN_vkGetDeviceProcAddr vkGetDeviceProcAddr;
-PFN_vkCreateDevice vkCreateDevice;
-PFN_vkDestroyDevice vkDestroyDevice;
-PFN_vkEnumerateInstanceExtensionProperties vkEnumerateInstanceExtensionProperties;
-PFN_vkEnumerateDeviceExtensionProperties vkEnumerateDeviceExtensionProperties;
-PFN_vkEnumerateInstanceLayerProperties vkEnumerateInstanceLayerProperties;
-PFN_vkEnumerateDeviceLayerProperties vkEnumerateDeviceLayerProperties;
-PFN_vkGetDeviceQueue vkGetDeviceQueue;
-PFN_vkQueueSubmit vkQueueSubmit;
-PFN_vkQueueWaitIdle vkQueueWaitIdle;
-PFN_vkDeviceWaitIdle vkDeviceWaitIdle;
-PFN_vkAllocateMemory vkAllocateMemory;
-PFN_vkFreeMemory vkFreeMemory;
-PFN_vkMapMemory vkMapMemory;
-PFN_vkUnmapMemory vkUnmapMemory;
-PFN_vkFlushMappedMemoryRanges vkFlushMappedMemoryRanges;
-PFN_vkInvalidateMappedMemoryRanges vkInvalidateMappedMemoryRanges;
-PFN_vkGetDeviceMemoryCommitment vkGetDeviceMemoryCommitment;
-PFN_vkBindBufferMemory vkBindBufferMemory;
-PFN_vkBindImageMemory vkBindImageMemory;
-PFN_vkGetBufferMemoryRequirements vkGetBufferMemoryRequirements;
-PFN_vkGetImageMemoryRequirements vkGetImageMemoryRequirements;
-PFN_vkGetImageSparseMemoryRequirements vkGetImageSparseMemoryRequirements;
-PFN_vkGetPhysicalDeviceSparseImageFormatProperties vkGetPhysicalDeviceSparseImageFormatProperties;
-PFN_vkQueueBindSparse vkQueueBindSparse;
-PFN_vkCreateFence vkCreateFence;
-PFN_vkDestroyFence vkDestroyFence;
-PFN_vkResetFences vkResetFences;
-PFN_vkGetFenceStatus vkGetFenceStatus;
-PFN_vkWaitForFences vkWaitForFences;
-PFN_vkCreateSemaphore vkCreateSemaphore;
-PFN_vkDestroySemaphore vkDestroySemaphore;
-PFN_vkCreateEvent vkCreateEvent;
-PFN_vkDestroyEvent vkDestroyEvent;
-PFN_vkGetEventStatus vkGetEventStatus;
-PFN_vkSetEvent vkSetEvent;
-PFN_vkResetEvent vkResetEvent;
-PFN_vkCreateQueryPool vkCreateQueryPool;
-PFN_vkDestroyQueryPool vkDestroyQueryPool;
-PFN_vkGetQueryPoolResults vkGetQueryPoolResults;
-PFN_vkCreateBuffer vkCreateBuffer;
-PFN_vkDestroyBuffer vkDestroyBuffer;
-PFN_vkCreateBufferView vkCreateBufferView;
-PFN_vkDestroyBufferView vkDestroyBufferView;
-PFN_vkCreateImage vkCreateImage;
-PFN_vkDestroyImage vkDestroyImage;
-PFN_vkGetImageSubresourceLayout vkGetImageSubresourceLayout;
-PFN_vkCreateImageView vkCreateImageView;
-PFN_vkDestroyImageView vkDestroyImageView;
-PFN_vkCreateShaderModule vkCreateShaderModule;
-PFN_vkDestroyShaderModule vkDestroyShaderModule;
-PFN_vkCreatePipelineCache vkCreatePipelineCache;
-PFN_vkDestroyPipelineCache vkDestroyPipelineCache;
-PFN_vkGetPipelineCacheData vkGetPipelineCacheData;
-PFN_vkMergePipelineCaches vkMergePipelineCaches;
-PFN_vkCreateGraphicsPipelines vkCreateGraphicsPipelines;
-PFN_vkCreateComputePipelines vkCreateComputePipelines;
-PFN_vkDestroyPipeline vkDestroyPipeline;
-PFN_vkCreatePipelineLayout vkCreatePipelineLayout;
-PFN_vkDestroyPipelineLayout vkDestroyPipelineLayout;
-PFN_vkCreateSampler vkCreateSampler;
-PFN_vkDestroySampler vkDestroySampler;
-PFN_vkCreateDescriptorSetLayout vkCreateDescriptorSetLayout;
-PFN_vkDestroyDescriptorSetLayout vkDestroyDescriptorSetLayout;
-PFN_vkCreateDescriptorPool vkCreateDescriptorPool;
-PFN_vkDestroyDescriptorPool vkDestroyDescriptorPool;
-PFN_vkResetDescriptorPool vkResetDescriptorPool;
-PFN_vkAllocateDescriptorSets vkAllocateDescriptorSets;
-PFN_vkFreeDescriptorSets vkFreeDescriptorSets;
-PFN_vkUpdateDescriptorSets vkUpdateDescriptorSets;
-PFN_vkCreateFramebuffer vkCreateFramebuffer;
-PFN_vkDestroyFramebuffer vkDestroyFramebuffer;
-PFN_vkCreateRenderPass vkCreateRenderPass;
-PFN_vkDestroyRenderPass vkDestroyRenderPass;
-PFN_vkGetRenderAreaGranularity vkGetRenderAreaGranularity;
-PFN_vkCreateCommandPool vkCreateCommandPool;
-PFN_vkDestroyCommandPool vkDestroyCommandPool;
-PFN_vkResetCommandPool vkResetCommandPool;
-PFN_vkAllocateCommandBuffers vkAllocateCommandBuffers;
-PFN_vkFreeCommandBuffers vkFreeCommandBuffers;
-PFN_vkBeginCommandBuffer vkBeginCommandBuffer;
-PFN_vkEndCommandBuffer vkEndCommandBuffer;
-PFN_vkResetCommandBuffer vkResetCommandBuffer;
-PFN_vkCmdBindPipeline vkCmdBindPipeline;
-PFN_vkCmdSetViewport vkCmdSetViewport;
-PFN_vkCmdSetScissor vkCmdSetScissor;
-PFN_vkCmdSetLineWidth vkCmdSetLineWidth;
-PFN_vkCmdSetDepthBias vkCmdSetDepthBias;
-PFN_vkCmdSetBlendConstants vkCmdSetBlendConstants;
-PFN_vkCmdSetDepthBounds vkCmdSetDepthBounds;
-PFN_vkCmdSetStencilCompareMask vkCmdSetStencilCompareMask;
-PFN_vkCmdSetStencilWriteMask vkCmdSetStencilWriteMask;
-PFN_vkCmdSetStencilReference vkCmdSetStencilReference;
-PFN_vkCmdBindDescriptorSets vkCmdBindDescriptorSets;
-PFN_vkCmdBindIndexBuffer vkCmdBindIndexBuffer;
-PFN_vkCmdBindVertexBuffers vkCmdBindVertexBuffers;
-PFN_vkCmdDraw vkCmdDraw;
-PFN_vkCmdDrawIndexed vkCmdDrawIndexed;
-PFN_vkCmdDrawIndirect vkCmdDrawIndirect;
-PFN_vkCmdDrawIndexedIndirect vkCmdDrawIndexedIndirect;
-PFN_vkCmdDispatch vkCmdDispatch;
-PFN_vkCmdDispatchIndirect vkCmdDispatchIndirect;
-PFN_vkCmdCopyBuffer vkCmdCopyBuffer;
-PFN_vkCmdCopyImage vkCmdCopyImage;
-PFN_vkCmdBlitImage vkCmdBlitImage;
-PFN_vkCmdCopyBufferToImage vkCmdCopyBufferToImage;
-PFN_vkCmdCopyImageToBuffer vkCmdCopyImageToBuffer;
-PFN_vkCmdUpdateBuffer vkCmdUpdateBuffer;
-PFN_vkCmdFillBuffer vkCmdFillBuffer;
-PFN_vkCmdClearColorImage vkCmdClearColorImage;
-PFN_vkCmdClearDepthStencilImage vkCmdClearDepthStencilImage;
-PFN_vkCmdClearAttachments vkCmdClearAttachments;
-PFN_vkCmdResolveImage vkCmdResolveImage;
-PFN_vkCmdSetEvent vkCmdSetEvent;
-PFN_vkCmdResetEvent vkCmdResetEvent;
-PFN_vkCmdWaitEvents vkCmdWaitEvents;
-PFN_vkCmdPipelineBarrier vkCmdPipelineBarrier;
-PFN_vkCmdBeginQuery vkCmdBeginQuery;
-PFN_vkCmdEndQuery vkCmdEndQuery;
-PFN_vkCmdResetQueryPool vkCmdResetQueryPool;
-PFN_vkCmdWriteTimestamp vkCmdWriteTimestamp;
-PFN_vkCmdCopyQueryPoolResults vkCmdCopyQueryPoolResults;
-PFN_vkCmdPushConstants vkCmdPushConstants;
-PFN_vkCmdBeginRenderPass vkCmdBeginRenderPass;
-PFN_vkCmdNextSubpass vkCmdNextSubpass;
-PFN_vkCmdEndRenderPass vkCmdEndRenderPass;
-PFN_vkCmdExecuteCommands vkCmdExecuteCommands;
-PFN_vkDestroySurfaceKHR vkDestroySurfaceKHR;
-PFN_vkGetPhysicalDeviceSurfaceSupportKHR vkGetPhysicalDeviceSurfaceSupportKHR;
-PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR vkGetPhysicalDeviceSurfaceCapabilitiesKHR;
-PFN_vkGetPhysicalDeviceSurfaceFormatsKHR vkGetPhysicalDeviceSurfaceFormatsKHR;
-PFN_vkGetPhysicalDeviceSurfacePresentModesKHR vkGetPhysicalDeviceSurfacePresentModesKHR;
-PFN_vkCreateSwapchainKHR vkCreateSwapchainKHR;
-PFN_vkDestroySwapchainKHR vkDestroySwapchainKHR;
-PFN_vkGetSwapchainImagesKHR vkGetSwapchainImagesKHR;
-PFN_vkAcquireNextImageKHR vkAcquireNextImageKHR;
-PFN_vkQueuePresentKHR vkQueuePresentKHR;
-PFN_vkGetPhysicalDeviceDisplayPropertiesKHR vkGetPhysicalDeviceDisplayPropertiesKHR;
-PFN_vkGetPhysicalDeviceDisplayPlanePropertiesKHR vkGetPhysicalDeviceDisplayPlanePropertiesKHR;
-PFN_vkGetDisplayPlaneSupportedDisplaysKHR vkGetDisplayPlaneSupportedDisplaysKHR;
-PFN_vkGetDisplayModePropertiesKHR vkGetDisplayModePropertiesKHR;
-PFN_vkCreateDisplayModeKHR vkCreateDisplayModeKHR;
-PFN_vkGetDisplayPlaneCapabilitiesKHR vkGetDisplayPlaneCapabilitiesKHR;
-PFN_vkCreateDisplayPlaneSurfaceKHR vkCreateDisplayPlaneSurfaceKHR;
-PFN_vkCreateSharedSwapchainsKHR vkCreateSharedSwapchainsKHR;
-
-#ifdef VK_USE_PLATFORM_XLIB_KHR
-PFN_vkCreateXlibSurfaceKHR vkCreateXlibSurfaceKHR;
-PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR vkGetPhysicalDeviceXlibPresentationSupportKHR;
-#endif
-
-#ifdef VK_USE_PLATFORM_XCB_KHR
-PFN_vkCreateXcbSurfaceKHR vkCreateXcbSurfaceKHR;
-PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR vkGetPhysicalDeviceXcbPresentationSupportKHR;
-#endif
-
-#ifdef VK_USE_PLATFORM_WAYLAND_KHR
-PFN_vkCreateWaylandSurfaceKHR vkCreateWaylandSurfaceKHR;
-PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR vkGetPhysicalDeviceWaylandPresentationSupportKHR;
-#endif
-
-#ifdef VK_USE_PLATFORM_MIR_KHR
-PFN_vkCreateMirSurfaceKHR vkCreateMirSurfaceKHR;
-PFN_vkGetPhysicalDeviceMirPresentationSupportKHR vkGetPhysicalDeviceMirPresentationSupportKHR;
-#endif
-
-#ifdef VK_USE_PLATFORM_ANDROID_KHR
-PFN_vkCreateAndroidSurfaceKHR vkCreateAndroidSurfaceKHR;
-#endif
-
-#ifdef VK_USE_PLATFORM_WIN32_KHR
-PFN_vkCreateWin32SurfaceKHR vkCreateWin32SurfaceKHR;
-PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR vkGetPhysicalDeviceWin32PresentationSupportKHR;
-#endif
-PFN_vkCreateDebugReportCallbackEXT vkCreateDebugReportCallbackEXT;
-PFN_vkDestroyDebugReportCallbackEXT vkDestroyDebugReportCallbackEXT;
-PFN_vkDebugReportMessageEXT vkDebugReportMessageEXT;
-
diff --git a/test/memoryadvice/memorytest/src/main/cpp/vulkan_wrapper/vulkan_wrapper.h b/test/memoryadvice/memorytest/src/main/cpp/vulkan_wrapper/vulkan_wrapper.h
deleted file mode 100644
index 22184b9..0000000
--- a/test/memoryadvice/memorytest/src/main/cpp/vulkan_wrapper/vulkan_wrapper.h
+++ /dev/null
@@ -1,236 +0,0 @@
-// Copyright 2016 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// This file is generated.
-#ifndef VULKAN_WRAPPER_H
-#define VULKAN_WRAPPER_H
-
-#define VK_NO_PROTOTYPES 1
-#include <vulkan/vulkan.h>
-
-/* Initialize the Vulkan function pointer variables declared in this header.
- * Returns 0 if vulkan is not available, non-zero if it is available.
- */
-int InitVulkan(void);
-
-// VK_core
-extern PFN_vkCreateInstance vkCreateInstance;
-extern PFN_vkDestroyInstance vkDestroyInstance;
-extern PFN_vkEnumeratePhysicalDevices vkEnumeratePhysicalDevices;
-extern PFN_vkGetPhysicalDeviceFeatures vkGetPhysicalDeviceFeatures;
-extern PFN_vkGetPhysicalDeviceFormatProperties vkGetPhysicalDeviceFormatProperties;
-extern PFN_vkGetPhysicalDeviceImageFormatProperties vkGetPhysicalDeviceImageFormatProperties;
-extern PFN_vkGetPhysicalDeviceProperties vkGetPhysicalDeviceProperties;
-extern PFN_vkGetPhysicalDeviceQueueFamilyProperties vkGetPhysicalDeviceQueueFamilyProperties;
-extern PFN_vkGetPhysicalDeviceMemoryProperties vkGetPhysicalDeviceMemoryProperties;
-extern PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr;
-extern PFN_vkGetDeviceProcAddr vkGetDeviceProcAddr;
-extern PFN_vkCreateDevice vkCreateDevice;
-extern PFN_vkDestroyDevice vkDestroyDevice;
-extern PFN_vkEnumerateInstanceExtensionProperties vkEnumerateInstanceExtensionProperties;
-extern PFN_vkEnumerateDeviceExtensionProperties vkEnumerateDeviceExtensionProperties;
-extern PFN_vkEnumerateInstanceLayerProperties vkEnumerateInstanceLayerProperties;
-extern PFN_vkEnumerateDeviceLayerProperties vkEnumerateDeviceLayerProperties;
-extern PFN_vkGetDeviceQueue vkGetDeviceQueue;
-extern PFN_vkQueueSubmit vkQueueSubmit;
-extern PFN_vkQueueWaitIdle vkQueueWaitIdle;
-extern PFN_vkDeviceWaitIdle vkDeviceWaitIdle;
-extern PFN_vkAllocateMemory vkAllocateMemory;
-extern PFN_vkFreeMemory vkFreeMemory;
-extern PFN_vkMapMemory vkMapMemory;
-extern PFN_vkUnmapMemory vkUnmapMemory;
-extern PFN_vkFlushMappedMemoryRanges vkFlushMappedMemoryRanges;
-extern PFN_vkInvalidateMappedMemoryRanges vkInvalidateMappedMemoryRanges;
-extern PFN_vkGetDeviceMemoryCommitment vkGetDeviceMemoryCommitment;
-extern PFN_vkBindBufferMemory vkBindBufferMemory;
-extern PFN_vkBindImageMemory vkBindImageMemory;
-extern PFN_vkGetBufferMemoryRequirements vkGetBufferMemoryRequirements;
-extern PFN_vkGetImageMemoryRequirements vkGetImageMemoryRequirements;
-extern PFN_vkGetImageSparseMemoryRequirements vkGetImageSparseMemoryRequirements;
-extern PFN_vkGetPhysicalDeviceSparseImageFormatProperties vkGetPhysicalDeviceSparseImageFormatProperties;
-extern PFN_vkQueueBindSparse vkQueueBindSparse;
-extern PFN_vkCreateFence vkCreateFence;
-extern PFN_vkDestroyFence vkDestroyFence;
-extern PFN_vkResetFences vkResetFences;
-extern PFN_vkGetFenceStatus vkGetFenceStatus;
-extern PFN_vkWaitForFences vkWaitForFences;
-extern PFN_vkCreateSemaphore vkCreateSemaphore;
-extern PFN_vkDestroySemaphore vkDestroySemaphore;
-extern PFN_vkCreateEvent vkCreateEvent;
-extern PFN_vkDestroyEvent vkDestroyEvent;
-extern PFN_vkGetEventStatus vkGetEventStatus;
-extern PFN_vkSetEvent vkSetEvent;
-extern PFN_vkResetEvent vkResetEvent;
-extern PFN_vkCreateQueryPool vkCreateQueryPool;
-extern PFN_vkDestroyQueryPool vkDestroyQueryPool;
-extern PFN_vkGetQueryPoolResults vkGetQueryPoolResults;
-extern PFN_vkCreateBuffer vkCreateBuffer;
-extern PFN_vkDestroyBuffer vkDestroyBuffer;
-extern PFN_vkCreateBufferView vkCreateBufferView;
-extern PFN_vkDestroyBufferView vkDestroyBufferView;
-extern PFN_vkCreateImage vkCreateImage;
-extern PFN_vkDestroyImage vkDestroyImage;
-extern PFN_vkGetImageSubresourceLayout vkGetImageSubresourceLayout;
-extern PFN_vkCreateImageView vkCreateImageView;
-extern PFN_vkDestroyImageView vkDestroyImageView;
-extern PFN_vkCreateShaderModule vkCreateShaderModule;
-extern PFN_vkDestroyShaderModule vkDestroyShaderModule;
-extern PFN_vkCreatePipelineCache vkCreatePipelineCache;
-extern PFN_vkDestroyPipelineCache vkDestroyPipelineCache;
-extern PFN_vkGetPipelineCacheData vkGetPipelineCacheData;
-extern PFN_vkMergePipelineCaches vkMergePipelineCaches;
-extern PFN_vkCreateGraphicsPipelines vkCreateGraphicsPipelines;
-extern PFN_vkCreateComputePipelines vkCreateComputePipelines;
-extern PFN_vkDestroyPipeline vkDestroyPipeline;
-extern PFN_vkCreatePipelineLayout vkCreatePipelineLayout;
-extern PFN_vkDestroyPipelineLayout vkDestroyPipelineLayout;
-extern PFN_vkCreateSampler vkCreateSampler;
-extern PFN_vkDestroySampler vkDestroySampler;
-extern PFN_vkCreateDescriptorSetLayout vkCreateDescriptorSetLayout;
-extern PFN_vkDestroyDescriptorSetLayout vkDestroyDescriptorSetLayout;
-extern PFN_vkCreateDescriptorPool vkCreateDescriptorPool;
-extern PFN_vkDestroyDescriptorPool vkDestroyDescriptorPool;
-extern PFN_vkResetDescriptorPool vkResetDescriptorPool;
-extern PFN_vkAllocateDescriptorSets vkAllocateDescriptorSets;
-extern PFN_vkFreeDescriptorSets vkFreeDescriptorSets;
-extern PFN_vkUpdateDescriptorSets vkUpdateDescriptorSets;
-extern PFN_vkCreateFramebuffer vkCreateFramebuffer;
-extern PFN_vkDestroyFramebuffer vkDestroyFramebuffer;
-extern PFN_vkCreateRenderPass vkCreateRenderPass;
-extern PFN_vkDestroyRenderPass vkDestroyRenderPass;
-extern PFN_vkGetRenderAreaGranularity vkGetRenderAreaGranularity;
-extern PFN_vkCreateCommandPool vkCreateCommandPool;
-extern PFN_vkDestroyCommandPool vkDestroyCommandPool;
-extern PFN_vkResetCommandPool vkResetCommandPool;
-extern PFN_vkAllocateCommandBuffers vkAllocateCommandBuffers;
-extern PFN_vkFreeCommandBuffers vkFreeCommandBuffers;
-extern PFN_vkBeginCommandBuffer vkBeginCommandBuffer;
-extern PFN_vkEndCommandBuffer vkEndCommandBuffer;
-extern PFN_vkResetCommandBuffer vkResetCommandBuffer;
-extern PFN_vkCmdBindPipeline vkCmdBindPipeline;
-extern PFN_vkCmdSetViewport vkCmdSetViewport;
-extern PFN_vkCmdSetScissor vkCmdSetScissor;
-extern PFN_vkCmdSetLineWidth vkCmdSetLineWidth;
-extern PFN_vkCmdSetDepthBias vkCmdSetDepthBias;
-extern PFN_vkCmdSetBlendConstants vkCmdSetBlendConstants;
-extern PFN_vkCmdSetDepthBounds vkCmdSetDepthBounds;
-extern PFN_vkCmdSetStencilCompareMask vkCmdSetStencilCompareMask;
-extern PFN_vkCmdSetStencilWriteMask vkCmdSetStencilWriteMask;
-extern PFN_vkCmdSetStencilReference vkCmdSetStencilReference;
-extern PFN_vkCmdBindDescriptorSets vkCmdBindDescriptorSets;
-extern PFN_vkCmdBindIndexBuffer vkCmdBindIndexBuffer;
-extern PFN_vkCmdBindVertexBuffers vkCmdBindVertexBuffers;
-extern PFN_vkCmdDraw vkCmdDraw;
-extern PFN_vkCmdDrawIndexed vkCmdDrawIndexed;
-extern PFN_vkCmdDrawIndirect vkCmdDrawIndirect;
-extern PFN_vkCmdDrawIndexedIndirect vkCmdDrawIndexedIndirect;
-extern PFN_vkCmdDispatch vkCmdDispatch;
-extern PFN_vkCmdDispatchIndirect vkCmdDispatchIndirect;
-extern PFN_vkCmdCopyBuffer vkCmdCopyBuffer;
-extern PFN_vkCmdCopyImage vkCmdCopyImage;
-extern PFN_vkCmdBlitImage vkCmdBlitImage;
-extern PFN_vkCmdCopyBufferToImage vkCmdCopyBufferToImage;
-extern PFN_vkCmdCopyImageToBuffer vkCmdCopyImageToBuffer;
-extern PFN_vkCmdUpdateBuffer vkCmdUpdateBuffer;
-extern PFN_vkCmdFillBuffer vkCmdFillBuffer;
-extern PFN_vkCmdClearColorImage vkCmdClearColorImage;
-extern PFN_vkCmdClearDepthStencilImage vkCmdClearDepthStencilImage;
-extern PFN_vkCmdClearAttachments vkCmdClearAttachments;
-extern PFN_vkCmdResolveImage vkCmdResolveImage;
-extern PFN_vkCmdSetEvent vkCmdSetEvent;
-extern PFN_vkCmdResetEvent vkCmdResetEvent;
-extern PFN_vkCmdWaitEvents vkCmdWaitEvents;
-extern PFN_vkCmdPipelineBarrier vkCmdPipelineBarrier;
-extern PFN_vkCmdBeginQuery vkCmdBeginQuery;
-extern PFN_vkCmdEndQuery vkCmdEndQuery;
-extern PFN_vkCmdResetQueryPool vkCmdResetQueryPool;
-extern PFN_vkCmdWriteTimestamp vkCmdWriteTimestamp;
-extern PFN_vkCmdCopyQueryPoolResults vkCmdCopyQueryPoolResults;
-extern PFN_vkCmdPushConstants vkCmdPushConstants;
-extern PFN_vkCmdBeginRenderPass vkCmdBeginRenderPass;
-extern PFN_vkCmdNextSubpass vkCmdNextSubpass;
-extern PFN_vkCmdEndRenderPass vkCmdEndRenderPass;
-extern PFN_vkCmdExecuteCommands vkCmdExecuteCommands;
-
-// VK_KHR_surface
-extern PFN_vkDestroySurfaceKHR vkDestroySurfaceKHR;
-extern PFN_vkGetPhysicalDeviceSurfaceSupportKHR vkGetPhysicalDeviceSurfaceSupportKHR;
-extern PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR vkGetPhysicalDeviceSurfaceCapabilitiesKHR;
-extern PFN_vkGetPhysicalDeviceSurfaceFormatsKHR vkGetPhysicalDeviceSurfaceFormatsKHR;
-extern PFN_vkGetPhysicalDeviceSurfacePresentModesKHR vkGetPhysicalDeviceSurfacePresentModesKHR;
-
-// VK_KHR_swapchain
-extern PFN_vkCreateSwapchainKHR vkCreateSwapchainKHR;
-extern PFN_vkDestroySwapchainKHR vkDestroySwapchainKHR;
-extern PFN_vkGetSwapchainImagesKHR vkGetSwapchainImagesKHR;
-extern PFN_vkAcquireNextImageKHR vkAcquireNextImageKHR;
-extern PFN_vkQueuePresentKHR vkQueuePresentKHR;
-
-// VK_KHR_display
-extern PFN_vkGetPhysicalDeviceDisplayPropertiesKHR vkGetPhysicalDeviceDisplayPropertiesKHR;
-extern PFN_vkGetPhysicalDeviceDisplayPlanePropertiesKHR vkGetPhysicalDeviceDisplayPlanePropertiesKHR;
-extern PFN_vkGetDisplayPlaneSupportedDisplaysKHR vkGetDisplayPlaneSupportedDisplaysKHR;
-extern PFN_vkGetDisplayModePropertiesKHR vkGetDisplayModePropertiesKHR;
-extern PFN_vkCreateDisplayModeKHR vkCreateDisplayModeKHR;
-extern PFN_vkGetDisplayPlaneCapabilitiesKHR vkGetDisplayPlaneCapabilitiesKHR;
-extern PFN_vkCreateDisplayPlaneSurfaceKHR vkCreateDisplayPlaneSurfaceKHR;
-
-// VK_KHR_display_swapchain
-extern PFN_vkCreateSharedSwapchainsKHR vkCreateSharedSwapchainsKHR;
-
-#ifdef VK_USE_PLATFORM_XLIB_KHR
-// VK_KHR_xlib_surface
-extern PFN_vkCreateXlibSurfaceKHR vkCreateXlibSurfaceKHR;
-extern PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR vkGetPhysicalDeviceXlibPresentationSupportKHR;
-#endif
-
-#ifdef VK_USE_PLATFORM_XCB_KHR
-// VK_KHR_xcb_surface
-extern PFN_vkCreateXcbSurfaceKHR vkCreateXcbSurfaceKHR;
-extern PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR vkGetPhysicalDeviceXcbPresentationSupportKHR;
-#endif
-
-#ifdef VK_USE_PLATFORM_WAYLAND_KHR
-// VK_KHR_wayland_surface
-extern PFN_vkCreateWaylandSurfaceKHR vkCreateWaylandSurfaceKHR;
-extern PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR vkGetPhysicalDeviceWaylandPresentationSupportKHR;
-#endif
-
-#ifdef VK_USE_PLATFORM_MIR_KHR
-// VK_KHR_mir_surface
-extern PFN_vkCreateMirSurfaceKHR vkCreateMirSurfaceKHR;
-extern PFN_vkGetPhysicalDeviceMirPresentationSupportKHR vkGetPhysicalDeviceMirPresentationSupportKHR;
-#endif
-
-#ifdef VK_USE_PLATFORM_ANDROID_KHR
-// VK_KHR_android_surface
-extern PFN_vkCreateAndroidSurfaceKHR vkCreateAndroidSurfaceKHR;
-#endif
-
-#ifdef VK_USE_PLATFORM_WIN32_KHR
-// VK_KHR_win32_surface
-extern PFN_vkCreateWin32SurfaceKHR vkCreateWin32SurfaceKHR;
-extern PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR vkGetPhysicalDeviceWin32PresentationSupportKHR;
-#endif
-
-#ifdef USE_DEBUG_EXTENSIONS
-#include <vulkan/vk_sdk_platform.h>
-// VK_EXT_debug_report
-extern PFN_vkCreateDebugReportCallbackEXT vkCreateDebugReportCallbackEXT;
-extern PFN_vkDestroyDebugReportCallbackEXT vkDestroyDebugReportCallbackEXT;
-extern PFN_vkDebugReportMessageEXT vkDebugReportMessageEXT;
-#endif
-
-
-#endif // VULKAN_WRAPPER_H
diff --git a/test/memoryadvice/memorytest/src/main/java/com/google/android/apps/internal/games/memorytest/DurationUtils.java b/test/memoryadvice/memorytest/src/main/java/com/google/android/apps/internal/games/memorytest/DurationUtils.java
deleted file mode 100644
index faa88e0..0000000
--- a/test/memoryadvice/memorytest/src/main/java/com/google/android/apps/internal/games/memorytest/DurationUtils.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package com.google.android.apps.internal.games.memorytest;
-
-/**
- * A helper class with static methods to help with Heuristics and file IO
- */
-public class DurationUtils {
- private static final String TAG = DurationUtils.class.getSimpleName();
-
- /**
- * Converts a time duration in an object to a number of milliseconds. If the object is a number,
- * it is interpreted as the number of milliseconds. If the value is a string, it is converted
- * according to the specified unit. e.g. "30s", "1H". No unit is interpreted as milliseconds.
- *
- * @param object The object to extract from.
- * @return The equivalent number of milliseconds.
- */
- public static long getDuration(Object object) {
- if (object instanceof Number) {
- return ((Number) object).longValue();
- }
-
- if (object instanceof String) {
- String str = ((String) object).toUpperCase();
- int unitPosition = str.indexOf('S');
- int unitMultiplier = 1000;
- if (unitPosition == -1) {
- unitPosition = str.indexOf('M');
- unitMultiplier *= 60;
- if (unitPosition == -1) {
- unitPosition = str.indexOf('H');
- unitMultiplier *= 60;
- if (unitPosition == -1) {
- unitMultiplier = 1;
- }
- }
- }
- float value = Float.parseFloat(str.substring(0, unitPosition));
- return (long) (value * unitMultiplier);
- }
- throw new IllegalArgumentException("Input to getDuration neither string or number.");
- }
-}
diff --git a/test/memoryadvice/memorytest/src/main/java/com/google/android/apps/internal/games/memorytest/MapUtils.java b/test/memoryadvice/memorytest/src/main/java/com/google/android/apps/internal/games/memorytest/MapUtils.java
deleted file mode 100644
index 97c9397..0000000
--- a/test/memoryadvice/memorytest/src/main/java/com/google/android/apps/internal/games/memorytest/MapUtils.java
+++ /dev/null
@@ -1,87 +0,0 @@
-package com.google.android.apps.internal.games.memorytest;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * A helper class with static methods to help with Heuristics and file IO
- */
-public class MapUtils {
- private static final String TAG = MapUtils.class.getSimpleName();
-
- /**
- * Selects the parameters for a run based on the 'tests' and 'coordinates' of the test
- * specification file.
- *
- * @param spec The test specification file.
- * @return The selected parameters.
- */
- public static Map<String, Object> flattenParams(Map<String, Object> spec) {
- Map<String, Object> params = new HashMap<>();
-
- List<Object> coordinates = (List<Object>) spec.get("coordinates");
- List<Object> tests = (List<Object>) spec.get("tests");
-
- for (int coordinateNumber = 0; coordinateNumber != coordinates.size(); coordinateNumber++) {
- List<Object> jsonArray = (List<Object>) tests.get(coordinateNumber);
- Map<String, Object> jsonObject = (Map<String, Object>) jsonArray.get(
- ((Number) coordinates.get(coordinateNumber)).intValue());
- merge(jsonObject, params);
- }
- return params;
- }
-
- /**
- * Creates a deep union of two maps. Arrays are concatenated and dictionaries are merged.
- *
- * @param in The first map; read only.
- * @param out The second map and the object into which changes are written.
- */
- private static void merge(Map<String, Object> in, Map<String, Object> out) {
- for (Map.Entry<String, Object> entry : in.entrySet()) {
- String key = entry.getKey();
- Object inObject = entry.getValue();
- Object outObject = out.get(key);
- if (outObject == null) {
- out.put(key, clone(inObject));
- continue;
- }
- if (inObject instanceof List && outObject instanceof List) {
- ((Collection<Object>) outObject).addAll((Collection<?>) clone(inObject));
- continue;
- }
- if (inObject instanceof Map && outObject instanceof Map) {
- merge((Map<String, Object>) inObject, ((Map<String, Object>) outObject));
- continue;
- }
- }
- }
-
- /**
- * Return a deep-clone of a JSON-compatible object tree.
- * @param in The tree to clone.
- * @param <T> The cloned tree.
- */
- public static <T> T clone(T in) {
- if (in instanceof Map) {
- Map<String, Object> map = new LinkedHashMap<>();
- for (Map.Entry<String, Object> entry : ((Map<String, Object>) in).entrySet()) {
- map.put(entry.getKey(), clone(entry.getValue()));
- }
- return (T) map;
- }
-
- if (in instanceof List) {
- Collection<Object> list = new ArrayList<>();
- for (Object obj : (Iterable<Object>) in) {
- list.add(clone(obj));
- }
- return (T) list;
- }
- return in;
- }
-}
diff --git a/test/memoryadvice/memorytest/src/main/java/com/google/android/apps/internal/games/memorytest/MemoryTest.java b/test/memoryadvice/memorytest/src/main/java/com/google/android/apps/internal/games/memorytest/MemoryTest.java
deleted file mode 100644
index b2ef14e..0000000
--- a/test/memoryadvice/memorytest/src/main/java/com/google/android/apps/internal/games/memorytest/MemoryTest.java
+++ /dev/null
@@ -1,353 +0,0 @@
-package com.google.android.apps.internal.games.memorytest;
-
-import static com.google.android.apps.internal.games.memoryadvice_common.ConfigUtils.getMemoryQuantity;
-import static com.google.android.apps.internal.games.memoryadvice_common.ConfigUtils.getOrDefault;
-import static com.google.android.apps.internal.games.memorytest.DurationUtils.getDuration;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.util.Log;
-import android.view.View;
-import com.google.android.apps.internal.games.memoryadvice.MemoryAdvisor;
-import com.google.android.apps.internal.games.memoryadvice.MemoryWatcher;
-import java.io.IOException;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Timer;
-import java.util.TimerTask;
-
-public class MemoryTest implements MemoryWatcher.Client {
- private static final String TAG = MemoryTest.class.getSimpleName();
-
- static {
- System.loadLibrary("memory-test");
- }
-
- private final boolean yellowLightTesting;
- private final long mallocBytesPerMillisecond;
- private final long glAllocBytesPerMillisecond;
- private final long vkAllocBytesPerMillisecond;
- private final long mmapFileBytesPerMillisecond;
- private final long mmapAnonBytesPerMillisecond;
- private final long mmapAnonBlock;
- private final long mmapFileBlock;
- private final long memoryToFreePerCycle;
- private final long delayBeforeRelease;
- private final long delayAfterRelease;
- private final ResultsReceiver resultsReceiver;
- private final MemoryAdvisor memoryAdvisor;
- private final Timer timer = new Timer();
- private final TestSurface testSurface;
- private final MmapFileGroup mmapFiles;
- private long allocationStartedTime = -1;
- private long nativeAllocatedByTest;
- private long vkAllocatedByTest;
- private long mmapAnonAllocatedByTest;
- private long mmapFileAllocatedByTest;
-
- public MemoryTest(Context context, MemoryAdvisor memoryAdvisor, TestSurface testSurface,
- Map<String, Object> params, ResultsReceiver resultsReceiver) {
- this.testSurface = testSurface;
- this.resultsReceiver = resultsReceiver;
- this.memoryAdvisor = memoryAdvisor;
-
- initNative();
-
- yellowLightTesting = Boolean.TRUE.equals(params.get("yellowLightTesting"));
- mallocBytesPerMillisecond = getMemoryQuantity(getOrDefault(params, "malloc", 0));
- glAllocBytesPerMillisecond = getMemoryQuantity(getOrDefault(params, "glTest", 0));
- vkAllocBytesPerMillisecond = getMemoryQuantity(getOrDefault(params, "vkTest", 0));
-
- delayBeforeRelease = getDuration(getOrDefault(params, "delayBeforeRelease", "1s"));
- delayAfterRelease = getDuration(getOrDefault(params, "delayAfterRelease", "1s"));
-
- memoryToFreePerCycle = getMemoryQuantity(getOrDefault(params, "memoryToFreePerCycle", "500M"));
-
- Map<String, Object> mmapFile = (Map<String, Object>) params.get("mmapFile");
- Map<String, Object> mmapAnon = (Map<String, Object>) params.get("mmapAnon");
-
- if (mmapAnon != null && mmapFile != null) {
- initMMap();
- }
-
- if (mmapAnon == null) {
- mmapAnonBlock = 0;
- mmapAnonBytesPerMillisecond = 0;
- } else {
- mmapAnonBlock = getMemoryQuantity(getOrDefault(mmapAnon, "blockSize", "2M"));
- mmapAnonBytesPerMillisecond =
- getMemoryQuantity(getOrDefault(mmapAnon, "allocPerMillisecond", 0));
- }
-
- if (mmapFile == null) {
- mmapFiles = null;
- mmapFileBlock = 0;
- mmapFileBytesPerMillisecond = 0;
- } else {
- int mmapFileCount = ((Number) getOrDefault(mmapFile, "count", 10)).intValue();
- long mmapFileSize = getMemoryQuantity(getOrDefault(mmapFile, "fileSize", "4K"));
- String mmapPath = context.getCacheDir().toString();
- try {
- mmapFiles = new MmapFileGroup(mmapPath, mmapFileCount, mmapFileSize);
- } catch (IOException e) {
- throw new IllegalStateException(e);
- }
- mmapFileBlock = getMemoryQuantity(getOrDefault(mmapFile, "blockSize", "2M"));
- mmapFileBytesPerMillisecond =
- getMemoryQuantity(getOrDefault(mmapFile, "allocPerMillisecond", 0));
- }
-
- long glFixed = getMemoryQuantity(getOrDefault(params, "glFixed", 0));
- if (glAllocBytesPerMillisecond > 0 || glFixed > 0) {
- initGl();
- testSurface.getRenderer().setMaxConsumerSize(
- getMemoryQuantity(getOrDefault(params, "maxConsumer", "2048K")));
- testSurface.setVisibility(View.VISIBLE);
- testSurface.getRenderer().setTarget(glFixed);
- }
-
- nativeConsume(getMemoryQuantity(getOrDefault(params, "mallocFixed", 0)));
-
- IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON);
- filter.addAction(Intent.ACTION_SCREEN_OFF);
- BroadcastReceiver receiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- Map<String, Object> report = new LinkedHashMap<>();
- report.put("action", intent.getAction());
- report.put("time", System.currentTimeMillis());
- resultsReceiver.accept(report);
- }
- };
- context.registerReceiver(receiver, filter);
-
- new Timer().schedule(new TimerTask() {
- @Override
- public void run() {
- context.unregisterReceiver(receiver);
- Map<String, Object> report = new LinkedHashMap<>();
- report.put("exiting", true);
- report.put("time", System.currentTimeMillis());
- resultsReceiver.accept(report);
- }
- }, getDuration(getOrDefault(params, "timeout", "10m")));
-
- runAfterDelay(() -> {
- allocationStartedTime = System.currentTimeMillis();
- }, getDuration(getOrDefault(params, "delayBeforeAllocation", "2s")));
- }
-
- public static native void initNative();
-
- public static native void initGl();
-
- public static native void initMMap();
-
- public static native int nativeDraw(int toAllocate);
-
- public static native void release();
-
- public static native long vkAlloc(long size);
-
- public static native void vkRelease();
-
- public static native boolean writeRandomFile(String path, long bytes);
-
- public static native void freeAll();
-
- public static native void freeMemory(long bytes);
-
- public static native boolean nativeConsume(long bytes);
-
- public static native void mmapAnonFreeAll();
-
- public static native long mmapAnonConsume(long bytes);
-
- public static native long mmapFileConsume(String path, long bytes, long offset);
-
- @Override
- public void newState(MemoryAdvisor.MemoryState state) {
- Log.i(TAG, "New memory state: " + state.name());
- }
-
- @Override
- public void receiveAdvice(Map<String, Object> advice) {
- Map<String, Object> report = new LinkedHashMap<>();
- report.put("advice", advice);
- if (allocationStartedTime == -1) {
- report.put("paused", true);
- } else {
- long sinceAllocationStarted = System.currentTimeMillis() - allocationStartedTime;
- if (sinceAllocationStarted > 0) {
- boolean shouldAllocate = true;
- switch (MemoryAdvisor.getMemoryState(advice)) {
- case APPROACHING_LIMIT:
- if (yellowLightTesting) {
- shouldAllocate = false;
- }
- break;
- case CRITICAL:
- shouldAllocate = false;
- if (yellowLightTesting) {
- freeMemory(memoryToFreePerCycle);
- } else {
- // Allocating 0 MB
- releaseMemory();
- }
- break;
- }
- if (shouldAllocate) {
- if (mallocBytesPerMillisecond > 0) {
- long owed = sinceAllocationStarted * mallocBytesPerMillisecond - nativeAllocatedByTest;
- if (owed > 0) {
- boolean succeeded = nativeConsume(owed);
- if (succeeded) {
- nativeAllocatedByTest += owed;
- } else {
- report.put("allocFailed", true);
- }
- }
- }
- if (glAllocBytesPerMillisecond > 0) {
- long target = sinceAllocationStarted * glAllocBytesPerMillisecond;
- testSurface.getRenderer().setTarget(target);
- }
-
- if (vkAllocBytesPerMillisecond > 0) {
- long owed = sinceAllocationStarted * vkAllocBytesPerMillisecond - vkAllocatedByTest;
- if (owed > 0) {
- long allocated = vkAlloc(owed);
- if (allocated >= owed) {
- vkAllocatedByTest += owed;
- } else {
- report.put("allocFailed", true);
- }
- }
- }
-
- if (mmapAnonBytesPerMillisecond > 0) {
- long owed =
- sinceAllocationStarted * mmapAnonBytesPerMillisecond - mmapAnonAllocatedByTest;
- if (owed > mmapAnonBlock) {
- long allocated = mmapAnonConsume(owed);
- if (allocated == 0) {
- report.put("mmapAnonFailed", true);
- } else {
- mmapAnonAllocatedByTest += allocated;
- }
- }
- }
- if (mmapFileBytesPerMillisecond > 0) {
- long owed =
- sinceAllocationStarted * mmapFileBytesPerMillisecond - mmapFileAllocatedByTest;
- if (owed > mmapFileBlock) {
- MmapFileInfo file = mmapFiles.alloc(owed);
- long allocated =
- mmapFileConsume(file.getPath(), file.getAllocSize(), file.getOffset());
- if (allocated == 0) {
- report.put("mmapFileFailed", true);
- } else {
- mmapFileAllocatedByTest += allocated;
- }
- }
- }
- }
- }
- }
-
- Map<String, Object> testMetrics = new LinkedHashMap<>();
- if (vkAllocatedByTest > 0) {
- testMetrics.put("vkAllocatedByTest", vkAllocatedByTest);
- }
- if (nativeAllocatedByTest > 0) {
- testMetrics.put("nativeAllocatedByTest", nativeAllocatedByTest);
- }
- if (mmapAnonAllocatedByTest > 0) {
- testMetrics.put("mmapAnonAllocatedByTest", mmapAnonAllocatedByTest);
- }
- if (mmapAnonAllocatedByTest > 0) {
- testMetrics.put("mmapFileAllocatedByTest", mmapFileAllocatedByTest);
- }
-
- if (testSurface != null) {
- TestRenderer renderer = testSurface.getRenderer();
- long glAllocated = renderer.getAllocated();
- if (glAllocated > 0) {
- testMetrics.put("gl_allocated", glAllocated);
- }
- if (renderer.getFailed()) {
- report.put("allocFailed", true);
- }
- }
- report.put("testMetrics", testMetrics);
-
- resultsReceiver.accept(report);
- }
-
- private void runAfterDelay(Runnable runnable, long delay) {
- timer.schedule(new TimerTask() {
- @Override
- public void run() {
- runnable.run();
- }
- }, delay);
- }
-
- private void releaseMemory() {
- allocationStartedTime = -1;
-
- runAfterDelay(() -> {
- Map<String, Object> report2 = new LinkedHashMap<>();
- report2.put("paused", true);
- report2.put("time", System.currentTimeMillis());
-
- resultsReceiver.accept(report2);
-
- if (nativeAllocatedByTest > 0) {
- nativeAllocatedByTest = 0;
- freeAll();
- }
-
- if (mmapAnonAllocatedByTest > 0) {
- mmapAnonFreeAll();
- mmapAnonAllocatedByTest = 0;
- }
-
- if (glAllocBytesPerMillisecond > 0) {
- if (testSurface != null) {
- testSurface.queueEvent(() -> {
- TestRenderer renderer = testSurface.getRenderer();
- renderer.release();
- });
- }
- }
- if (vkAllocBytesPerMillisecond > 0) {
- vkAllocatedByTest = 0;
- vkRelease();
- }
-
- runAfterDelay(new Runnable() {
- @Override
- public void run() {
- Map<String, Object> report = new LinkedHashMap<>();
- Map<String, Object> advice = memoryAdvisor.getAdvice();
- report.put("advice", advice);
- if (MemoryAdvisor.anyWarnings(advice)) {
- report.put("failedToClear", true);
- report.put("paused", true);
- runAfterDelay(this, delayAfterRelease);
- } else {
- allocationStartedTime = System.currentTimeMillis();
- }
- resultsReceiver.accept(report);
- }
- }, delayAfterRelease);
- }, delayBeforeRelease);
- }
-
- public interface ResultsReceiver {
- void accept(Map<String, Object> results);
- }
-}
\ No newline at end of file
diff --git a/test/memoryadvice/memorytest/src/main/java/com/google/android/apps/internal/games/memorytest/MmapFileGroup.java b/test/memoryadvice/memorytest/src/main/java/com/google/android/apps/internal/games/memorytest/MmapFileGroup.java
deleted file mode 100644
index 3590c2c..0000000
--- a/test/memoryadvice/memorytest/src/main/java/com/google/android/apps/internal/games/memorytest/MmapFileGroup.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package com.google.android.apps.internal.games.memorytest;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import org.apache.commons.io.FileUtils;
-
-class MmapFileGroup {
- private final ArrayList<MmapFileInfo> files = new ArrayList<>();
- private int current;
-
- MmapFileGroup(String mmapPath, int mmapFileCount, long mmapFileSize) throws IOException {
- int digits = Integer.toString(mmapFileCount - 1).length();
- FileUtils.cleanDirectory(new File(mmapPath));
- for (int i = 0; i < mmapFileCount; ++i) {
- String filename = mmapPath + "/" + String.format("test%0" + digits + "d.dat", i);
- MemoryTest.writeRandomFile(filename, mmapFileSize);
- files.add(new MmapFileInfo(filename));
- }
- }
-
- public MmapFileInfo alloc(long desiredSize) {
- while (!files.get(current).alloc(desiredSize)) {
- current = (current + 1) % files.size();
- files.get(current).reset();
- }
- return files.get(current);
- }
-}
diff --git a/test/memoryadvice/memorytest/src/main/java/com/google/android/apps/internal/games/memorytest/MmapFileInfo.java b/test/memoryadvice/memorytest/src/main/java/com/google/android/apps/internal/games/memorytest/MmapFileInfo.java
deleted file mode 100644
index 7e20cb9..0000000
--- a/test/memoryadvice/memorytest/src/main/java/com/google/android/apps/internal/games/memorytest/MmapFileInfo.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package com.google.android.apps.internal.games.memorytest;
-
-import java.io.File;
-
-class MmapFileInfo {
- private final long fileSize;
- private final String path;
- private long allocSize;
- private long offset;
-
- MmapFileInfo(String path) {
- this.path = path;
- fileSize = new File(path).length();
- offset = 0;
- }
-
- public boolean alloc(long desiredSize) {
- offset += allocSize;
- long limit = fileSize - offset;
- allocSize = Math.min(limit, desiredSize);
- return allocSize > 0;
- }
-
- public void reset() {
- offset = 0;
- allocSize = 0;
- }
-
- public String getPath() {
- return path;
- }
-
- public long getOffset() {
- return offset;
- }
-
- public long getAllocSize() {
- return allocSize;
- }
-}
diff --git a/test/memoryadvice/memorytest/src/main/java/com/google/android/apps/internal/games/memorytest/TestRenderer.java b/test/memoryadvice/memorytest/src/main/java/com/google/android/apps/internal/games/memorytest/TestRenderer.java
deleted file mode 100644
index f595673..0000000
--- a/test/memoryadvice/memorytest/src/main/java/com/google/android/apps/internal/games/memorytest/TestRenderer.java
+++ /dev/null
@@ -1,83 +0,0 @@
-package com.google.android.apps.internal.games.memorytest;
-
-import static javax.microedition.khronos.opengles.GL10.GL_MAX_ELEMENTS_VERTICES;
-
-import android.opengl.GLES20;
-import android.opengl.GLSurfaceView;
-import android.util.Log;
-import java.nio.IntBuffer;
-import java.util.concurrent.atomic.AtomicBoolean;
-import javax.microedition.khronos.egl.EGLConfig;
-import javax.microedition.khronos.opengles.GL10;
-
-public class TestRenderer implements GLSurfaceView.Renderer {
- private static final String TAG = TestRenderer.class.getSimpleName();
-
- private static final int VIEWPORT_X = 0;
- private static final int VIEWPORT_Y = 0;
- private static final long GL_FLOAT_SIZE = 4L;
- private final AtomicBoolean intialized = new AtomicBoolean(false);
- private long target;
- private long allocated;
- private long maxConsumerSize;
- private boolean failed;
- private int maxElementVertices;
-
- @Override
- public void onSurfaceCreated(GL10 gl, EGLConfig config) {
- if (intialized.compareAndSet(false, true)) {
- MemoryTest.initGl();
- try {
- IntBuffer valueOut = IntBuffer.allocate(1);
- gl.glGetIntegerv(GL_MAX_ELEMENTS_VERTICES, valueOut);
- maxElementVertices = valueOut.get(0);
- } catch (android.opengl.GLException e) {
- maxElementVertices = Integer.MAX_VALUE;
- Log.w(TAG, "Could not get max buffer size", e);
- }
- }
- }
-
- public void onSurfaceChanged(GL10 unused, int width, int height) {
- GLES20.glViewport(VIEWPORT_X, VIEWPORT_Y, width, height);
- }
-
- public void onDrawFrame(GL10 unused) {
- long allocate1 = Math.min(target - allocated, maxConsumerSize);
- allocate1 = Math.min(allocate1, maxElementVertices * GL_FLOAT_SIZE);
- int toAllocate = (int) Math.min(Integer.MAX_VALUE, allocate1);
-
- if (toAllocate > 0) {
- int result = MemoryTest.nativeDraw(toAllocate);
- if (result >= toAllocate) {
- allocated += result;
- } else {
- Log.i(TAG, "Allocation failed");
- failed = true;
- }
- }
- }
-
- public void release() {
- target = 0;
- allocated = 0;
- failed = false;
- MemoryTest.release();
- }
-
- public long getAllocated() {
- return allocated;
- }
-
- void setMaxConsumerSize(long value) {
- maxConsumerSize = value;
- }
-
- public void setTarget(long value) {
- target = value;
- }
-
- boolean getFailed() {
- return failed;
- }
-}
diff --git a/test/memoryadvice/memorytest/src/main/java/com/google/android/apps/internal/games/memorytest/TestSurface.java b/test/memoryadvice/memorytest/src/main/java/com/google/android/apps/internal/games/memorytest/TestSurface.java
deleted file mode 100644
index 22fcd57..0000000
--- a/test/memoryadvice/memorytest/src/main/java/com/google/android/apps/internal/games/memorytest/TestSurface.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package com.google.android.apps.internal.games.memorytest;
-
-import android.content.Context;
-import android.opengl.GLSurfaceView;
-import android.util.AttributeSet;
-
-public class TestSurface extends GLSurfaceView {
- public static final int GL_CLIENT_VERSION = 2;
- public static final int RED_SIZE = 8;
- public static final int GREEN_SIZE = 8;
- public static final int BLUE_SIZE = 8;
- public static final int ALPHA_SIZE = 0;
- public static final int DEPTH_SIZE = 16;
- public static final int STENCIL_SIZE = 0;
-
- private final TestRenderer renderer;
-
- public TestSurface(Context context, AttributeSet attrs) {
- super(context, attrs);
-
- setEGLContextClientVersion(GL_CLIENT_VERSION);
- setEGLConfigChooser(RED_SIZE, GREEN_SIZE, BLUE_SIZE, ALPHA_SIZE, DEPTH_SIZE, STENCIL_SIZE);
- setDebugFlags(DEBUG_CHECK_GL_ERROR | DEBUG_LOG_GL_CALLS);
- renderer = new TestRenderer();
- setRenderer(renderer);
- }
-
- TestRenderer getRenderer() {
- return renderer;
- }
-}
diff --git a/test/memoryadvice/settings.gradle b/test/memoryadvice/settings.gradle
deleted file mode 100644
index ebb7f0e..0000000
--- a/test/memoryadvice/settings.gradle
+++ /dev/null
@@ -1,13 +0,0 @@
-
-pluginManagement {
- repositories {
- maven { url "https://jitpack.io" }
- mavenLocal();
- google()
- mavenCentral()
- }
-}
-
-include ':memoryadvice_common'
-include ':memoryadvice'
-include ':memorytest'
diff --git a/test/memoryadvice_exampleclient/.clang-format b/test/memoryadvice_exampleclient/.clang-format
deleted file mode 100644
index 3b60c89..0000000
--- a/test/memoryadvice_exampleclient/.clang-format
+++ /dev/null
@@ -1,3 +0,0 @@
-BasedOnStyle: Google
-IndentWidth: 2
-SpacesBeforeTrailingComments: 2
diff --git a/test/memoryadvice_exampleclient/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/test/memoryadvice_exampleclient/app/src/main/res/drawable-v24/ic_launcher_foreground.xml
deleted file mode 100644
index 1f6bb29..0000000
--- a/test/memoryadvice_exampleclient/app/src/main/res/drawable-v24/ic_launcher_foreground.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:aapt="http://schemas.android.com/aapt"
- android:width="108dp"
- android:height="108dp"
- android:viewportWidth="108"
- android:viewportHeight="108">
- <path
- android:fillType="evenOdd"
- android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
- android:strokeWidth="1"
- android:strokeColor="#00000000">
- <aapt:attr name="android:fillColor">
- <gradient
- android:endX="78.5885"
- android:endY="90.9159"
- android:startX="48.7653"
- android:startY="61.0927"
- android:type="linear">
- <item
- android:color="#44000000"
- android:offset="0.0" />
- <item
- android:color="#00000000"
- android:offset="1.0" />
- </gradient>
- </aapt:attr>
- </path>
- <path
- android:fillColor="#FFFFFF"
- android:fillType="nonZero"
- android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
- android:strokeWidth="1"
- android:strokeColor="#00000000" />
-</vector>
diff --git a/test/memoryadvice_exampleclient/app/src/main/res/drawable/ic_launcher_background.xml b/test/memoryadvice_exampleclient/app/src/main/res/drawable/ic_launcher_background.xml
deleted file mode 100644
index 0d025f9..0000000
--- a/test/memoryadvice_exampleclient/app/src/main/res/drawable/ic_launcher_background.xml
+++ /dev/null
@@ -1,170 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="108dp"
- android:height="108dp"
- android:viewportWidth="108"
- android:viewportHeight="108">
- <path
- android:fillColor="#008577"
- android:pathData="M0,0h108v108h-108z" />
- <path
- android:fillColor="#00000000"
- android:pathData="M9,0L9,108"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M19,0L19,108"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M29,0L29,108"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M39,0L39,108"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M49,0L49,108"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M59,0L59,108"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M69,0L69,108"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M79,0L79,108"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M89,0L89,108"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M99,0L99,108"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M0,9L108,9"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M0,19L108,19"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M0,29L108,29"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M0,39L108,39"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M0,49L108,49"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M0,59L108,59"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M0,69L108,69"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M0,79L108,79"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M0,89L108,89"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M0,99L108,99"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M19,29L89,29"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M19,39L89,39"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M19,49L89,49"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M19,59L89,59"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M19,69L89,69"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M19,79L89,79"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M29,19L29,89"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M39,19L39,89"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M49,19L49,89"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M59,19L59,89"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M69,19L69,89"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M79,19L79,89"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
-</vector>
diff --git a/test/memoryadvice_exampleclient/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/test/memoryadvice_exampleclient/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
deleted file mode 100644
index eca70cf..0000000
--- a/test/memoryadvice_exampleclient/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
- <background android:drawable="@drawable/ic_launcher_background" />
- <foreground android:drawable="@drawable/ic_launcher_foreground" />
-</adaptive-icon>
\ No newline at end of file
diff --git a/test/memoryadvice_exampleclient/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/test/memoryadvice_exampleclient/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
deleted file mode 100644
index eca70cf..0000000
--- a/test/memoryadvice_exampleclient/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
- <background android:drawable="@drawable/ic_launcher_background" />
- <foreground android:drawable="@drawable/ic_launcher_foreground" />
-</adaptive-icon>
\ No newline at end of file
diff --git a/test/memoryadvice_exampleclient/app/src/main/res/mipmap-hdpi/ic_launcher.png b/test/memoryadvice_exampleclient/app/src/main/res/mipmap-hdpi/ic_launcher.png
deleted file mode 100644
index 898f3ed..0000000
--- a/test/memoryadvice_exampleclient/app/src/main/res/mipmap-hdpi/ic_launcher.png
+++ /dev/null
Binary files differ
diff --git a/test/memoryadvice_exampleclient/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/test/memoryadvice_exampleclient/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
deleted file mode 100644
index dffca36..0000000
--- a/test/memoryadvice_exampleclient/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
+++ /dev/null
Binary files differ
diff --git a/test/memoryadvice_exampleclient/app/src/main/res/mipmap-mdpi/ic_launcher.png b/test/memoryadvice_exampleclient/app/src/main/res/mipmap-mdpi/ic_launcher.png
deleted file mode 100644
index 64ba76f..0000000
--- a/test/memoryadvice_exampleclient/app/src/main/res/mipmap-mdpi/ic_launcher.png
+++ /dev/null
Binary files differ
diff --git a/test/memoryadvice_exampleclient/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/test/memoryadvice_exampleclient/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
deleted file mode 100644
index dae5e08..0000000
--- a/test/memoryadvice_exampleclient/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
+++ /dev/null
Binary files differ
diff --git a/test/memoryadvice_exampleclient/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/test/memoryadvice_exampleclient/app/src/main/res/mipmap-xhdpi/ic_launcher.png
deleted file mode 100644
index e5ed465..0000000
--- a/test/memoryadvice_exampleclient/app/src/main/res/mipmap-xhdpi/ic_launcher.png
+++ /dev/null
Binary files differ
diff --git a/test/memoryadvice_exampleclient/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/test/memoryadvice_exampleclient/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
deleted file mode 100644
index 14ed0af..0000000
--- a/test/memoryadvice_exampleclient/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
+++ /dev/null
Binary files differ
diff --git a/test/memoryadvice_exampleclient/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/test/memoryadvice_exampleclient/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
deleted file mode 100644
index b0907ca..0000000
--- a/test/memoryadvice_exampleclient/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
+++ /dev/null
Binary files differ
diff --git a/test/memoryadvice_exampleclient/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/test/memoryadvice_exampleclient/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
deleted file mode 100644
index d8ae031..0000000
--- a/test/memoryadvice_exampleclient/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
+++ /dev/null
Binary files differ
diff --git a/test/memoryadvice_exampleclient/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/test/memoryadvice_exampleclient/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
deleted file mode 100644
index 2c18de9..0000000
--- a/test/memoryadvice_exampleclient/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
+++ /dev/null
Binary files differ
diff --git a/test/memoryadvice_exampleclient/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/test/memoryadvice_exampleclient/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
deleted file mode 100644
index beed3cd..0000000
--- a/test/memoryadvice_exampleclient/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
+++ /dev/null
Binary files differ
diff --git a/test/memoryadvice_exampleclient/gradle/wrapper/gradle-wrapper.jar b/test/memoryadvice_exampleclient/gradle/wrapper/gradle-wrapper.jar
deleted file mode 100644
index f6b961f..0000000
--- a/test/memoryadvice_exampleclient/gradle/wrapper/gradle-wrapper.jar
+++ /dev/null
Binary files differ
diff --git a/test/memoryadvice_exampleclient/gradlew b/test/memoryadvice_exampleclient/gradlew
deleted file mode 100755
index cccdd3d..0000000
--- a/test/memoryadvice_exampleclient/gradlew
+++ /dev/null
@@ -1,172 +0,0 @@
-#!/usr/bin/env sh
-
-##############################################################################
-##
-## Gradle start up script for UN*X
-##
-##############################################################################
-
-# Attempt to set APP_HOME
-# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >/dev/null
-APP_HOME="`pwd -P`"
-cd "$SAVED" >/dev/null
-
-APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
-
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
-
-# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD="maximum"
-
-warn () {
- echo "$*"
-}
-
-die () {
- echo
- echo "$*"
- echo
- exit 1
-}
-
-# OS specific support (must be 'true' or 'false').
-cygwin=false
-msys=false
-darwin=false
-nonstop=false
-case "`uname`" in
- CYGWIN* )
- cygwin=true
- ;;
- Darwin* )
- darwin=true
- ;;
- MINGW* )
- msys=true
- ;;
- NONSTOP* )
- nonstop=true
- ;;
-esac
-
-CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
-
-# Determine the Java command to use to start the JVM.
-if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
- # IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
- else
- JAVACMD="$JAVA_HOME/bin/java"
- fi
- if [ ! -x "$JAVACMD" ] ; then
- die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
- fi
-else
- JAVACMD="java"
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
-fi
-
-# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
- MAX_FD_LIMIT=`ulimit -H -n`
- if [ $? -eq 0 ] ; then
- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
- MAX_FD="$MAX_FD_LIMIT"
- fi
- ulimit -n $MAX_FD
- if [ $? -ne 0 ] ; then
- warn "Could not set maximum file descriptor limit: $MAX_FD"
- fi
- else
- warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
- fi
-fi
-
-# For Darwin, add options to specify how the application appears in the dock
-if $darwin; then
- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
-fi
-
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
- APP_HOME=`cygpath --path --mixed "$APP_HOME"`
- CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
- JAVACMD=`cygpath --unix "$JAVACMD"`
-
- # We build the pattern for arguments to be converted via cygpath
- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
- SEP=""
- for dir in $ROOTDIRSRAW ; do
- ROOTDIRS="$ROOTDIRS$SEP$dir"
- SEP="|"
- done
- OURCYGPATTERN="(^($ROOTDIRS))"
- # Add a user-defined pattern to the cygpath arguments
- if [ "$GRADLE_CYGPATTERN" != "" ] ; then
- OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
- fi
- # Now convert the arguments - kludge to limit ourselves to /bin/sh
- i=0
- for arg in "$@" ; do
- CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
- CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
-
- if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
- eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
- else
- eval `echo args$i`="\"$arg\""
- fi
- i=$((i+1))
- done
- case $i in
- (0) set -- ;;
- (1) set -- "$args0" ;;
- (2) set -- "$args0" "$args1" ;;
- (3) set -- "$args0" "$args1" "$args2" ;;
- (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
- esac
-fi
-
-# Escape application args
-save () {
- for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
- echo " "
-}
-APP_ARGS=$(save "$@")
-
-# Collect all arguments for the java command, following the shell quoting and substitution rules
-eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
-
-# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
-if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
- cd "$(dirname "$0")"
-fi
-
-exec "$JAVACMD" "$@"
diff --git a/test/memoryadvice_exampleclient/gradlew.bat b/test/memoryadvice_exampleclient/gradlew.bat
deleted file mode 100644
index f955316..0000000
--- a/test/memoryadvice_exampleclient/gradlew.bat
+++ /dev/null
@@ -1,84 +0,0 @@
-@if "%DEBUG%" == "" @echo off
-@rem ##########################################################################
-@rem
-@rem Gradle startup script for Windows
-@rem
-@rem ##########################################################################
-
-@rem Set local scope for the variables with windows NT shell
-if "%OS%"=="Windows_NT" setlocal
-
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-set APP_BASE_NAME=%~n0
-set APP_HOME=%DIRNAME%
-
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
-
-@rem Find java.exe
-if defined JAVA_HOME goto findJavaFromJavaHome
-
-set JAVA_EXE=java.exe
-%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
-
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:findJavaFromJavaHome
-set JAVA_HOME=%JAVA_HOME:"=%
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-
-if exist "%JAVA_EXE%" goto init
-
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:init
-@rem Get command-line arguments, handling Windows variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-
-:execute
-@rem Setup the command line
-
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
-
-@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
-
-:end
-@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
-
-:fail
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
-rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
-
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
-
-:omega