Skip to content

Commit

Permalink
Add microbenchmarks for message decryption.
Browse files Browse the repository at this point in the history
  • Loading branch information
greyson-signal committed Apr 12, 2023
1 parent 0156e74 commit 6d4906d
Show file tree
Hide file tree
Showing 16 changed files with 611 additions and 13 deletions.
2 changes: 1 addition & 1 deletion benchmark/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ android {
testOptions {
managedDevices {
devices {
create ("api31", ManagedVirtualDevice::class) {
create("api31", ManagedVirtualDevice::class) {
device = "Pixel 6"
apiLevel = 31
systemImageSource = "aosp"
Expand Down
8 changes: 8 additions & 0 deletions build-logic/plugins/src/main/java/ktlint.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
plugins {
id("org.jlleitschuh.gradle.ktlint")
}

ktlint {
// Use a newer version to resolve https://github.com/JLLeitschuh/ktlint-gradle/issues/507
version.set("0.47.1")
}
7 changes: 1 addition & 6 deletions build-logic/plugins/src/main/java/signal-library.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ val signalJavaVersion: JavaVersion by extra
plugins {
id("com.android.library")
id("kotlin-android")
id("org.jlleitschuh.gradle.ktlint")
id("android-constants")
id("ktlint")
}

android {
Expand Down Expand Up @@ -46,11 +46,6 @@ android {
}
}

ktlint {
// Use a newer version to resolve https://github.com/JLLeitschuh/ktlint-gradle/issues/507
version.set("0.47.1")
}

dependencies {
lintChecks(project(":lintchecks"))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ val signalJavaVersion: JavaVersion by extra
plugins {
id("com.android.application")
id("kotlin-android")
id("org.jlleitschuh.gradle.ktlint")
id("ktlint")
id("android-constants")
}

Expand Down Expand Up @@ -47,11 +47,6 @@ android {
}
}

ktlint {
// Use a newer version to resolve https://github.com/JLLeitschuh/ktlint-gradle/issues/507
version.set("0.47.1")
}

dependencies {
coreLibraryDesugaring(libs.android.tools.desugar)

Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ buildscript {
exclude group: 'com.squareup.wire', module: 'wire-grpc-server-generator'
exclude group: 'io.outfoxx', module: 'swiftpoet'
}
classpath 'androidx.benchmark:benchmark-gradle-plugin:1.1.0-beta04'
}
}

Expand Down
1 change: 1 addition & 0 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ dependencyResolutionManagement {
alias('espresso-core').to('androidx.test.espresso:espresso-core:3.4.0')
alias('uiautomator').to('androidx.test.uiautomator:uiautomator:2.2.0')
alias('androidx-benchmark-macro').to('androidx.benchmark:benchmark-macro-junit4:1.1.1')
alias('androidx-benchmark-micro').to('androidx.benchmark:benchmark-junit4:1.1.0-beta04')
}

testLibs {
Expand Down
58 changes: 58 additions & 0 deletions gradle/verification-metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ https://docs.gradle.org/current/userguide/dependency_verification.html
<sha256 value="4c84feee2db891ff6b97d613a0d40ab96ce297b034a6927ca8479f09e82d7c2e" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="androidx.annotation" name="annotation-experimental" version="1.0.0">
<artifact name="annotation-experimental-1.0.0.aar">
<sha256 value="b219d2b568e7e4ba534e09f8c2fd242343df6ccbdfbbe938846f5d740e6b0b11" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="androidx.annotation" name="annotation-experimental" version="1.1.0">
<artifact name="annotation-experimental-1.1.0.aar">
<sha256 value="0157de61a2064047896a058080f3fd67ba57ad9a94857b3f7a363660243e3f90" origin="Generated by Gradle"/>
Expand Down Expand Up @@ -180,6 +185,14 @@ https://docs.gradle.org/current/userguide/dependency_verification.html
<sha256 value="c9468f56e05006ea151a426c54957cd0799b8b83a579d2846dd22061f33e5ecd" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="androidx.benchmark" name="benchmark-common" version="1.1.0-beta04">
<artifact name="benchmark-common-1.1.0-beta04.aar">
<sha256 value="0d5d97bec86870ee542da651ba3d5ac1977318bec5047205bbdb22afa7eb84be" origin="Generated by Gradle"/>
</artifact>
<artifact name="benchmark-common-1.1.0-beta04.module">
<sha256 value="83a7d93e6a941236619117f46b8911f1cdf28be6a8765fe6b8b3ee122d992a09" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="androidx.benchmark" name="benchmark-common" version="1.1.0-beta05">
<artifact name="benchmark-common-1.1.0-beta05.aar">
<sha256 value="685021a5a65fc92f94e84a942f029edb2fc77e89144b666c8a85e1538f35ad19" origin="Generated by Gradle"/>
Expand All @@ -204,6 +217,22 @@ https://docs.gradle.org/current/userguide/dependency_verification.html
<sha256 value="5c22871af95906149ea0a0ae9a30d76e93c35382dd5a1cb8df942773143325b8" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="androidx.benchmark" name="benchmark-gradle-plugin" version="1.1.0-beta04">
<artifact name="benchmark-gradle-plugin-1.1.0-beta04.jar">
<sha256 value="ffcad358968c938d69922f1082b637bd7ee9d7a60bfd9433df7f5b131c9c8df6" origin="Generated by Gradle"/>
</artifact>
<artifact name="benchmark-gradle-plugin-1.1.0-beta04.module">
<sha256 value="b39229f5f951ff9091d0c42d29cdd272a96112a9bd5100131a465db656456773" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="androidx.benchmark" name="benchmark-junit4" version="1.1.0-beta04">
<artifact name="benchmark-junit4-1.1.0-beta04.aar">
<sha256 value="6977d2a084b46a16d4e3f1b7e76ef085337cf960a1ff44939b845c22e93bf94a" origin="Generated by Gradle"/>
</artifact>
<artifact name="benchmark-junit4-1.1.0-beta04.module">
<sha256 value="e6c8b5a5b5904ee2e1f62ffb3472af4007197f429acb42003939703581056a14" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="androidx.benchmark" name="benchmark-macro" version="1.1.0-beta05">
<artifact name="benchmark-macro-1.1.0-beta05.aar">
<sha256 value="979733a465d24a85536d4a51d0a9bfc20d8cd6537e032f88a5fb669f25d880e7" origin="Generated by Gradle"/>
Expand Down Expand Up @@ -1184,6 +1213,11 @@ https://docs.gradle.org/current/userguide/dependency_verification.html
<sha256 value="c1753946c498b0d5d7cf341cfed661f66915c4c9deb4ed10462a08ae33b2429a" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="androidx.test" name="rules" version="1.4.0">
<artifact name="rules-1.4.0.aar">
<sha256 value="01401cd7d1185530f6081ce503ce611d18d8a483ea15599a16c39f15b2f8e7d8" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="androidx.test" name="runner" version="1.4.0">
<artifact name="runner-1.4.0.aar">
<sha256 value="e3f3d8b8d5d4a3edcacbdaa4a31bda2b0e41d3e704b02b3750466a06367ec5a0" origin="Generated by Gradle"/>
Expand Down Expand Up @@ -1267,6 +1301,9 @@ https://docs.gradle.org/current/userguide/dependency_verification.html
</artifact>
</component>
<component group="androidx.tracing" name="tracing-ktx" version="1.0.0">
<artifact name="tracing-ktx-1.0.0.aar">
<sha256 value="3a918d0d2318b8cca1062cdddb2f7b4077ee2f270093850010379d579cdc8b6e" origin="Generated by Gradle"/>
</artifact>
<artifact name="tracing-ktx-1.0.0.module">
<sha256 value="f426e636a23a05db8c7fabf2b959f4dab80c9ca97b5131bf411d422555c48c18" origin="Generated by Gradle"/>
</artifact>
Expand Down Expand Up @@ -3404,6 +3441,14 @@ https://docs.gradle.org/current/userguide/dependency_verification.html
<sha256 value="17f48d41775bd84dea78e9dfed8dfbcc66af80567a5c9ec9d9608785ec820cde" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.squareup.okio" name="okio-metadata" version="2.8.0">
<artifact name="okio-metadata-2.8.0.jar">
<sha256 value="f7dc3883ceae2e1fe3425e1b54c5df28b8857c5fd00381b521fda60790f2952c" origin="Generated by Gradle"/>
</artifact>
<artifact name="okio-metadata-2.8.0.module">
<sha256 value="a4eef641be5e5463d2789c3c73601f9a99f36e1377ca007e30f0fee53a054cdc" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.squareup.okio" name="okio-multiplatform" version="2.8.0">
<artifact name="okio-multiplatform-2.8.0.module">
<sha256 value="87c4327538ba166a914171631470a6e9db2b007125bae164af6b0d47aefd34d7" origin="Generated by Gradle"/>
Expand Down Expand Up @@ -3481,6 +3526,14 @@ https://docs.gradle.org/current/userguide/dependency_verification.html
<sha256 value="b02d3bd2e4929ccb0ab36c88b569b10fc27b360711ee1718126a3b11b317d7f7" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.squareup.wire" name="wire-runtime-metadata" version="3.6.0">
<artifact name="wire-runtime-metadata-3.6.0.jar">
<sha256 value="89e54163f6219b177838e9f2c18d023c3ee2c01427c3b621694717f58ee4f300" origin="Generated by Gradle"/>
</artifact>
<artifact name="wire-runtime-metadata-3.6.0.module">
<sha256 value="39dcf0ac4b2ca9e8b1fe7fdc4085aeaeefce335fb059c015ca24ec5ef0ff9ec5" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.squareup.wire" name="wire-schema" version="4.4.3">
<artifact name="wire-schema-4.4.3.module">
<sha256 value="44c4bf54631537be1e096d09e5557f801f4e93f853ed5830168483c6cd4c832b" origin="Generated by Gradle"/>
Expand Down Expand Up @@ -4506,6 +4559,11 @@ https://docs.gradle.org/current/userguide/dependency_verification.html
<sha256 value="4800ceacb2ec0bb9959a087154b8e35318ead1ea4eba32d4bb1b9734222a7e68" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.jetbrains.kotlin" name="kotlin-stdlib" version="1.6.10">
<artifact name="kotlin-stdlib-1.6.10.jar">
<sha256 value="5305f7a4dee7a6cb79a29c258aca93de47b49588a6dfc6da01bd8772589ea66c" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.jetbrains.kotlin" name="kotlin-stdlib" version="1.6.21">
<artifact name="kotlin-stdlib-1.6.21.jar">
<sha256 value="739c526672bb337573b28f63afa8306eb088b0c3a0967f56d6c89f4a3012a492" origin="Generated by Gradle"/>
Expand Down
1 change: 1 addition & 0 deletions microbenchmark/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
37 changes: 37 additions & 0 deletions microbenchmark/benchmark-proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

-dontobfuscate

-ignorewarnings

-keepattributes *Annotation*

-dontnote junit.framework.**
-dontnote junit.runner.**

-dontwarn androidx.test.**
-dontwarn org.junit.**
-dontwarn org.hamcrest.**
-dontwarn com.squareup.javawriter.JavaWriter

-keepclasseswithmembers @org.junit.runner.RunWith public class *
63 changes: 63 additions & 0 deletions microbenchmark/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
@file:Suppress("UnstableApiUsage")

plugins {
id("com.android.library")
id("androidx.benchmark")
id("org.jetbrains.kotlin.android")
id("android-constants")
id("ktlint")
}

val signalBuildToolsVersion: String by extra
val signalCompileSdkVersion: String by extra
val signalTargetSdkVersion: Int by extra
val signalMinSdkVersion: Int by extra
val signalJavaVersion: JavaVersion by extra

android {
namespace = "org.signal.microbenchmark"
compileSdkVersion = signalCompileSdkVersion

compileOptions {
sourceCompatibility = signalJavaVersion
targetCompatibility = signalJavaVersion
}

kotlinOptions {
jvmTarget = "11"
}

defaultConfig {
minSdk = signalMinSdkVersion
targetSdk = signalTargetSdkVersion

testInstrumentationRunner = "androidx.benchmark.junit4.AndroidBenchmarkRunner"
}

testBuildType = "release"
buildTypes {
debug {
// Since isDebuggable can't be modified by gradle for library modules,
// it must be done in a manifest - see src/androidTest/AndroidManifest.xml
isMinifyEnabled = true
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "benchmark-proguard-rules.pro")
}
release {
isDefault = true
}
}
}

dependencies {
lintChecks(project(":lintchecks"))

// Base dependencies
androidTestImplementation(testLibs.junit.junit)
androidTestImplementation(benchmarkLibs.androidx.test.ext.junit)
androidTestImplementation(benchmarkLibs.androidx.benchmark.micro)

// Dependencies of modules being tested
androidTestImplementation(project(":libsignal-service"))
androidTestImplementation(libs.libsignal.android)
androidTestImplementation(libs.google.protobuf.javalite)
}
15 changes: 15 additions & 0 deletions microbenchmark/src/androidTest/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<!--
Important: disable debugging for accurate performance results
In a com.android.library project, this flag must be disabled from this
manifest, as it is not possible to override this flag from Gradle.
-->
<application
android:debuggable="false"
tools:ignore="HardcodedDebugMode"
tools:replace="android:debuggable" />
</manifest>

0 comments on commit 6d4906d

Please sign in to comment.