lang/ruby

Ruby helloWorld

C/H 2018. 6. 9. 16:44

Ruby

require 'socket'
server = TCPServer.new 1337

while session = server.accept
    request = session.gets
    puts request

    session.print "HTTP/1.1 200\r\n" # 1
    session.print "Content-Type: text/html\r\n" # 2
    session.print "\r\n" # 3
    session.print "Hello world" #4

    session.close
end
ruby server.rb

# other terminal
ab -n 10000 -c 10 -k http://127.0.0.1:1337/
.....
Concurrency Level:      10
Time taken for tests:   0.470 seconds
Complete requests:      10000
Failed requests:        0
Keep-Alive requests:    0
Total transferred:      520000 bytes
HTML transferred:       110000 bytes
Requests per second:    21257.96 [#/sec] (mean)
Time per request:       0.470 [ms] (mean)
Time per request:       0.047 [ms] (mean, across all concurrent requests)
Transfer rate:          1079.51 [Kbytes/sec] received

Connection Times (ms)
                min  mean[+/-sd] median   max
Connect:        0    0   0.1      0       1
Processing:     0    0   0.2      0       2
Waiting:        0    0   0.2      0       2
Total:          0    0   0.2      0       3

Percentage of the requests served within a certain time (ms)
    50%      0
    66%      0
    75%      0
    80%      0
    90%      1
    95%      1
    98%      1
    99%      2
    100%      3 (longest request)


반응형

'lang > ruby' 카테고리의 다른 글

Ruby JSON multiJson activeSupport  (0) 2018.06.21
Ruby JSON multiJson oj  (0) 2018.06.20
RadRails와 Eclipse로 Ruby on Rails를 쉽게! (한글)  (0) 2007.05.13
RoR(Ruby on Rails)  (0) 2006.10.26