qicosmos / cinatra

modern c++(c++20), cross-platform, header-only, easy to use http framework
MIT License
1.9k stars 375 forks source link

perf: Optimize payload length check before reading data #629

Closed xukeawsl closed 2 months ago

xukeawsl commented 2 months ago
github-actions[bot] commented 2 months ago

Code Coverage Report for detail, goto summary download Artifacts

Filename                               Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
cinatra_log_wrapper.hpp                        4                 1    75.00%           9                 1    88.89%           0                 0         -
cookie.hpp                                    15                 2    86.67%          84                 2    97.62%          28                 3    89.29%
coro_http_client.hpp                          93                 8    91.40%        1555               311    80.00%         470               145    69.15%
coro_http_connection.hpp                      36                 2    94.44%         667               184    72.41%         202                64    68.32%
coro_http_request.hpp                         31                 7    77.42%         220                43    80.45%          74                10    86.49%
coro_http_response.hpp                        31                 6    80.65%         224                68    69.64%          90                36    60.00%
coro_http_router.hpp                          15                 0   100.00%         181                32    82.32%          20                 8    60.00%
coro_http_server.hpp                          50                 5    90.00%         988               147    85.12%         182                49    73.08%
coro_radix_tree.hpp                           17                 0   100.00%         264                38    85.61%         136                30    77.94%
define.h                                       2                 0   100.00%          28                 2    92.86%          20                 1    95.00%
http_parser.hpp                               29                 6    79.31%         193                33    82.90%          52                 8    84.62%
metric_conf.hpp                                8                 4    50.00%          96                80    16.67%          32                28    12.50%
mime_types.hpp                                 1                 0   100.00%           7                 2    71.43%           2                 1    50.00%
multipart.hpp                                  4                 0   100.00%          89                15    83.15%          22                 5    77.27%
picohttpparser.h                              14                 6    57.14%         467               278    40.47%         212               103    51.42%
response_cv.hpp                                2                 0   100.00%          55                32    41.82%          46                16    65.22%
session.hpp                                   11                 0   100.00%          54                 2    96.30%           4                 1    75.00%
session_manager.hpp                           10                 1    90.00%          67                 5    92.54%          10                 1    90.00%
sha1.hpp                                      12                 0   100.00%         181                 8    95.58%          12                 2    83.33%
string_resize.hpp                              2                 0   100.00%          18                 0   100.00%           2                 0   100.00%
time_util.hpp                                 20                 7    65.00%         172                72    58.14%          28                 3    89.29%
uri.hpp                                       17                 5    70.59%         200                62    69.00%         166                52    68.67%
url_encode_decode.hpp                          4                 0   100.00%          85                20    76.47%          48                16    66.67%
utils.hpp                                     14                 0   100.00%         221                22    90.05%         116                43    62.93%
websocket.hpp                                 15                 4    73.33%         170                43    74.71%          70                18    74.29%
ylt/coro_io/client_pool.hpp                   21                 5    76.19%         278               132    52.52%          56                37    33.93%
ylt/coro_io/coro_file.hpp                     34                 0   100.00%         246                20    91.87%          44                18    59.09%
ylt/coro_io/coro_io.hpp                       56                 6    89.29%         378                44    88.36%          32                 9    71.88%
ylt/coro_io/detail/client_queue.hpp           10                 5    50.00%          47                23    51.06%          10                 4    60.00%
ylt/coro_io/io_context_pool.hpp               40                 8    80.00%         227                41    81.94%          28                 8    71.43%
ylt/coro_io/load_blancer.hpp                  16                 1    93.75%         112                 8    92.86%          34                 8    76.47%
ylt/metric/counter.hpp                         2                 1    50.00%          13                 6    53.85%           2                 0   100.00%
ylt/metric/detail/ckms_quantiles.hpp           1                 1     0.00%           5                 5     0.00%           0                 0         -
ylt/metric/gauge.hpp                           1                 0   100.00%           7                 0   100.00%           2                 0   100.00%
ylt/metric/histogram.hpp                       1                 0   100.00%           8                 0   100.00%           0                 0         -
ylt/metric/metric.hpp                         12                12     0.00%          26                26     0.00%           0                 0         -
ylt/metric/metric_manager.hpp                  8                 5    37.50%          45                33    26.67%           2                 1    50.00%
ylt/metric/summary.hpp                         1                 1     0.00%           1                 1     0.00%           0                 0         -
ylt/metric/thread_local_value.hpp              6                 0   100.00%          22                 2    90.91%           4                 1    75.00%
ylt/util/concurrentqueue.h                    77                26    66.23%        1354               835    38.33%         290               198    31.72%
ylt/util/expected.hpp                          6                 4    33.33%           6                 4    33.33%           0                 0         -
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                        749               139    81.44%        9070              2682    70.43%        2548               927    63.62%
github-actions[bot] commented 2 months ago

Code Coverage Report for detail, goto summary download Artifacts

Filename                               Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
cinatra_log_wrapper.hpp                        4                 1    75.00%           9                 1    88.89%           0                 0         -
cookie.hpp                                    15                 2    86.67%          84                 2    97.62%          28                 3    89.29%
coro_http_client.hpp                          93                 8    91.40%        1555               311    80.00%         470               145    69.15%
coro_http_connection.hpp                      36                 2    94.44%         667               180    73.01%         202                64    68.32%
coro_http_request.hpp                         31                 7    77.42%         220                43    80.45%          74                10    86.49%
coro_http_response.hpp                        31                 6    80.65%         224                68    69.64%          90                36    60.00%
coro_http_router.hpp                          15                 0   100.00%         181                32    82.32%          20                 8    60.00%
coro_http_server.hpp                          50                 5    90.00%         988               147    85.12%         182                49    73.08%
coro_radix_tree.hpp                           17                 0   100.00%         264                38    85.61%         136                30    77.94%
define.h                                       2                 0   100.00%          28                 2    92.86%          20                 1    95.00%
http_parser.hpp                               29                 6    79.31%         193                33    82.90%          52                 8    84.62%
metric_conf.hpp                                8                 4    50.00%          96                80    16.67%          32                28    12.50%
mime_types.hpp                                 1                 0   100.00%           7                 2    71.43%           2                 1    50.00%
multipart.hpp                                  4                 0   100.00%          89                15    83.15%          22                 5    77.27%
picohttpparser.h                              14                 6    57.14%         467               278    40.47%         212               103    51.42%
response_cv.hpp                                2                 0   100.00%          55                32    41.82%          46                16    65.22%
session.hpp                                   11                 0   100.00%          54                 2    96.30%           4                 1    75.00%
session_manager.hpp                           10                 1    90.00%          67                 5    92.54%          10                 1    90.00%
sha1.hpp                                      12                 0   100.00%         181                 8    95.58%          12                 2    83.33%
string_resize.hpp                              2                 0   100.00%          18                 0   100.00%           2                 0   100.00%
time_util.hpp                                 20                 7    65.00%         172                70    59.30%          28                 2    92.86%
uri.hpp                                       17                 5    70.59%         200                62    69.00%         166                52    68.67%
url_encode_decode.hpp                          4                 0   100.00%          85                20    76.47%          48                16    66.67%
utils.hpp                                     14                 0   100.00%         221                22    90.05%         116                43    62.93%
websocket.hpp                                 15                 4    73.33%         170                43    74.71%          70                18    74.29%
ylt/coro_io/client_pool.hpp                   21                 5    76.19%         278               132    52.52%          56                37    33.93%
ylt/coro_io/coro_file.hpp                     34                 0   100.00%         246                20    91.87%          44                18    59.09%
ylt/coro_io/coro_io.hpp                       56                 6    89.29%         378                44    88.36%          32                 9    71.88%
ylt/coro_io/detail/client_queue.hpp           10                 5    50.00%          47                23    51.06%          10                 4    60.00%
ylt/coro_io/io_context_pool.hpp               40                 8    80.00%         227                41    81.94%          28                 8    71.43%
ylt/coro_io/load_blancer.hpp                  16                 1    93.75%         112                 8    92.86%          34                 8    76.47%
ylt/metric/counter.hpp                         2                 1    50.00%          13                 6    53.85%           2                 0   100.00%
ylt/metric/detail/ckms_quantiles.hpp           1                 1     0.00%           5                 5     0.00%           0                 0         -
ylt/metric/gauge.hpp                           1                 0   100.00%           7                 0   100.00%           2                 0   100.00%
ylt/metric/histogram.hpp                       1                 0   100.00%           8                 0   100.00%           0                 0         -
ylt/metric/metric.hpp                         12                12     0.00%          26                26     0.00%           0                 0         -
ylt/metric/metric_manager.hpp                  8                 5    37.50%          45                33    26.67%           2                 1    50.00%
ylt/metric/summary.hpp                         1                 1     0.00%           1                 1     0.00%           0                 0         -
ylt/metric/thread_local_value.hpp              6                 0   100.00%          22                 2    90.91%           4                 1    75.00%
ylt/util/concurrentqueue.h                    77                26    66.23%        1354               835    38.33%         290               198    31.72%
ylt/util/expected.hpp                          6                 4    33.33%           6                 4    33.33%           0                 0         -
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                        749               139    81.44%        9070              2676    70.50%        2548               926    63.66%
qicosmos commented 2 months ago

please format the code with clang-format13

github-actions[bot] commented 2 months ago

Code Coverage Report for detail, goto summary download Artifacts

Filename                               Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
cinatra_log_wrapper.hpp                        4                 1    75.00%           9                 1    88.89%           0                 0         -
cookie.hpp                                    15                 2    86.67%          84                 2    97.62%          28                 3    89.29%
coro_http_client.hpp                          93                 8    91.40%        1555               311    80.00%         470               145    69.15%
coro_http_connection.hpp                      36                 2    94.44%         667               180    73.01%         202                64    68.32%
coro_http_request.hpp                         31                 7    77.42%         220                43    80.45%          74                10    86.49%
coro_http_response.hpp                        31                 6    80.65%         224                68    69.64%          90                36    60.00%
coro_http_router.hpp                          15                 0   100.00%         181                32    82.32%          20                 8    60.00%
coro_http_server.hpp                          50                 5    90.00%         988               147    85.12%         182                49    73.08%
coro_radix_tree.hpp                           17                 0   100.00%         264                38    85.61%         136                30    77.94%
define.h                                       2                 0   100.00%          28                 2    92.86%          20                 1    95.00%
http_parser.hpp                               29                 6    79.31%         193                33    82.90%          52                 8    84.62%
metric_conf.hpp                                8                 4    50.00%          96                80    16.67%          32                28    12.50%
mime_types.hpp                                 1                 0   100.00%           7                 2    71.43%           2                 1    50.00%
multipart.hpp                                  4                 0   100.00%          89                15    83.15%          22                 5    77.27%
picohttpparser.h                              14                 6    57.14%         467               278    40.47%         212               103    51.42%
response_cv.hpp                                2                 0   100.00%          55                32    41.82%          46                16    65.22%
session.hpp                                   11                 0   100.00%          54                 2    96.30%           4                 1    75.00%
session_manager.hpp                           10                 1    90.00%          67                 5    92.54%          10                 1    90.00%
sha1.hpp                                      12                 0   100.00%         181                 8    95.58%          12                 2    83.33%
string_resize.hpp                              2                 0   100.00%          18                 0   100.00%           2                 0   100.00%
time_util.hpp                                 20                 7    65.00%         172                70    59.30%          28                 2    92.86%
uri.hpp                                       17                 5    70.59%         200                62    69.00%         166                52    68.67%
url_encode_decode.hpp                          4                 0   100.00%          85                20    76.47%          48                16    66.67%
utils.hpp                                     14                 0   100.00%         221                22    90.05%         116                43    62.93%
websocket.hpp                                 15                 4    73.33%         170                43    74.71%          70                18    74.29%
ylt/coro_io/client_pool.hpp                   21                 5    76.19%         278               132    52.52%          56                37    33.93%
ylt/coro_io/coro_file.hpp                     34                 0   100.00%         246                20    91.87%          44                18    59.09%
ylt/coro_io/coro_io.hpp                       56                 6    89.29%         378                44    88.36%          32                 9    71.88%
ylt/coro_io/detail/client_queue.hpp           10                 5    50.00%          47                23    51.06%          10                 4    60.00%
ylt/coro_io/io_context_pool.hpp               40                 8    80.00%         227                41    81.94%          28                 8    71.43%
ylt/coro_io/load_blancer.hpp                  16                 1    93.75%         112                 8    92.86%          34                 8    76.47%
ylt/metric/counter.hpp                         2                 1    50.00%          13                 6    53.85%           2                 0   100.00%
ylt/metric/detail/ckms_quantiles.hpp           1                 1     0.00%           5                 5     0.00%           0                 0         -
ylt/metric/gauge.hpp                           1                 0   100.00%           7                 0   100.00%           2                 0   100.00%
ylt/metric/histogram.hpp                       1                 0   100.00%           8                 0   100.00%           0                 0         -
ylt/metric/metric.hpp                         12                12     0.00%          26                26     0.00%           0                 0         -
ylt/metric/metric_manager.hpp                  8                 5    37.50%          45                33    26.67%           2                 1    50.00%
ylt/metric/summary.hpp                         1                 1     0.00%           1                 1     0.00%           0                 0         -
ylt/metric/thread_local_value.hpp              6                 0   100.00%          22                 2    90.91%           4                 1    75.00%
ylt/util/concurrentqueue.h                    77                26    66.23%        1354               835    38.33%         290               198    31.72%
ylt/util/expected.hpp                          6                 4    33.33%           6                 4    33.33%           0                 0         -
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                        749               139    81.44%        9070              2676    70.50%        2548               926    63.66%