나는 ASP 온라인으로 가짜 스레드가 열린 것을 발견했고 이전에 내가 만든 프로그램과 일치한다는 것을 알았지 만 전에 VB를 사용하여 그것을 골라서 예약했습니다.
1. 원리 실험은 물론 동일합니다. 웹 서버를 사용하여 여러 스레드를 지원하고 동일한 페이지의 서버에 여러 HTTP 요청을 보내 작업을 완료합니다. 먼저 실험하고, 글쓰기 시간의 차이를 비교하기 위해 페이지에 동시에 2 개의 txt 파일을 작성해 봅시다. 코드는 다음과 같습니다. <%
startTime = 타이머 ()
''----------------------------------------------------------------------------------------------------------------------------
함수 runthread ()
희미한 HTTP
set 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")
set fso = createobject ( "scripting.filesystemobject")
set myfile = fso.creatextfile (filepath, true)
myfile.write (콘텐츠)
myfile.close
엔드 기능
기능 b ()
희미한 컨텐츠, FilePath, MyFile
content = now () & chr (30) & timer ()
filepath = server.mappath ( "b.txt")
set fso = createobject ( "scripting.filesystemobject")
set myfile = fso.creatextfile (filepath, true)
myfile.write (콘텐츠)
myfile.close
엔드 기능
if (request.querystring ( "action") = "" ")
runthread ()
에이()
또 다른
비()
끝 If
%> 스크립트 실행 시간 : <%= fix ((timer ()-startime)*1000)%> 실행 후 결과는 파일 A와 파일 B의 시간이 기본적으로 동일하다는 것을 보여줍니다. 2. 실제 응용 프로그램 비교. 예를 들어, 나는 동시에 2 페이지의 HTML 코드를 가져오고, 하나는 Sohu 홈페이지와 하나는 Sina 홈페이지입니다. 두 가지 방식으로 : 하나는 정기적 인 코드 실행, 단일 스레드 실행, 다른 하나는 멀티 스레드 실행입니다. 페이지 완료 시간 비교, 코드는 다음과 같습니다. testspeed1.asp : <%
startTime = 타이머 ()
기능 gethttppage (URL)
다음에 오류가 재개됩니다
희미한 HTTP
set http = server.createobject ( "msxml2.xmlhttp")
http.open "post", url, false
http.send ()
http.readystate <> 4 인 경우 함수를 종료하십시오
gethttppage = bytes2bstr (http.responsebody)
내용 = gethttppage
response.write "<xmp>"
응답. 쓰기 (내용)
응답. "</xmp>"
HTTP = 아무것도 설정하지 않습니다
err.number <> 0 인 경우 err.clear
엔드 기능
함수 BYTES2BSTR (VIN)
Dim Strreturn
Dim I, ThischarCode, NextCharCode
strreturn = ""
i = 1 대 Lenb (Vin)의 경우
thischarCode = ASCB (MIDB (Vin, I, 1))
이 charcode <& h80 인 경우
strreturn = strreturn & chr (thischarcode)
또 다른
NextCharCode = ASCB (MIDB (VIN, I+1,1))
strreturn = strreturn & chr (clng (thischarcode) * & h100 + cint (nextcharcode))
i = i + 1
끝 If
다음
바이트 2bstr = strreturn
엔드 기능
gethttppage ( "http://www.sohu.com/")
gethttppage ( "http://www.sina.com.cn/")
%> 스크립트 실행 시간 : <%= fix ((timer ()-startime)*1000)%> ms testspeed2.asp : <%
startTime = 타이머 ()
기능 gethttppage (URL)
다음에 오류가 재개됩니다
희미한 HTTP
set http = server.createobject ( "msxml2.xmlhttp")
http.open "post", url, false
http.send ()
http.readystate <> 4 인 경우 함수를 종료하십시오