Created
February 8, 2018 22:55
-
-
Save damien5314/e1e7a1a69a3ce09789bc273dc8cfed3f to your computer and use it in GitHub Desktop.
Activity designed to test performance of Apptimize.track
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="utf-8"?> | |
| <LinearLayout | |
| 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:layout_margin="16dp" | |
| android:gravity="center" | |
| android:orientation="vertical"> | |
| <Button | |
| android:id="@+id/apptimize_performance_activity_button1" | |
| android:layout_width="240dp" | |
| android:layout_height="wrap_content" | |
| android:text="Apptimize" | |
| tools:ignore="HardcodedText" /> | |
| <android.support.v4.widget.Space | |
| android:layout_width="match_parent" | |
| android:layout_height="16dp" /> | |
| <Button | |
| android:id="@+id/apptimize_performance_activity_button2" | |
| android:layout_width="240dp" | |
| android:layout_height="wrap_content" | |
| android:text="No Apptimize" | |
| tools:ignore="HardcodedText" /> | |
| </LinearLayout> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.quizlet.android.apptimize | |
| import android.os.Bundle | |
| import android.support.v7.app.AppCompatActivity | |
| import android.util.Log | |
| import android.widget.Button | |
| import com.apptimize.Apptimize | |
| import com.quizlet.quizletandroid.R | |
| /** | |
| * Class with two buttons. One button triggers an Apptimize event | |
| * via [Apptimize.track], the other has an empty click handler. | |
| */ | |
| class ApptimizePerformanceActivity : AppCompatActivity() { | |
| private lateinit var buttonWithApptimize: Button | |
| private lateinit var buttonWithoutApptimize: Button | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| setContentView(R.layout.apptimize_performance_activity) | |
| buttonWithApptimize = findViewById(R.id.apptimize_performance_activity_button1) | |
| buttonWithoutApptimize = findViewById(R.id.apptimize_performance_activity_button2) | |
| buttonWithApptimize.setOnClickListener { | |
| val start = System.nanoTime() | |
| doWithApptimize() | |
| val end = System.nanoTime() | |
| val elapsed = end - start | |
| Log.d("PERFMATTERS", "doWithApptimize: $elapsed ns") | |
| } | |
| buttonWithoutApptimize.setOnClickListener { | |
| val start = System.nanoTime() | |
| doWithoutApptimize() | |
| val end = System.nanoTime() | |
| val elapsed = end - start | |
| Log.d("PERFMATTERS", "doWithoutApptimize: $elapsed ns") | |
| } | |
| } | |
| private fun doWithApptimize() { | |
| Apptimize.track("apptimize_performance_testing") | |
| } | |
| private fun doWithoutApptimize() { | |
| Log.d("PERFMATTERS", "Click handler triggered") | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment