Test the stringbuilder object efficiency of ASP. NET Ajax framework in IE and Firefox

Source: Internet
Author: User

Today, I suddenly remembered how to test the stringbuilder object efficiency under Js. So I wrote a loop to test it. The result was a bit unexpected.

1. directly use the + = Operator for 50 thousand cycles:

1 var sbtest // = new SYS. stringbuilder ();
2 For (VAR I = 0; I <50000; I ++)
3 {
4 var now = new date ();
5 sbtest + = now. getseconds () + "<br/> ";
6}
7
8 $ get ("message"). innerhtml = sbtest; //. tostring ('| <br/> ');

The test results are as follows:
32 s for IE and 2 S for Firefox during Loop
2. Use stringbuilder: var sbtest = new SYS. stringbuilder ();
For (VAR I = 0; I <50000; I ++)
{
VaR now = new date ();

Sbtest. append (now. getseconds ());
}

$ Get ("message"). innerhtml = sbtest. tostring ('| <br/> ');


The test results are as follows:
6 seconds for IE and 3 seconds for Firefox

The results differ so much. In ie, the efficiency of stringbuilder is obviously higher than that of + =, but there is no big difference in Firefox whether stringbuilder is used or not.

Related Article

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.