0

I wrote this Mandelbrot plotter in HTML5 and it has a reproducible performance bug that I can't figure out.

In the Plot Controls section, there's the ability to save coordinates into a pick list to be able to return directly there later. If I select a saved set of coordinates, however, and then click "Load", the performance suddenly becomes so slow that at first I thought it was hanging the script (it will eventually start to develop the image as it's supposed to).

I cannot figure out why. The onclick handler for the Load button (line #258) simply calls gotoCoord() (line #457). The gotoCoord function simply sets several of the plot parameters (xOff, yOff, fMag) and then calls initDisplay(). I do those exact things in several other places with no ill effects (mousedown on line 124, zoomOut on line 386, zoomIn on line 394). I can't figure out what's different about gotoCoord.

I've done repeated comparison testing, navigating to a plot and timing how long it takes to develop the image. Then I save the coords and load them. The performance hit is drastic.

Does anyone else see what I'm missing?

4

1 回答 1

1

这个问题已经回答了,所以只需将其从未回答的列表中删除即可。

@DCoder 的评论解决了它。绘图参数存储在 localStorage 中,然后从那里加载选择列表。当然,从 localStorage 加载时,值都是字符串。这就是 gotoCoord 与其他函数的不同之处。由于绘图中使用了参数(第 589 和 590 行),因此对于每帧中每个像素的每次计算,都必须将文本转换为数字!

三个小加号修复了它。

于 2013-06-15T21:58:05.967 回答