How to improve jqPlot parseOptions/jquery.extend performance

I have an app that uses jqPlot and I want to make it perform better - ie have it render the charts faster.

Using the Firefox profiler, I'm able to drill down on the time being spent in the various parts of the code, and I've found that the call to jqplot takes ~85% of the time. Of that 85%, ~60% is spent in the jqplot.draw routine and ~20% is taken in the jqplot.parseOptions routine.

In addition to the static configuration data (legend related stuff, grid related stuff, cursor and highlighter stuff, and x, y, y1, and y2 axis info), the actual chart data is passed in the option object to jqplot. The chart data includes the series data, the series options, and the label ticks.

jqplot copies all of this stuff into it's own memory, and it does it with a function called parseOptions that uses the jquery.extend() function to do the work. The jquery.extend function appears to be a general purpose copy function that knows how to deal with all data types and objects, but like any generalized function it's not optimized for any one of them.

My first attempt was to try just pass in the static options on the call to jqplot, and then to use jqplot.replot() to pass series data, series options, and ticks to chart object (to avoid extend in parseOptions). This failed, and after I traced through the code I discovered that replot only accepts line plot data (x,y points) and does not accept OHLC data (as most these charts are composed of). I next tried passing the OHLC data in the initial call to jqplot and passing the series options and ticks in the subsequent call to replot, but although the (limited) jqplot documentation says that replot will accept options, it's not the full option set and the ones I needed weren't handled.

My next attempt was to make the series_options "lighter". The primary series data for the chart uses the OHLCRenderer, and the other series use the lineRenderer. The current code has the lineRenderer set as the default, and each series_option object has an override specifying the OHLCRenderer. Each of these OHLCRenderer override references in the series_option objects has multiple objects beneath them - function prototypes and other stuff. Since there are just a few of the non-sample/wafer types compared to the sample/wafer objects, I changed things around to make the OHLCRenderer the default and added the lineRenderer overrides to those other objects. I thought that removing so many object references would speed up the parseOption process, but it had no appreciable difference (if anything, it seemed a little slower but since the profiling is so course it's not clear).

I'm out of ideas at this point. Anyone have any ideas as to what I could do to speed up the chart rendering?

链接地址: http://www.djcxy.com/p/14220.html

上一篇: 无法从子项中扩展现有的jQuery函数

下一篇: 如何提高jqPlot parseOptions / jquery.extend性能