SlideShare une entreprise Scribd logo
1  sur  26
Télécharger pour lire hors ligne
Internet speed
김민석
http://www.emanueleferonato.com/2006/05/31/determine-connection-speed-with-php/
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php
$kb=512;
echo "streaming $kb Kb...<!-";
flush();
$time = explode(" ",microtime());
$start = $time[0] + $time[1];
for($x=0;$x<$kb;$x++){
echo str_pad('', 1024, '.');
flush();
}
$time = explode(" ",microtime());
$finish = $time[0] + $time[1];
$deltat = $finish - $start;
echo "-> Test finished in $deltat seconds. Your speed is ". round($kb / $deltat, 3)."Kb/s";
?>
Done. Analysis and considerations:
2: Declaring how much Kb I want to transmit to accomplish the test. This value can also be passed in POST or GET. In my example it is
declared.
3: I write I am downloading data, and open a comment tag. Everithing I am sending from now on will not be displayed. It’s not necessary, but
prevents the browser to be fullfilled of chars.
4: Flush the chache
5-6: Saving actual timestamp
7-9: For $kb times I send 1024 chars (1Kb) and flush the cache
11-12: Saving actual timestamp
13: Calculating difference between start and finish timestamps
14: Closing comment tag and writing test result, calculated as Kb/time
Done… very easy isn’t it?
http://www.hackingwithphp.com/13/9/0/flushing-output
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php
$kb=512;
echo "streaming $kb Kb...<!-";
flush();
$time = explode(" ",microtime());
$start = $time[0] + $time[1];
for($x=0;$x<$kb;$x++){
echo str_pad('', 1024, '.');
flush();
}
$time = explode(" ",microtime());
$finish = $time[0] + $time[1];
$deltat = $finish - $start;
echo "-> Test finished in $deltat seconds. Your speed is ". round($kb / $deltat, 3)."Kb/s";
?>
서버의 아웃풋을 내는 성능이
무한대라고 볼 때,
그래서 순간 아웃풋을 발생시킨다고 할 때,
전송한 데이터 / 걸린 시간
위 방법으로 클라이언트의 전송속도를 알 수 있다?
내 생각에는 위 코드는
서버의 성능을 나타내는 것일 뿐이지,
‘클라이언트’ 또는 ‘클라이언트-서버’ 간의 인터넷 속도를
나타내지 못할 거 같다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php
$kb=512;
echo "streaming $kb Kb...<!-";
flush();
$time = explode(" ",microtime());
$start = $time[0] + $time[1];
for($x=0;$x<$kb;$x++){
echo str_pad('', 1024, '.');
flush();
}
$time = explode(" ",microtime());
$finish = $time[0] + $time[1];
$deltat = $finish - $start;
echo "-> Test finished in $deltat seconds. Your speed is ". round($kb / $deltat, 3)."Kb/s";
?>
Php의 Backend에,
flush를 통한 출력이 어떻게 처리되는지를
이해해야지, 명확히 알 수 있을 거 같다.
Apache http web server의 경우,
다양한 서버사이드 언어를 모듈을 달아서 만질 수 있는데,
php의 경우 mod_php가 그것이다.
적어도 Apache에서 PHP를 돌리는 방법은 두가지가 있다.
CGI와 mod_php
https://kldp.org/node/73386
https://kldp.org/node/73386
아직 더 봐야겠다.
CGI에 대한 개념을 잡는데 아주 좋은 쓰레드
https://httpd.apache.org/docs/2.2/ko/howto/cgi.html
https://www.ibm.com/support/knowledgecenter/en/SSSHTQ_8.1.0/com.ibm.netcool_OMNIbus.doc_8.1.0/webtop/wip/reference/web_cust_envvariablesincgiscripts.html
http://www.cgi101.com/book/ch3/text.html
http://www.perl.or.kr/tipsinaction/control_flow/local_env
GET 요청은 QUERY_STRING 환경변수로 데이터를 넘기는 것이군.
CGI 프로그램에 클라이언트가 보낸 데이터를 보낸다.
데이터는 웹 양식 form 이고, 이렇게 보내는 걸 POST라 한다.
CGI 프로그램의 STDIN으로 전달한다. 전달하는 형식은 위와 같다.
그 형식이 종종 URL 뒤에 붙기도 하는데, 그런 경우는
이런 문자열을 유용한 정보로 처리해야 하겠네. 그런 라이브러리와 모듈이 있구나.
https://en.wikipedia.org/wiki/CGI.pm
그렇겠네.
HTML은 자꾸 변하고,
(브라우저 마다 결국 다르고)
producing HTML 하는 것은 unmaintained 되기 쉽겠네.
v5.22 of perl에서 없어졌는데, CGI가 현재 잘 안쓰이는 것과 관련 있겠네.
CGI 프로그램은 대체로 이런 느낌이겠군.
빨간 박스 아래
부분이 실제 내용일 것.
환경변수 가져오고. 쿠키 셋. 헤드타입. stdout...
https://boutell.com/cgic/#howto
https://www.binarytides.com/php-output-content-browser-realtime-buffering/
그래서.. 좀 더 코드를 보면
또한 출력된 데이터가 타고 가는 라인이
일반적으로 어느 속도를 갖느냐에 따라서,
$kb 값을 더 크게 수정하는 것이 옳을 수 있다는 의견.
내 생각에는 $kb가 아주 커야지.. 의미가 있지 않나?
돌아와서......
내 생각과 비슷한듯.
RTT를 구하기 위해서는
Javascript 단에서의 방법이 나을 듯함.
https://stackoverflow.com/questions/5529718/how-to-detect-internet-speed-in-
javascript?
utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
//JUST AN EXAMPLE, PLEASE USE YOUR OWN PICTURE!
var imageAddr = "http://www.kenrockwell.com/contax/images/g2/examples/31120037-5mb.jpg";
var downloadSize = 4995374; //bytes
function ShowProgressMessage(msg) {
if (console) {
if (typeof msg == "string") {
console.log(msg);
} else {
for (var i = 0; i < msg.length; i++) {
console.log(msg[i]);
}
}
}
var oProgress = document.getElementById("progress");
if (oProgress) {
var actualHTML = (typeof msg == "string") ? msg : msg.join("<br />");
oProgress.innerHTML = actualHTML;
}
}
function InitiateSpeedDetection() {
ShowProgressMessage("Loading the image, please wait...");
window.setTimeout(MeasureConnectionSpeed, 1);
};
if (window.addEventListener) {
window.addEventListener('load', InitiateSpeedDetection, false);
} else if (window.attachEvent) {
window.attachEvent('onload', InitiateSpeedDetection);
}
function MeasureConnectionSpeed() {
var startTime, endTime;
var download = new Image();
download.onload = function () {
endTime = (new Date()).getTime();
showResults();
}
download.onerror = function (err, msg) {
ShowProgressMessage("Invalid image, or error downloading")
}
startTime = (new Date()).getTime();
var cacheBuster = "?nnn=" + startTime;
download.src = imageAddr + cacheBuster;
function showResults() {
var duration = (endTime - startTime) / 1000;
var bitsLoaded = downloadSize * 8;
var speedBps = (bitsLoaded / duration).toFixed(2);
var speedKbps = (speedBps / 1024).toFixed(2);
var speedMbps = (speedKbps / 1024).toFixed(2);
ShowProgressMessage([
"Your connection speed is:",
speedBps + " bps",
speedKbps + " kbps",
speedMbps + " Mbps"
]);
}
그러나 다른 인터넷 속도 테스트와 많은 차이가 있음..
이유가 무엇일까?
https://codereview.stackexchange.com/questions/140573/python-internet-speed-
testing?
utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
https://www.accelebrate.com/blog/pandas-bandwidth-python-tutorial-plotting-results-
internet-speed-tests/

Contenu connexe

Similaire à Internet speed 인터넷 속도를 측정해보자

처음배우는 자바스크립트, 제이쿼리 #4
처음배우는 자바스크립트, 제이쿼리 #4처음배우는 자바스크립트, 제이쿼리 #4
처음배우는 자바스크립트, 제이쿼리 #4성일 한
 
Front-end Development Process - 어디까지 개선할 수 있나
Front-end Development Process - 어디까지 개선할 수 있나Front-end Development Process - 어디까지 개선할 수 있나
Front-end Development Process - 어디까지 개선할 수 있나JeongHun Byeon
 
MongoDB 도입을 위한 제언
MongoDB 도입을 위한 제언MongoDB 도입을 위한 제언
MongoDB 도입을 위한 제언DongHan Kim
 
MongoDB 도입을 위한 제언 @krmug
MongoDB 도입을 위한 제언 @krmug MongoDB 도입을 위한 제언 @krmug
MongoDB 도입을 위한 제언 @krmug Ha-Yang(White) Moon
 
[제3회 스포카콘] React + TypeScript + GraphQL 으로 시작하는 Web Front-End
[제3회 스포카콘] React + TypeScript + GraphQL 으로 시작하는 Web Front-End[제3회 스포카콘] React + TypeScript + GraphQL 으로 시작하는 Web Front-End
[제3회 스포카콘] React + TypeScript + GraphQL 으로 시작하는 Web Front-End우현 김
 
Clova extension에서 OAuth 계정 연동 구현
Clova extension에서 OAuth 계정 연동 구현Clova extension에서 OAuth 계정 연동 구현
Clova extension에서 OAuth 계정 연동 구현Gosu Ok
 
Resource Handling in Spring MVC
Resource Handling in Spring MVCResource Handling in Spring MVC
Resource Handling in Spring MVCArawn Park
 
하이퍼레저 패브릭 데이터 구조
하이퍼레저 패브릭 데이터 구조하이퍼레저 패브릭 데이터 구조
하이퍼레저 패브릭 데이터 구조Logpresso
 
HeadFisrt Servlet&JSP Chapter 3
HeadFisrt Servlet&JSP Chapter 3HeadFisrt Servlet&JSP Chapter 3
HeadFisrt Servlet&JSP Chapter 3J B
 
성공적인 게임 런칭을 위한 비밀의 레시피 #3
성공적인 게임 런칭을 위한 비밀의 레시피 #3성공적인 게임 런칭을 위한 비밀의 레시피 #3
성공적인 게임 런칭을 위한 비밀의 레시피 #3Amazon Web Services Korea
 
Lan3 강향리 2013 겨울방학 기말아웃풋
Lan3 강향리 2013 겨울방학 기말아웃풋Lan3 강향리 2013 겨울방학 기말아웃풋
Lan3 강향리 2013 겨울방학 기말아웃풋Hyangri Kang
 
PHP 함수와 제어구조
PHP 함수와 제어구조PHP 함수와 제어구조
PHP 함수와 제어구조Yoonwhan Lee
 
채팅 소스부터 Https 주소까지
채팅 소스부터  Https 주소까지채팅 소스부터  Https 주소까지
채팅 소스부터 Https 주소까지Kenu, GwangNam Heo
 

Similaire à Internet speed 인터넷 속도를 측정해보자 (20)

처음배우는 자바스크립트, 제이쿼리 #4
처음배우는 자바스크립트, 제이쿼리 #4처음배우는 자바스크립트, 제이쿼리 #4
처음배우는 자바스크립트, 제이쿼리 #4
 
ch04
ch04ch04
ch04
 
Front-end Development Process - 어디까지 개선할 수 있나
Front-end Development Process - 어디까지 개선할 수 있나Front-end Development Process - 어디까지 개선할 수 있나
Front-end Development Process - 어디까지 개선할 수 있나
 
MongoDB 도입을 위한 제언
MongoDB 도입을 위한 제언MongoDB 도입을 위한 제언
MongoDB 도입을 위한 제언
 
MongoDB 도입을 위한 제언 @krmug
MongoDB 도입을 위한 제언 @krmug MongoDB 도입을 위한 제언 @krmug
MongoDB 도입을 위한 제언 @krmug
 
Html5 performance
Html5 performanceHtml5 performance
Html5 performance
 
[제3회 스포카콘] React + TypeScript + GraphQL 으로 시작하는 Web Front-End
[제3회 스포카콘] React + TypeScript + GraphQL 으로 시작하는 Web Front-End[제3회 스포카콘] React + TypeScript + GraphQL 으로 시작하는 Web Front-End
[제3회 스포카콘] React + TypeScript + GraphQL 으로 시작하는 Web Front-End
 
Clova extension에서 OAuth 계정 연동 구현
Clova extension에서 OAuth 계정 연동 구현Clova extension에서 OAuth 계정 연동 구현
Clova extension에서 OAuth 계정 연동 구현
 
Resource Handling in Spring MVC
Resource Handling in Spring MVCResource Handling in Spring MVC
Resource Handling in Spring MVC
 
하이퍼레저 패브릭 데이터 구조
하이퍼레저 패브릭 데이터 구조하이퍼레저 패브릭 데이터 구조
하이퍼레저 패브릭 데이터 구조
 
테스트
테스트테스트
테스트
 
Mongo db 최범균
Mongo db 최범균Mongo db 최범균
Mongo db 최범균
 
Cdr with php
Cdr with phpCdr with php
Cdr with php
 
Html5
Html5 Html5
Html5
 
HeadFisrt Servlet&JSP Chapter 3
HeadFisrt Servlet&JSP Chapter 3HeadFisrt Servlet&JSP Chapter 3
HeadFisrt Servlet&JSP Chapter 3
 
성공적인 게임 런칭을 위한 비밀의 레시피 #3
성공적인 게임 런칭을 위한 비밀의 레시피 #3성공적인 게임 런칭을 위한 비밀의 레시피 #3
성공적인 게임 런칭을 위한 비밀의 레시피 #3
 
What's new in IE11
What's new in IE11What's new in IE11
What's new in IE11
 
Lan3 강향리 2013 겨울방학 기말아웃풋
Lan3 강향리 2013 겨울방학 기말아웃풋Lan3 강향리 2013 겨울방학 기말아웃풋
Lan3 강향리 2013 겨울방학 기말아웃풋
 
PHP 함수와 제어구조
PHP 함수와 제어구조PHP 함수와 제어구조
PHP 함수와 제어구조
 
채팅 소스부터 Https 주소까지
채팅 소스부터  Https 주소까지채팅 소스부터  Https 주소까지
채팅 소스부터 Https 주소까지
 

Plus de 민석 김

off-policy methods with approximation
off-policy methods with approximationoff-policy methods with approximation
off-policy methods with approximation민석 김
 
Multi armed bandit
Multi armed banditMulti armed bandit
Multi armed bandit민석 김
 
Kanerva machine
Kanerva machineKanerva machine
Kanerva machine민석 김
 
Shouting at gwanghwamun
Shouting at gwanghwamunShouting at gwanghwamun
Shouting at gwanghwamun민석 김
 
ML 60'~80' new paradigm 1
ML 60'~80' new paradigm 1ML 60'~80' new paradigm 1
ML 60'~80' new paradigm 1민석 김
 
벽 생성기 Wall generator
벽 생성기 Wall generator 벽 생성기 Wall generator
벽 생성기 Wall generator 민석 김
 
복소수와 오일러 공식
복소수와 오일러 공식복소수와 오일러 공식
복소수와 오일러 공식민석 김
 
Bayesian nets 발표 3
Bayesian nets 발표 3Bayesian nets 발표 3
Bayesian nets 발표 3민석 김
 
Bayesian nets 발표 1
Bayesian nets 발표 1Bayesian nets 발표 1
Bayesian nets 발표 1민석 김
 
Bayesian nets 발표 2
Bayesian nets 발표 2Bayesian nets 발표 2
Bayesian nets 발표 2민석 김
 
AI 인공지능이란 단어 읽기
AI 인공지능이란 단어 읽기AI 인공지능이란 단어 읽기
AI 인공지능이란 단어 읽기민석 김
 
Hopfield network 처음부터 공부해보기
Hopfield network 처음부터 공부해보기Hopfield network 처음부터 공부해보기
Hopfield network 처음부터 공부해보기민석 김
 
VAE 처음부터 알아보기
VAE 처음부터 알아보기VAE 처음부터 알아보기
VAE 처음부터 알아보기민석 김
 

Plus de 민석 김 (15)

pt
ptpt
pt
 
off-policy methods with approximation
off-policy methods with approximationoff-policy methods with approximation
off-policy methods with approximation
 
Multi armed bandit
Multi armed banditMulti armed bandit
Multi armed bandit
 
NN and PDF
NN and PDFNN and PDF
NN and PDF
 
Kanerva machine
Kanerva machineKanerva machine
Kanerva machine
 
Shouting at gwanghwamun
Shouting at gwanghwamunShouting at gwanghwamun
Shouting at gwanghwamun
 
ML 60'~80' new paradigm 1
ML 60'~80' new paradigm 1ML 60'~80' new paradigm 1
ML 60'~80' new paradigm 1
 
벽 생성기 Wall generator
벽 생성기 Wall generator 벽 생성기 Wall generator
벽 생성기 Wall generator
 
복소수와 오일러 공식
복소수와 오일러 공식복소수와 오일러 공식
복소수와 오일러 공식
 
Bayesian nets 발표 3
Bayesian nets 발표 3Bayesian nets 발표 3
Bayesian nets 발표 3
 
Bayesian nets 발표 1
Bayesian nets 발표 1Bayesian nets 발표 1
Bayesian nets 발표 1
 
Bayesian nets 발표 2
Bayesian nets 발표 2Bayesian nets 발표 2
Bayesian nets 발표 2
 
AI 인공지능이란 단어 읽기
AI 인공지능이란 단어 읽기AI 인공지능이란 단어 읽기
AI 인공지능이란 단어 읽기
 
Hopfield network 처음부터 공부해보기
Hopfield network 처음부터 공부해보기Hopfield network 처음부터 공부해보기
Hopfield network 처음부터 공부해보기
 
VAE 처음부터 알아보기
VAE 처음부터 알아보기VAE 처음부터 알아보기
VAE 처음부터 알아보기
 

Internet speed 인터넷 속도를 측정해보자