Android code JIT friendliness testing tool _android

Source: Internet
Author: User

Using the weekend's time, write a tool to detect the JIT friendliness of the Android code, taking a name of Droidjitchecker. Hope to help you quickly find a bad taste of the code, and timely correction.

noun explanation

    1. Jit:jit Full name Just-in-time compilation. Real-time compilation is an optimization technique in the JVM, which translates bytecode into machine code and improves execution efficiency by optimizing the frequently invoked and eligible methods.
    2. Method Size: The method body implementation of each method is measured in bytes as a unit, and in general, the larger the method body, the larger the method size.
    3. JIT-friendly: Usually the smaller the method, the simpler, the more JIT-compiled friendly.

What is it

    1. This is a tool to detect the JIT friendliness of Android (Directory organization structure) code
    2. The tool is assembled based on the jarscan.sh in Adoptopenjdk/jitwatch
    3. Output supports HTML for easy viewing in browsers

Prerequisite Preparation

    1. The detected Android project can support Gradle compilation success
    2. Install Jitwatch Kit
    3. Ruby Running Environment

Installation

Installing Jitwatch Components

Get code

git clone git@github.com:adoptopenjdk/jitwatch.git

Compile

Enter the repo directory above, using one of the following three methods can be

Ant

Ant Clean compile test run

Maven

MVN Clean Compile test Exec:java

Gradle

Gradlew Clean Build Run

Configuration

Get the code for this repo and open config.ini file modification

[Setup]
Jarscan = "/users/androidyue/github/jitwatch/jarscan.sh"
maxmethodsize = 325
OutputDir = "/tmp/ droidjitchecker/output_new/"

Modification Notes

    1. Jarscan must be modified to a jarscan path that has been installed
    2. Maxmethodsize do not need to change, such as change caution
    3. Output directory, OutputDir, recommended to be modified as a sustainable directory

How to use

Easy to use, open the terminal, execute the following statement

Ruby Jitchecker.rb Your_android_project Jartask

Note: Jartask is a task that compiles a project's Java file into a jar package that can be viewed by performing the./gradlew tasks, and then selecting a task that starts with a jar.

View Results

    1. When the check is finished, the results are automatically opened using the browser
    2. The resulting file path is also exported to the terminal
    3. The result file name contains the relevant Jartask information for easy lookup
    4. The resulting content, sorted by the byte size of the method, in descending order from large to small

A typical sample of content

Md4.mdfour64

Package:com.app.utils
parameters:int[]
bytesize:1129
    1. Md4.mdfour64 methods of JIT-unfriendly and their classes
    2. Package:com.app.utils the above MD4 belong to the package
    3. Parameters:int[] The parameters accepted by the Mdfour64 method
    4. BYTESIZE:1129 represents the size held by the Mdfour64 method

How to Solve

    1. A simple method of writing logic and a single responsibility
    2. A simple method of writing logic and a single responsibility
    3. A simple method of writing logic and a single responsibility

Contribution Code

Any helpful suggestions are welcome.

The following code contribution is more welcome

Landscaping Results Display page (HTML,CSS)

Problem

Q: A large number of bytes of the method must be modified, modify the JIT can be compiled?

A: A large number of bytes of the method proposed to modify, not mandatory, modified may not be JIT-compiled, because the JIT optimization does not mean that the JIT compiled the method, but also need other factors, such as the frequency of calls to the method. So this is a thing that you love me.

Why use Ruby

A: It's a struggle to have idea, because it's not sure what language to implement, especially between Python and Ruby, to ask a lot of students, and finally "just" decided to use Ruby, do not like the mandatory alignment of Python, super like Ruby string template. Ruby is simple and humane, and I'm sure you'll like it.

Source

Droidjitchecker@github

The above is on the Android JIT code friendliness testing tool data collation, thank you for your support of this site!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.