Skip to content

hq-cml/unicorn-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

97 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

 __    __   __   __   __    ______   ______   .______    __   __          ______   ______
|  |  |  | |  \ |  | |  |  /      | /  __  \  |   _  \  |  \ |  |        /      | /  __  \
|  |  |  | |   \|  | |  | |  ,----'|  |  |  | |  |_)  | |   \|  |  ___  |  ,----'|  |  |  |
|  |  |  | |  . `  | |  | |  |     |  |  |  | |      /  |  . `  | .___. |  |  --.|  |  |  |
|  `--'  | |  |\   | |  | |  `----.|  `--'  | |  |\  \-.|  |\   |       |  `--| ||  `--'  |
 \______/  |__| \__| |__|  \______| \______/  | _| `.__||__| \__|        \______| \______/

====================================== Description ========================================
    Unicorn-go is a TCP client framework that you can customize your logical business code
and not to care about networking processing and event process. Unicorn is responsible for
them. Unicorn-go is Unicorn's implementation based on golang. Reference Unicorn, you can
refer: https://github.com/hq-cml/unicorn.

    In plugin directory, there are some production cases based on unicorn. You can refer
them to write your business code.

    ./plugin/echo        -- a tcp pressure tester for echo back server.
    ./plugin/equation.go -- a tcp pressure tester for math equation.
    ./plugin/reversi.go  -- a tcp client for reversi. To get the reversi server, you can see:
                            https://github.com/hq-cml/reversi.

======================================== Usage ============================================
Usage: unicorn -c <concurrency>|-q <qps> [-h <ip>] [-p <port>] [-D <duration>] [-k <boolean>]

Note: !!!!- The argu 'c' and 'q' can't be set at the same time -!!!!

 -h <hostname>      server hostname (default 127.0.0.1)
 -p <port>          server port (default 9527)
 -c <concurrency>   number of parallel connections
 -q <qps>           qps-- the frequence you wanted for requests
 -t <timeout>       time out of per request (default 50 ms)
 -D <duration>      test time duration for requests (default 5s)
 -k <keepalive>     true = keep alive, false = reconnect (default false)
 -m <mode>          0-echo; 1-equation; 2-reversi
 -H                 show help information
 -v                 verbos (default false)

======================================== Note ============================================
Please make sure the argu 'c' and 'q' not to be set at the same time!!!

When the argu 'c' is set, the qps will be the test result. As many as possible.

Otherwise when the argu 'q' is set, the concurency will be calculate automaticlly. The
equation is : concurrency ≈ (timeout / (1e9 / qps))+1

======================================== Run ============================================
Echo:
Start Mossad.                      # Run The server. Refer: https://github.com/hq-cml/mossad
./unicorn -c 10 -D 3 -m 0 -k       # Begin Test: concurrency: 10, keepalive
./unicorn -c 10 -D 3 -m 0          # Begin Test: concurrency: 10, no keepalive
./unicorn -q 1000 -D 3 -m 0 -k     # Begin Test: qps: 1000, keepalive
./unicorn -q 1000 -D 3 -m 0        # Begin Test: qps: 1000, no keepalive

Equation:
go test -run=TestServer github.com/hq-cml/unicorn-go/plugin -v  # Run The server
./unicorn -c 100 -D 5 -m 1                                      # Begin Test
./unicorn -c 100 -D 5 -m 1 -k                                   # Begin Test, keepalive
./unicorn -q 10000 -D 5 -m 1                                    # Begin Test, 指定qps,自动计算并发
./unicorn -q 10000 -D 5 -m 1 -k                                 # Begin Test, 指定qps,自动计算并发,keepalive

Reversi:
Run the java reversi server              #refer:https://github.com/hq-cml/reversi
./unicorn -c 1 -D 1000 -t 100000 -m 2-k  #等待对方落子的过程要比较大的时间和超时忍受,防止对方不是AI,并且,必须是长连接模式!!

About

unicorn based on golang

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages