Efficiency of sax and script packages in android

Source: Internet
Author: User

 

SAX and script in debug mode

The efficiency is extremely slow, and the running mode is much better, about 5-10 times faster.

 

In addition, the script package will compile a print method, which takes a lot of time and seriously affects the efficiency.

After removing and optimizing

500 scripts, which are reduced from 1 s to 200 ms

 

The code is simplified as follows:

 

RhinoScriptEngine. java

Scriptable getruntimesxt (ScriptContext ctxt ){

If (ctxt = null ){

Throw new NullPointerException ("null script context ");

}

 

// We create a scope for the given ScriptContext

Scriptable newScope = new ExternalScriptable (ctxt, indexedProps );

 

// Set the prototype of newScope to be 'toplevel' so that

// JavaScript standard objects are visible from the scope.

NewScope. setPrototype (topLevel );

 

// Define "context" variable in the new scope

NewScope. put ("context", newScope, ctxt );

 

// Define "print", "println" functions in the new scope

// Remove the following lines

// Context cx = enterContext ();

// Try {

// Cx. evaluateString (newScope, printSource, "print", 1, null );

//} Finally {

// Cx. exit ();

//}

Return newScope;

}

Related Article

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.