2016-04-25-Information System practice notes on the performance of 6-JS call Flex Example

Source: Internet
Author: User

Layout:post
The practice of title:2016-04-25-information System a case of 6-JS calling Flex performance
key:20160425
Tags:gis JS FLEX Technology selection Performance API call
modify_date:2016-04-25
---

The practice of information system a case of 6-JS invoking Flex performance

Description

    • This article was posted in: Gitee,github, Blog Park
    • Please specify the original author and connection and source.

Body:

    • Information System Practice Notes series is the author in peacetime research and development has encountered the size of the problem, which is more typical content to be collected and shared.
    • Information System Practice Notes directory: Blog Park (or view the source of the readme.md file)

Summary:

    • This article describes some of the experience summaries of JS and flex (Flash) interactions.

Body

In the author's practice, in some cases (such as the development of map applications), the client's JS code is often called the map engine API.
Map Engine API, some are JS interface, that the most convenient, some are the Flex programming interface API (running in Flash), JS calls Flex performance has the following experience.
For example, the client is a map-based application, using the JS code to call the Flex API interface, you need to use Flex's statement on the map to render (place) 20,000 objects (object).

  • Method A (Low efficiency):
  • In JS, the information data of n million devices are obtained through the business layer, such as array dev[n0000];
  • In JS, the information data is packaged as HashMap (key-value);
  • In JS, the HASHMAP data structure from JS into Flex:js---Flex;
  • In Flex, get the incoming HASHMAP structure and loop over the GIS map;
  • In Flex, a service with key check value is provided through the HASHMAP structure: val = devicehashmap.get (key);
  • Performance Evaluation & Analysis:
  • In step 2,3,4 consumes about 20 seconds, the data volume is 20,000 device, the main step is 3 slower;
  • Preliminary estimates, JS in the composition of HASHMAP structure takes a certain amount of time, but not much; unfortunately this high-level structure on both sides of the js/flex is a burden, the incoming time need to do the necessary checks and conversions, so relatively slow;
  • In addition, considering the complexity of the Js/flex mutual call structure, if the high-level structure is passed, the two systems are prone to inconsistency in the parsing and can cause additional overhead.
    (Note: Actually tried the variant of method A, that is, JS here to start the loop 20,000 times, each time a device information to flex and display object on the GIS map, although each time the amount of data is very small, but call JS/FLEX2 million times, inefficient, so also abandoned, This is not discussed here.)

  • Method B (Good):
  • In JS, the information data of n million devices are obtained through the business layer, such as array dev[n0000];
  • In JS, the information data is packaged as long string strings (with contract structure/JSON-like);
  • In JS, the string is passed from JS to Flex:js--Flex;
  • In Flex, get the incoming string, parse it back to HashMap, and loop it over the GIS map;
  • In Flex, a service with key check value is provided through the HASHMAP structure: val = devicehashmap.get (key);
  • Performance Evaluation & Analysis:
  • In step 3 consumed about 1 seconds (in fact, about 500ms), the data volume is 20,000 device;
  • Preliminary estimates, the classic data structure string, in most systems can be very good interoperability, and get the simplest support and parsing (such as mostly bytes byte array, the last is a tag, or have a small elegant head structure, etc.), so the passing of string greatly reduces the time overhead. On the JS side, stitching string is faster than assembling the HashMap, and on the flex side, parsing string itself assembles its own haspmap (not the HASHMAP structure that understands JS) also quickly.
  • Overall on the steps 1 to 5 consumed in about 1 seconds, to meet the requirements;
    (Note: In fact, when trying several other GIS engines, we use the Js/api interface, there is no problem, this is actually the technology selection is very important. )

Summarize:

Many times, the development of a system, the implementation of A and B calls and operation of each other, but only to achieve. In more cases, the actual application will inevitably have data pressure and performance requirements, and once the performance, "usable" is not enough, but also to consider "feasible";
The ultimate goal is to find the practical one in many ways. This actually requires an in-depth study of the understanding and comparison of various methods. But time is limited, experience is limited, manpower is limited, so we can only do a limited amount of trial, and constantly optimize, this may also be iterative development or agile development compared to advocate it.
Performance optimization I've talked roughly in my previous space, as long as there is a performance bottleneck, as long as the physical (theoretical) computable performance boundaries are not met, you can find the right method to optimize.
In addition, the technology selection is also very important, for the current contact of several GIS engines, support JSAPI no similar problems, and not JS API interface needs to do additional research, try and optimize. This selection of technology is also an example worth thinking about.

END

2016-04-25-Information System practice notes 6-JS Calling Flex Performance Problem example

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.