Encontré un hilo falso abierto con ASP Online y descubrí que coincidía con un programa que hice antes, pero usé VB antes, lo elegí y lo reservé.
1. Los experimentos de principios son, por supuesto, los mismos. Utilizamos el servidor web para admitir múltiples hilos y enviar múltiples solicitudes HTTP al servidor en la misma página para completar nuestro trabajo. Experimentemos primero, escriba 2 archivos txt al mismo tiempo en una página para comparar la diferencia en el tiempo de escritura. El código es el siguiente: <%
starttime = timer ()
'' ------------------------------------------------------------------------------------------------------------------------
función runThread ()
Dim http
Establecer http = server.createObject ("msxml2.xmlhttp")
Http.open "get", "http://127.0.0.1/thread.asp?action=b", falso
Http.send ()
función final
función a ()
Dim contenido, filepath, myfile
Content = now () & chr (30) & timer ()
Filepath = server.mappath ("a.txt")
Establecer fso = createObject ("scripting.filesystemObject")
Establecer myFile = fso.createTextFile (FilePath, verdadero)
MyFile.write (contenido)
Myfile.close
función final
función b ()
Dim contenido, filepath, myfile
Content = now () & chr (30) & timer ()
Filepath = server.mappath ("b.txt")
Establecer fso = createObject ("scripting.filesystemObject")
Establecer myFile = fso.createTextFile (FilePath, verdadero)
MyFile.write (contenido)
Myfile.close
función final
if (request.QueryString ("Action") = "") Entonces
runthread ()
a()
demás
b()
final si
%> Tiempo de ejecución de script: <%= fix ((Timer ()-Startime)*1000)%> MS El resultado después de ejecutar muestra que el tiempo en el archivo A y el archivo B es básicamente el mismo. 2. Comparación práctica de aplicaciones. Por ejemplo, tomo el código HTML de 2 páginas al mismo tiempo, una página de inicio de Sohu y otra es la página de inicio de Sina. De dos maneras: uno es el orden regular de la ejecución del código, la ejecución de un solo hilo y el otro es la ejecución de múltiples hilos aquí. Compare el tiempo de finalización de la página, el código es el siguiente: TestSpeed1.asp: <%
starttime = timer ()
función gethttppage (URL)
En el currículum de error siguiente
Dim http
Establecer http = server.createObject ("msxml2.xmlhttp")
Http.open "post", url, falso
Http.send ()
Si http.readyState <> 4, entonces salga de la función
gethttppage = bytes2bstr (http.ResponseBody)
contenido = gethttppage
Response.write "<xmp>"
Respuesta.WRITE (contenido)
Response.write "</ xmp>"
Establecer http = nada
Si err.number <> 0 entonces Err.Clear
función final
Función bytes2bstr (vin)
Dim strreturn
Dim I, ThisCharCode, NextCharcode
strreturn = ""
Para i = 1 a Lenb (vin)
ThisCharCode = ASCB (MidB (Vin, I, 1))
Si thisCharCode <& H80 entonces
strreturn = strreturn & chr (thisCharcode)
Demás
Nextcharcode = ascb (midb (vin, i+1,1))
strreturn = strreturn & chr (clng (thisCharCode) * & H100 + cint (nextcharcode)))
i = i + 1
Final si
Próximo
bytes2bstr = strreturn
Función final
gethttppage ("http://www.sohu.com/")
gethttppage ("http://www.sina.com.cn/")
%> Tiempo de ejecución de script: <%= fix ((Timer ()-Startime)*1000)%> MS TestSpeed2.asp: <%
starttime = timer ()
función gethttppage (URL)
En el currículum de error siguiente
Dim http
Establecer http = server.createObject ("msxml2.xmlhttp")
Http.open "post", url, falso
Http.send ()
Si http.readyState <> 4, entonces salga de la función