diff options
author | Yabin Cui <yabinc@google.com> | 2017-07-26 12:29:44 -0700 |
---|---|---|
committer | Yabin Cui <yabinc@google.com> | 2017-07-28 15:07:41 -0700 |
commit | d97a532cb291aa8c5b5b1f000052c581faa50f29 (patch) | |
tree | 9bed67bd4a1a9602313d1784512d65b955f6aee8 /simpleperf/demo/SimpleperfExampleOfKotlin | |
parent | 6fd3f9b50db7f3c5896e06488d0fe17878599ec0 (diff) | |
download | extras-d97a532cb291aa8c5b5b1f000052c581faa50f29.tar.gz |
simpleperf add more script tests.
Add tests for Trace offcpu.
Add test for jni call.
Build testdata when running test.py.
Bug: http://b/63006886
Test: run test.py.
Change-Id: I5a87b8d2a8f59ead858c1b78a78c7e78847854f4
Diffstat (limited to 'simpleperf/demo/SimpleperfExampleOfKotlin')
7 files changed, 67 insertions, 4 deletions
diff --git a/simpleperf/demo/SimpleperfExampleOfKotlin/app/build.gradle b/simpleperf/demo/SimpleperfExampleOfKotlin/app/build.gradle index e7110fb7..f9178042 100644 --- a/simpleperf/demo/SimpleperfExampleOfKotlin/app/build.gradle +++ b/simpleperf/demo/SimpleperfExampleOfKotlin/app/build.gradle @@ -30,7 +30,7 @@ dependencies { androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) - implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" implementation 'com.android.support:appcompat-v7:25.4.0' testImplementation 'junit:junit:4.12' implementation 'com.android.support.constraint:constraint-layout:1.0.2' diff --git a/simpleperf/demo/SimpleperfExampleOfKotlin/app/build/outputs/apk/profiling/app-profiling.apk b/simpleperf/demo/SimpleperfExampleOfKotlin/app/build/outputs/apk/profiling/app-profiling.apk Binary files differnew file mode 100644 index 00000000..fde5086e --- /dev/null +++ b/simpleperf/demo/SimpleperfExampleOfKotlin/app/build/outputs/apk/profiling/app-profiling.apk diff --git a/simpleperf/demo/SimpleperfExampleOfKotlin/app/src/main/AndroidManifest.xml b/simpleperf/demo/SimpleperfExampleOfKotlin/app/src/main/AndroidManifest.xml index 05eb9ee4..33e820ea 100644 --- a/simpleperf/demo/SimpleperfExampleOfKotlin/app/src/main/AndroidManifest.xml +++ b/simpleperf/demo/SimpleperfExampleOfKotlin/app/src/main/AndroidManifest.xml @@ -16,6 +16,10 @@ <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> + <activity android:name=".SleepActivity" + android:exported="true"> + + </activity> </application> </manifest>
\ No newline at end of file diff --git a/simpleperf/demo/SimpleperfExampleOfKotlin/app/src/main/java/com/example/simpleperf/simpleperfexampleofkotlin/SleepActivity.kt b/simpleperf/demo/SimpleperfExampleOfKotlin/app/src/main/java/com/example/simpleperf/simpleperfexampleofkotlin/SleepActivity.kt new file mode 100644 index 00000000..2ed5afe5 --- /dev/null +++ b/simpleperf/demo/SimpleperfExampleOfKotlin/app/src/main/java/com/example/simpleperf/simpleperfexampleofkotlin/SleepActivity.kt @@ -0,0 +1,50 @@ +package com.example.simpleperf.simpleperfexampleofkotlin + +import android.support.v7.app.AppCompatActivity +import android.os.Bundle + +class SleepActivity : AppCompatActivity() { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_sleep) + createRunSleepThread(); + } + + fun createRunSleepThread() { + object : Thread() { + var counter = 0 + var totalRunTimeInNs: Long = 0 + var totalSleepTimeInNs: Long = 0 + + fun RunFunction(): Long { + var startTimeInNs = System.nanoTime() + var i = 0 + while (i < 10000000) { + counter = callFunction(counter) + i++ + } + return System.nanoTime() - startTimeInNs + } + + fun SleepFunction(sleepTimeInNs: Long): Long { + var startTimeInNs = System.nanoTime() + Thread.sleep(sleepTimeInNs / 1000000, (sleepTimeInNs % 1000000).toInt()) + return System.nanoTime() - startTimeInNs + } + + override fun run() { + while (true) { + totalRunTimeInNs += RunFunction() + if (totalSleepTimeInNs < totalRunTimeInNs) { + totalSleepTimeInNs += SleepFunction(totalRunTimeInNs - totalSleepTimeInNs) + } + } + } + + fun callFunction(i: Int): Int { + return i + 1 + } + }.start() + } +} diff --git a/simpleperf/demo/SimpleperfExampleOfKotlin/app/src/main/res/layout/activity_sleep.xml b/simpleperf/demo/SimpleperfExampleOfKotlin/app/src/main/res/layout/activity_sleep.xml new file mode 100644 index 00000000..7043eb11 --- /dev/null +++ b/simpleperf/demo/SimpleperfExampleOfKotlin/app/src/main/res/layout/activity_sleep.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="utf-8"?> +<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="match_parent" + tools:context="com.example.simpleperf.simpleperfexampleofkotlin.SleepActivity"> + +</android.support.constraint.ConstraintLayout> diff --git a/simpleperf/demo/SimpleperfExampleOfKotlin/build.gradle b/simpleperf/demo/SimpleperfExampleOfKotlin/build.gradle index 2e0233ba..f54592ff 100644 --- a/simpleperf/demo/SimpleperfExampleOfKotlin/build.gradle +++ b/simpleperf/demo/SimpleperfExampleOfKotlin/build.gradle @@ -7,7 +7,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.0.0-alpha4' + classpath 'com.android.tools.build:gradle:3.0.0-alpha8' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong diff --git a/simpleperf/demo/SimpleperfExampleOfKotlin/gradle/wrapper/gradle-wrapper.properties b/simpleperf/demo/SimpleperfExampleOfKotlin/gradle/wrapper/gradle-wrapper.properties index 96b0280b..8295c9f6 100644 --- a/simpleperf/demo/SimpleperfExampleOfKotlin/gradle/wrapper/gradle-wrapper.properties +++ b/simpleperf/demo/SimpleperfExampleOfKotlin/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Mon Jun 26 18:23:25 PDT 2017 +#Wed Jul 26 16:12:43 PDT 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-rc-1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-milestone-1-all.zip |