Use joins and array in ASP to speed up character connections.

Source: Internet
Author: User
Tags date array final join joins
Speed such as
<%
Dim A (10000), i,t
T=timer
For I=0 to 10000
A (i) =cstr (i)
Next
Response.Write Join (A,VBCRLF)
Response.Write Timer-t
Erase A
%>

Speed can be spelled with PHP (though not as fast as he does)
Another way to use it is

S=join (Array ("1", "2", "3",....., "9999"))
The speed is still much faster than "1" & "2" & "3" & .....& "9999"

Detailed test data can be seen:

////////////////////////////////////////////////////
{The client template for testing}
////////////////////////////////////////////////////
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" >
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<meta name= "generator" content= "EditPlus" >
<meta name= "Author" content= "" >
<meta name= "Keywords" content= "" >
<meta name= "Description" content= "" >
</HEAD>

<BODY>
<script language= "VBScript" >
Dim t
T=timer
</script>
<!--here put the server test script-->
<script language= "VBScript" >
Document.Write "|" & (TIMER-T) ' Output the time taken by the client to fully accept all data
</script>
</BODY>
</HTML>
////////////////////////////////////////////////////
{The code for each script you tested}
////////////////////////////////////////////////////
//--------------------------------------------------
Test-js.asp
Use an array to collect all the character channeling and finally join the Join function
//--------------------------------------------------
<script language= "JavaScript" runat= "Server" >
var i,t,s;
var a=new Array (10000);
t= (New Date ()). GetTime ();
for (i=0;i<10000;i++) {
S+=string (i) + "";
A[i]=string (i);
}
S=a.join ("");
Response.Write (s);
Response.Write ("<br>" +string (New Date ()). GetTime ()-T);
A=null;
S=null;
</Script>
//--------------------------------------------------
////////////////////////////////////////////////////
//--------------------------------------------------
Test-js2.asp
//--------------------------------------------------
<script language= "JavaScript" runat= "Server" >
var i,t,s= "";
t= (New Date ()). GetTime ();
for (i=0;i<10000;i++) {
S+=string (i) + "";
}
Response.Write (s);
Response.Write (New Date ()). GetTime ()-T);
A=null;
S=null;
</Script>
//--------------------------------------------------
////////////////////////////////////////////////////
//--------------------------------------------------
Test-js3.asp
Each data is obtained, and is immediately exported to the data stream.
//--------------------------------------------------
<script language= "JavaScript" runat= "Server" >
var i,t;
t= (New Date ()). GetTime ();
for (i=0;i<10000;i++) {
Response.Write (i+ "");

}
Response.Write ("<br>");
Response.Write (New Date ()). GetTime ()-T);
</Script>
//--------------------------------------------------
////////////////////////////////////////////////////
//--------------------------------------------------
Test-js3.asp
This program creates a zero file and enters all the content into the file, and the final unified output
The component used to establish the zero file is the FSO
//--------------------------------------------------
<script language= "JavaScript" runat= "Server" >
var i,t;
t= (New Date ()). GetTime ();
var fso=server.createobject ("Scripting.FileSystemObject");/Create an FSO object
var f=fso. CreateTextFile (Server.MapPath ("Temp.txt"), true);//Create a zero file through the FSO object
for (i=0;i<10000;i++) {
F.writeline (i);
}
F.close ();
F=fso. OpenTextFile (Server.MapPath ("Temp.txt"), 1);
Response.Write (F.readall ())//Read the contents of a zero file
F.close ();
F=null;
Fso=null;
Response.Write ("<br>");
Response.Write (New Date ()). GetTime ()-T);
</Script>
//--------------------------------------------------
////////////////////////////////////////////////////
//--------------------------------------------------
Test-js5.asp
This program creates a zero file and enters all the content into the file, and the final unified output
The component used to establish the zero file is ADODB.stream
//--------------------------------------------------
<script language= "JavaScript" runat= "Server" >
var i,t;
t= (New Date ()). GetTime ();
var ado=server.createobject ("ADODB



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.