javascript string string optimization problem_javascript skills
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)
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
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:
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
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

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Convert basic data types to strings using Java's String.valueOf() function In Java development, when we need to convert basic data types to strings, a common method is to use the valueOf() function of the String class. This function can accept parameters of basic data types and return the corresponding string representation. In this article, we will explore how to use the String.valueOf() function for basic data type conversions and provide some code examples to

Method of converting char array to string: It can be achieved by assignment. Use {char a[]=" abc d\0efg ";string s=a;} syntax to let the char array directly assign a value to string, and execute the code to complete the conversion.

Replace characters (strings) in a string using Java's String.replace() function In Java, strings are immutable objects, which means that once a string object is created, its value cannot be modified. However, you may encounter situations where you need to replace certain characters or strings in a string. At this time, we can use the replace() method in Java's String class to implement string replacement. The replace() method of String class has two types:

Hello everyone, today I will share with you the basic knowledge of Java: String. Needless to say the importance of the String class, it can be said to be the most used class in our back-end development, so it is necessary to talk about it.

Use Java's String.length() function to get the length of a string. In Java programming, string is a very common data type. We often need to get the length of a string, that is, the number of characters in the string. In Java, we can use the length() function of the String class to get the length of a string. Here is a simple example code: publicclassStringLengthExample{publ

In Golang programming, byte, rune and string types are very basic and common data types. They play an important role in processing data operations such as strings and file streams. When performing these data operations, we usually need to convert them to each other, which requires mastering some conversion skills. This article will introduce the byte, rune and string type conversion techniques of Golang functions, aiming to help readers better understand these data types and be able to apply them skillfully in programming practice.

1. Understanding String1. String in JDK First, let’s take a look at the source code of the String class in the JDK. It implements many interfaces. You can see that the String class is modified by final. This means that the String class cannot be inherited and there is no subclass of String. class, so that all people using JDK use the same String class. If String is allowed to be inherited, everyone can extend String. Everyone uses different versions of String, and two different people Using the same method shows different results, which makes it impossible to develop the code. Inheritance and method overriding not only bring flexibility, but also cause many subclasses to behave differently.

The String.toLowerCase() function is a very useful and common string processing function in Java, which can convert a string to lowercase. In this article, we will introduce how to use this function and give some related code examples. First, let's take a look at the basic syntax of the String.toLowerCase() function. It doesn't have any parameters, just call it. Here is the sample code: Stringstr="Hel
