vearutop / plt

⏱️ Pocket load tester
MIT License
50 stars 4 forks source link

Beautify the output #9

Open karakanb opened 4 years ago

karakanb commented 4 years ago

Here's an example output of the tool:

❯ plt --live-ui --concurrency=5 curl http://localhost:8000/login
Host resolved: ::1,127.0.0.1
Requests per second: 33.97
Total requests: 1000
Request latency distribution in ms:
[   min    max]  cnt total% (1000 events)
[ 53.05  53.05]    1  0.10%
[ 53.44  53.63]    2  0.20%
[ 57.30  57.30]    1  0.10%
[ 61.55  61.55]    1  0.10%
[ 64.40  72.33]   10  1.00% .
[ 74.08  86.93]   24  2.40% ..
[ 87.01 120.37]  201 20.10% ....................
[120.48 155.74]  414 41.40% .........................................
[155.75 188.30]  267 26.70% ..........................
[188.71 304.20]   79  7.90% .......

Request latency percentiles:
99%: 240.994161ms
95%: 202.252658ms
90%: 184.659317ms
50%: 144.925221ms

Requests with latency more than 1s: 0

DNS latency distribution in ms:
[ min  max] cnt total% (12 events)
[0.53 0.53]  1  8.33% ........
[0.57 0.57]  1  8.33% ........
[0.58 0.59]  2 16.67% ................
[0.60 0.60]  1  8.33% ........
[0.62 0.62]  2 16.67% ................
[0.63 0.63]  1  8.33% ........
[0.65 0.65]  1  8.33% ........
[0.74 0.74]  1  8.33% ........
[1.06 1.06]  1  8.33% ........
[1.11 1.11]  1  8.33% ........

Connection latency distribution in ms:
[ min  max] cnt total% (12 events)
[0.21 0.21]  1  8.33% ........
[0.22 0.22]  1  8.33% ........
[0.23 0.23]  1  8.33% ........
[0.23 0.23]  2 16.67% ................
[0.25 0.25]  1  8.33% ........
[0.31 0.31]  1  8.33% ........
[0.36 0.36]  1  8.33% ........
[0.42 0.43]  2 16.67% ................
[0.48 0.48]  1  8.33% ........
[1.01 1.01]  1  8.33% ........

Responses by status code
[200] 1000

Bytes read 5870717
Bytes written 85000
[200]
<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- CSRF Token -->
    <meta name="csrf-token" content="gpUQ1qVPOT165dVG1rqkUZvfpLBIDiU0KLIjT9R4">

    <title>Laravel</title>

    <!-- Styles -->
    <link href="/css/app.css" rel="stylesheet">
</head>
<body class="bg-gray-200 h-screen antialiased leading-none">
    <div id="app">
            <div class="container mx-auto">
        <main role="main" class="px-4 md:px-8">
                <div class="flex flex-wrap items-center justify-center min-h-screen">
        <div class="w-full md:w-1/3">
            <h2 class="font-extrabold leading-9 mb-6 text-3xl text-center text-gray-700">
                Login to your account
            </h2>
            <div class="bg-white break-words flex flex-col rounded-md shadow-md">
                <form class="w-full p-6" method="POST" action="http://localhost:8000/login">
                    <input type="...

Reading the above is confusing and requires carefully checking the output. It doesn't really have a hierarchy, and shows information that is not necessarily required. Let's have a look at ab output for the same site:

❯ ab localhost:8000/login
This is ApacheBench, Version 2.3 <$Revision: 1874286 $>
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).....done

Server Software:        nginx/1.17.5
Server Hostname:        localhost
Server Port:            8000

Document Path:          /login
Document Length:        4187 bytes

Concurrency Level:      1
Time taken for tests:   0.461 seconds
Complete requests:      1
Failed requests:        0
Total transferred:      5858 bytes
HTML transferred:       4187 bytes
Requests per second:    2.17 [#/sec] (mean)
Time per request:       460.860 [ms] (mean)
Time per request:       460.860 [ms] (mean, across all concurrent requests)
Transfer rate:          12.41 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       0
Processing:   461  461   0.0    461     461
Waiting:      459  459   0.0    459     459
Total:        461  461   0.0    461     461

As you can tell, the output of ab is much easier to process, although it doesn't provide as much details as plt does.

Proposed Output

Here's a quick sketch of how the output might be changed:

❯ plt --live-ui --concurrency=5 curl http://localhost:8000/login

--------------------------------------------

Successfully completed in 17.89 seconds.

Latency Distribution
+---------+---------+-------+------------+
| Minimum | Maximum | Count | Percentage |
+---------+---------+-------+------------+
|   53.05 |   53.05 |     1 | 0.10       |
|   53.44 |   53.63 |     2 | 0.20       |
|   57.30 |   57.30 |     1 | 0.10       |
|   61.55 |   61.55 |     1 | 0.10       |
|   64.40 |   72.33 |    10 | 1.00%      |
|   74.08 |   86.93 |    24 | 2.40%      |
|   87.01 |  120.37 |   201 | 20.10%     |
|  120.48 |  155.74 |   414 | 41.40%     |
|  155.75 |  188.30 |   267 | 26.70%     |
|  188.71 |  304.20 |    79 | 7.90%      |
+---------+---------+-------+------------+

Latency Percentiles
+-----+--------------+
| Pp  |   Latency    |
+-----+--------------+
| 99% | 240.994161ms |
| 95% | 202.252658ms |
| 90% | 184.659317ms |
| 50% | 144.925221ms |
+-----+--------------+

Status Code Distribution
+-------------+-------+
| Status Code | Count |
+-------------+-------+
|         200 |  1000 |
+-------------+-------+

DNS Resolution Latency
+---------+---------+-------+------------+
| Min(ms) | Max(ms) | Count | Percentage |
+---------+---------+-------+------------+
|    0.53 |    0.53 |     1 | 8.33%      |
|    0.57 |    0.57 |     1 | 8.33%      |
|    0.58 |    0.59 |     2 | 16.67%     |
|    0.60 |    0.60 |     1 | 8.33%      |
|    0.62 |    0.62 |     2 | 16.67%     |
|    0.63 |    0.63 |     1 | 8.33%      |
|    0.65 |    0.65 |     1 | 8.33%      |
|    0.74 |    0.74 |     1 | 8.33%      |
|    1.06 |    1.06 |     1 | 8.33%      |
|    1.11 |    1.11 |     1 | 8.33%      |
+---------+---------+-------+------------+

Connection Latency
+---------+---------+-------+------------+
| Min(ms) | Max(ms) | Count | Percentage |
+---------+---------+-------+------------+
|    0.53 |    0.53 |     1 | 8.33%      |
|    0.57 |    0.57 |     1 | 8.33%      |
|    0.58 |    0.59 |     2 | 16.67%     |
|    0.60 |    0.60 |     1 | 8.33%      |
|    0.62 |    0.62 |     2 | 16.67%     |
|    0.63 |    0.63 |     1 | 8.33%      |
|    0.65 |    0.65 |     1 | 8.33%      |
|    0.74 |    0.74 |     1 | 8.33%      |
|    1.06 |    1.06 |     1 | 8.33%      |
|    1.11 |    1.11 |     1 | 8.33%      |
+---------+---------+-------+------------+

----------------------------------------------

Total Requests:        1000          
Failed Requests:       0             
Requests per second:   33.97         
p99 Latency:           240.994161ms  
p50 Latency:           240.994161ms  

Combined with font weights and colors, this might make the output much easier to process.