Home > Web Front-end > JS Tutorial > body text

javascript string string optimization problem_javascript skills

WBOY
Release: 2016-05-16 18:04:22
Original
1090 people have browsed it
Copy code The code is as follows:





test






The result is not like the general saying, using array will be faster. In ie9,8. I tested it under IE core browsers such as ff, Google, Sogou, etc. It is true that the array method is slower than the " " method in tests with a magnitude of more than 100,000.
Results of 1000000 times
First time on ie (probably, ie can’t copy it, so the picture won’t be cut off)
Copy code The code is as follows:

array time spent 890
str connection time 450

ie maybe the memory is not recycled and a warning will pop up at the second point. And the time used is 1400 and 1200. After clicking more several times, the time of = connection method returns to 400. Is it possible that the array object is not recycled? Open the task manager and refresh the IE browser again. The memory has dropped by more than 100 MB. You should study the JavaScript memory recycling mechanism of IE.
ff
Copy code The code is as follows:

Time 1: 1312102053720
Time 2 1312102053842
Time 3 1312102053882
array time 122
str connection time 40

google (cannot copy data)
array time 200
str Connection time 100
opera
time 1: 1312102258270
time 2 1312102258460
time 3 1312102258592
array time 190
str connection time 132
By the way, in After the data reaches 5000000, ff throws an exception. It should be a memory overflow. . . (ps, I don’t understand very well)
Error: uncaught exception: 8.375396749959738e-274
When tested under IE, a decisive warning appears, and then out of memory.
Of course, large data connections are impossible to appear on current web pages, and data processing should be done in the background. The teacher’s host does not dare to install so many browsers
In fact, it is the jion of array, which is too time-consuming. Without adding this sentence, opera and Google show the advantages of array:
opera results:
Copy code The code is as follows:

Time 1: 1312101715553
Time 2 1312101715622
Time 3 1312101715749
array time 69
str connection time 127
[code]
ie Result
array time spent 700
str connection time 500
ff
[code]
Time 1: 1312101925895
Time 2 1312101925945
Time 3 1312101925979
array used Time 50
str connection time 34

google
array time 17
str connection time 100
Go and check the jion mechanism before writing it.
ps: browser version
google12.0.742.122
ff5.0.1
opera11.50
ie8.0.6001.18702
pss: ie processing speed is not good
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template