Skip to content

Commit

Permalink
trying to get the profiler working
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielZlotin committed May 17, 2018
1 parent 6e5fb90 commit 55f4e71
Show file tree
Hide file tree
Showing 16 changed files with 105 additions and 108 deletions.
3 changes: 0 additions & 3 deletions measure/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/jsc


# Created by https://www.gitignore.io/api/node,android,reactnative,intellij+all,androidstudio,visualstudiocode

### Android ###
Expand Down
31 changes: 21 additions & 10 deletions measure/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
apply plugin: "com.android.application"

ext.react = [
jsBundleDirRelease: "$buildDir/intermediates/merged_assets/release/mergeReleaseAssets/out"
]

apply from: "$rootDir/../node_modules/react-native/react.gradle"

android {
compileSdkVersion 27
buildToolsVersion "27.0.3"

defaultConfig {
applicationId "com.reactnativeperf"
applicationId "com.javascriptcore.profiler"
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"//, "arm64-v8a", "x86_64"
abiFilters = JSC_VERSION.contains("x64") ? ["armeabi-v7a", "x86", "arm64-v8a", "x86_64"] : ["armeabi-v7a", "x86"]
}
}
signingConfigs {
release {
storeFile file("$rootDir/keystores/release.keystore")
storePassword 'jscore'
keyAlias 'jscore'
keyPassword 'jscore'
}
release {
storeFile file("$rootDir/keystores/release.keystore")
storePassword 'jscore'
keyAlias 'jscore'
keyPassword 'jscore'
}
}
buildTypes {
release {
Expand All @@ -34,7 +39,13 @@ android {

dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:26.1.0"
implementation "com.android.support:appcompat-v7:27.1.1"
implementation "com.facebook.react:react-native:+" // From node_modules
implementation project(":react-native-navigation")
}

// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
20 changes: 7 additions & 13 deletions measure/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.reactnativeperf"
android:versionCode="1"
android:versionName="1.0">
package="com.javascriptcore.profiler">

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />

<permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>

<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="26"/>
<permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />

<application
android:name=".MainApplication"
Expand All @@ -23,11 +17,11 @@
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity"/>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.javascriptcore.profiler;


import com.facebook.react.ReactActivity;

import javax.annotation.Nullable;

public class MainActivity extends ReactActivity {
@Nullable
@Override
protected String getMainComponentName() {
return "MainScreen";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.javascriptcore.profiler;

import android.app.Application;

import com.facebook.react.*;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;

import java.util.Arrays;
import java.util.List;

public class MainApplication extends Application implements ReactApplication {

@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, false);
}

private ReactNativeHost host = new ReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return false;
}

@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(new MainReactPackage());
}
};

@Override
public ReactNativeHost getReactNativeHost() {
return host;
}
}

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion measure/android/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<resources>
<string name="app_name">perf</string>
<string name="app_name">JavaScriptCore Profiler</string>
</resources>
42 changes: 18 additions & 24 deletions measure/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

project.ext.JSC_ZIP_DIR = "$rootDir/../../dist"
project.ext.JSC_DIR = "$rootDir/../jsc"
def listFiles = new File(project.JSC_ZIP_DIR).listFiles().findAll{ it.name.endsWith('.zip') }
project.ext.JSC_ZIP_FILE = listFiles[listFiles.size() - 1]
project.ext.JSC_NAME = project.JSC_ZIP_FILE.name.take(project.JSC_ZIP_FILE.name.lastIndexOf('.'))
println "\n\n\t\tCompiling using javascript core for android, version ======== ${(char)27}[35m${project.JSC_NAME}${(char)27}[0m =======\n\n"

delete project.JSC_DIR
copy() {
from zipTree(file(project.JSC_ZIP_FILE))
into file(project.JSC_DIR)
ext {
JSC_DIR = "$rootDir/../../dist"
JSC_VERSION = file(file(fileTree(dir: JSC_DIR).find { it.name.endsWith(".aar") }).getParent()).getName()
}

println "\n\n\t\tUsing javascript core for android, version ${(char) 27}[35m${JSC_VERSION}${(char) 27}[0m \n\n"

allprojects {
configurations.all {
resolutionStrategy {
force "org.webkit:android-jsc:${project.JSC_NAME}"
configurations.all {
resolutionStrategy {
force "org.webkit:android-jsc:${JSC_VERSION}"
}
}
}
}

buildscript {
Expand All @@ -29,7 +23,7 @@ buildscript {
mavenLocal()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.android.tools.build:gradle:3.+'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -38,18 +32,18 @@ buildscript {

allprojects {
repositories {
google()
jcenter()
mavenCentral()
mavenLocal()
// this tells gradle where android-jsc resides
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
url JSC_DIR
}

// this tells gradle where android-jsc resides
maven {
url project.JSC_DIR
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
google()
jcenter()
mavenCentral()
mavenLocal()
}
}
3 changes: 2 additions & 1 deletion measure/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#Tue May 15 12:33:24 IDT 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-all.zip
8 changes: 0 additions & 8 deletions measure/android/keystores/BUCK

This file was deleted.

4 changes: 0 additions & 4 deletions measure/android/keystores/debug.keystore.properties

This file was deleted.

2 changes: 1 addition & 1 deletion measure/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
rootProject.name = 'ReactNativePerf'
rootProject.name = 'JavaScriptCore Profiler'

include ':app'
11 changes: 2 additions & 9 deletions measure/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const RENDER_JS = 1;
const RENDER_PERF = 2;
const RENDER_PERF_DEEP = 4;

class ReactNativePerf extends Component {
class MainScreen extends Component {
constructor(props) {
super(props);
this.state = {
Expand Down Expand Up @@ -80,11 +80,4 @@ const styles = StyleSheet.create({
}
});

AppRegistry.registerComponent('ReactNativePerf', () => ReactNativePerf);

Navigation.startSingleScreenApp({
screen: {
screen: 'ReactNativePerf',
title: 'JSCore Perf Measurements'
}
});
AppRegistry.registerComponent('MainScreen', () => MainScreen);
4 changes: 2 additions & 2 deletions measure/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "react-native-android-perf-measure",
"name": "javascriptcore-profiler",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "cd android && rm -rf build && rm -rf app/build && ./gradlew installRelease"
"android": "cd android && rm -rf build && rm -rf app/build && ./gradlew clean installRelease"
},
"dependencies": {
"react-native": "0.51.0",
Expand Down
1 change: 1 addition & 0 deletions measure/perf/RenderPerf.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const SCALE = 1000;

class RenderPerf extends Component {
constructor(props) {
super(props);
this.startTime = Date.now();
this.onLayout = this.onLayout.bind(this);
}
Expand Down

0 comments on commit 55f4e71

Please sign in to comment.