ASPオンラインで開かれた偽のスレッドが見つかり、以前に作成したプログラムと一致していることがわかりましたが、以前にVBを使用して、それを拾い上げて予約しました。
1.原則実験はもちろん同じです。 Webサーバーを使用して複数のスレッドをサポートし、同じページのサーバーに複数のHTTPリクエストを送信して作業を完了します。最初に実験して、ページに2つのTXTファイルを同時に記述して、ライティング時間の違いを比較します。コードは次のとおりです:<%
starttime = timer()
'' ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -
関数runthread()
dim http
http = server.createobject( "msxml2.xmlhttp")を設定します
http.open "get"、 "http://127.0.0.1/thread.asp?action=b"、false
http.send()
エンド関数
関数a()
薄暗いコンテンツ、filepath、myfile
content = now()&chr(30)&timer()
filepath = server.mappath( "a.txt")
fso = createObject( "Scripting.filesystemObject")
myfile = fso.createTextfile(filepath、true)を設定します
myfile.write(content)
myfile.close
エンド関数
関数B()
薄暗いコンテンツ、filepath、myfile
content = now()&chr(30)&timer()
filepath = server.mappath( "b.txt")
fso = createObject( "Scripting.filesystemObject")
myfile = fso.createTextfile(filepath、true)を設定します
myfile.write(content)
myfile.close
エンド関数
if(request.querystring( "action")= "")then
runthread()
a()
それ以外
b()
ifを終了します
%>スクリプト実行時間:<%= fix((timer() - startime)*1000)%> ms実行後の結果は、ファイルaとファイルBの時間が基本的に同じであることを示しています。 2。実用的なアプリケーションの比較。たとえば、2ページのHTMLコードを同時に取得します。1つはSohuホームページ、1つはSinaホームページです。 2つの方法:1つはコード実行の通常の順序、シングルスレッド実行、もう1つはここでマルチスレッド実行です。ページの完了時間を比較すると、コードは次のとおりです。TESTSPEED1.asp:<%
starttime = timer()
関数gethttppage(url)
エラーの再開時に次に再開します
dim http
http = server.createobject( "msxml2.xmlhttp")を設定します
http.open "post"、url、false
http.send()
HTTP.ReadyState <> 4の場合、機能を終了します
gethttppage = bytes2bstr(http.responsebody)
内容= gethttppage
Response.Write "<xmp>"
Response.Write(内容)
respons.write "</xmp>"
http = Nothingを設定します
err.number <> 0の場合、err.clear
エンド関数
関数bytes2bstr(vin)
Dim Strreturn
DIM I、ThisCharcode、Next Charcode
strreturn = ""
i = 1にレンブ(vin)へ
thischarcode = ascb(midb(vin、i、1))
thischarcode <&h80の場合
strreturn = strreturn&chr(thischarcode)
それ以外
NextCharcode = ascb(midb(vin、i+1,1))
strreturn = strreturn&chr(clng(thischarcode) *&h100 + cint(nextcharcode)))
i = i + 1
ifを終了します
次
bytes2bstr = strreturn
エンド関数
gethttppage( "http://www.sohu.com/")
gethttppage( "http://www.sina.com.cn/")
%>スクリプト実行時間:<%= fix((timer() - startime)*1000)%> ms testspeed2.asp:<%
starttime = timer()
関数gethttppage(url)
エラーの再開時に次に再開します
dim http
http = server.createobject( "msxml2.xmlhttp")を設定します
http.open "post"、url、false
http.send()
HTTP.ReadyState <> 4の場合、機能を終了します