Giter Site home page Giter Site logo

tcp_server's People

Contributors

henrybear327 avatar superdanby avatar

Watchers

 avatar  avatar  avatar

tcp_server's Issues

Weird performance effect with str.decode()

server.py now yields weird benchmark results. The server clean up time takes as long as the process time.

~> python3 client.py 127.0.0.1 8888 1000000
eof sent
finish writing
wait for server to clean up
1000000 requests done.
Process time: 33.637513160705566s, requests per second: 29728.71374951026, server clean up time: 32.18577456474304s, total time elapsed: 65.82328772544861s

The part in async def respond() causing this problem:

    if Error:
        status_code = status_code.decode('utf-8').split(' ', 2)[1]
    else:
        status_code, Error = status_code.decode('utf-8').split(' ', 1)[1].split(' ', 1)
    # status_code, Error = status_code.decode('utf-8').split(' ', 1)[1].split(' ', 1)
    # status_code = status_code.decode('utf-8')
    # status_code = "212".split('1')[0]

Changing those to the following yields similar results:

    # if Error:
    #     status_code = status_code.decode('utf-8').split(' ', 2)[1]
    # else:
    #     status_code, Error = status_code.decode('utf-8').split(' ', 1)[1].split(' ', 1)
    # status_code, Error = status_code.decode('utf-8').split(' ', 1)[1].split(' ', 1)
    status_code = status_code.decode('utf-8')
    # status_code = "212".split('1')[0]

But if the part doesn't use str.decode():

    # if Error:
    #     status_code = status_code.decode('utf-8').split(' ', 2)[1]
    # else:
    #     status_code, Error = status_code.decode('utf-8').split(' ', 1)[1].split(' ', 1)
    # status_code, Error = status_code.decode('utf-8').split(' ', 1)[1].split(' ', 1)
    # status_code = status_code.decode('utf-8')
    status_code = "212".split('1')[0]

The results are:

~> python3 client.py 127.0.0.1 8888 1000000
eof sent
finish writing
wait for server to clean up
1000000 requests done.
Process time: 66.861887216568s, requests per second: 14956.203625556738, server clean up time: 0.0014019012451171875s, total time elapsed: 66.86328911781311s

Though total time elapsed don't differ a lot, we can cut out the connection from the client once all requests are received(the time it takes would be 'process time'). Hence, it would be a huge impact on the performance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.