课程咨询 :0571-56020834 QQ:3163902815

杭州软件测试培训

杭州软件测试培训 > 达内新闻 > 达内:python的web应用开发与测试
  • 达内:python的web应用开发与测试

    发布:杭州软件测试培训      来源:51测试网      时间:2015-12-31


  •     杭州达内软件测试培训专家分享python的web应用开发与测试的方法,代码如下:

    同步和异步代码 


    class SyncSleepHandler(RequestHandler):
    """
    同步的方式,一个延时1s的接口
    """
    def get(self):
    time.sleep(1)
    self.write("when i sleep 5s")
    class SleepHandler(RequestHandler):
    """
    异步的延时1秒的接口
    """
    @tornado.gen.coroutine
    def get(self):
    yield tornado.gen.Task(
    tornado.ioloop.IOLoop.instance().add_timeout,
    time.time() + 1
    )
    self.write("when i sleep 5s")


    同步测试结果


    ?  /  ab -n 200 -c 40 http://localhost:8009/demo/syncsleep-handler/
    This is ApacheBench, Version 2.3 <$Revision: 1528965 $>
    Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
    Licensed to The Apache Software Foundation, http://www.apache.org/
    Benchmarking localhost (be patient)
    Completed 100 requests
    Completed 200 requests
    Finished 200 requests
    Server Software:        TornadoServer/4.2.1
    Server Hostname:        localhost
    Server Port:            8009
    Document Path:          /demo/syncsleep-handler/
    Document Length:        15 bytes
    Concurrency Level:      40
    Time taken for tests:   200.746 seconds
    Complete requests:      200
    Failed requests:        0
    Total transferred:      42000 bytes
    HTML transferred:       3000 bytes
    Requests per second:    1.00 [#/sec] (mean)
    Time per request:       40149.159 [ms] (mean)
    Time per request:       1003.729 [ms] (mean, across all concurrent requests)
    Transfer rate:          0.20 [Kbytes/sec] received
    Connection Times (ms)
    min  mean[+/-sd] median   max
    Connect:        0    0   0.2      0       1
    Processing:  1005 36235 18692.2  38133  200745
    Waiting:     1005 36234 18692.2  38133  200745
    Total:       1006 36235 18692.2  38133  200746
    Percentage of the requests served within a certain time (ms)
    50%  38133
    66%  38137
    75%  38142
    80%  38161
    90%  38171
    95%  38176
    98%  38179
    99%  199742
    100%  200746 (longest request)


    异步测试结果


    ?  /  ab -n 200 -c 40 http://localhost:8009/demo/sleep-handler/
    This is ApacheBench, Version 2.3 <$Revision: 1528965 $>
    Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
    Licensed to The Apache Software Foundation, http://www.apache.org/
    Benchmarking localhost (be patient)
    Completed 100 requests
    Completed 200 requests
    Finished 200 requests
    Server Software:        TornadoServer/4.2.1
    Server Hostname:        localhost
    Server Port:            8009
    Document Path:          /demo/sleep-handler/
    Document Length:        15 bytes
    Concurrency Level:      40
    Time taken for tests:   5.083 seconds
    Complete requests:      200
    Failed requests:        0
    Total transferred:      42000 bytes
    HTML transferred:       3000 bytes
    Requests per second:    39.35 [#/sec] (mean)
    Time per request:       1016.611 [ms] (mean)
    Time per request:       25.415 [ms] (mean, across all concurrent requests)
    Transfer rate:          8.07 [Kbytes/sec] received
    Connection Times (ms)
    min  mean[+/-sd] median   max
    Connect:        0    0   0.4      0       2
    Processing:  1001 1010  12.0   1005    1053
    Waiting:     1001 1010  12.0   1005    1053
    Total:       1001 1010  12.3   1005    1055
    Percentage of the requests served within a certain time (ms)
    50%   1005
    66%   1009
    75%   1011
    80%   1015
    90%   1032
    95%   1044
    98%   1045
    99%   1054
    100%   1055 (longest request)








    原文链接:http://www.51testing.com/html/65/n-3697365.html

    推荐文章

上一篇:达内:性能测试之部署测试环境

下一篇:达内:Swift中的单元测试

最新开班日期  |  更多

国际软件测试工程师精品班

国际软件测试工程师精品班

开班日期:每月底

国际软件测试工程师提升班

国际软件测试工程师提升班

开班日期:每月底

国际软件测试工程师就业班

国际软件测试工程师就业班

开班日期:每月底

国际软件测试工程师就业班

国际软件测试工程师就业班

开班日期:每月底

  • 地址:杭州市西湖区文三路199号创业大厦4楼
  • 课程培训电话:0571-56020834 QQ:3163902815     全国服务监督电话:400-827-0010
  • 服务邮箱 ts@tedu.cn
  • 2001-2016 达内国际公司(TARENA INTERNATIONAL,INC.) 版权所有 京ICP证08000853号-56