diff --git a/src/h2load.cc b/src/h2load.cc index 1c47f6e8..62d65bd3 100644 --- a/src/h2load.cc +++ b/src/h2load.cc @@ -2321,7 +2321,7 @@ int main(int argc, char **argv) { std::cout << std::fixed << std::setprecision(2) << R"( finished in )" << util::format_duration(duration) << ", " << rps << " req/s, " - << util::utos_with_funit(bps) << R"(B/s + << util::utos_funit(bps) << R"(B/s requests: )" << stats.req_todo << " total, " << stats.req_started << " started, " << stats.req_done << " done, " << stats.req_status_success << " succeeded, " << stats.req_failed @@ -2329,13 +2329,12 @@ requests: )" << stats.req_todo << " total, " << stats.req_started << stats.req_timedout << R"( timeout status codes: )" << stats.status[2] << " 2xx, " << stats.status[3] << " 3xx, " << stats.status[4] << " 4xx, " << stats.status[5] << R"( 5xx -traffic: )" << util::utos_with_funit(stats.bytes_total) << "B (" - << stats.bytes_total << ") total, " - << util::utos_with_funit(stats.bytes_head) << "B (" +traffic: )" << util::utos_funit(stats.bytes_total) << "B (" << stats.bytes_total + << ") total, " << util::utos_funit(stats.bytes_head) << "B (" << stats.bytes_head << ") headers (space savings " << header_space_savings * 100 << "%), " - << util::utos_with_funit(stats.bytes_body) << "B (" - << stats.bytes_body << R"() data + << util::utos_funit(stats.bytes_body) << "B (" << stats.bytes_body + << R"() data min max mean sd +/- sd time for request: )" << std::setw(10) << util::format_duration(ts.request.min) << " " << std::setw(10) << util::format_duration(ts.request.max) diff --git a/src/nghttp.cc b/src/nghttp.cc index 2788c104..df33e12d 100644 --- a/src/nghttp.cc +++ b/src/nghttp.cc @@ -1974,7 +1974,7 @@ id responseEnd requestStart process code size request path)" << std::endl; << ("+" + util::format_duration(request_start)) << " " << std::setw(8) << util::format_duration(total) << " " << std::setw(4) << req->status << " " << std::setw(4) - << util::utos_with_unit(req->response_len) << " " + << util::utos_unit(req->response_len) << " " << req->make_reqpath() << std::endl; } } diff --git a/src/shrpx-unittest.cc b/src/shrpx-unittest.cc index b51c242f..2e156f1d 100644 --- a/src/shrpx-unittest.cc +++ b/src/shrpx-unittest.cc @@ -144,10 +144,8 @@ int main(int argc, char *argv[]) { !CU_add_test(pSuite, "util_select_h2", shrpx::test_util_select_h2) || !CU_add_test(pSuite, "util_ipv6_numeric_addr", shrpx::test_util_ipv6_numeric_addr) || - !CU_add_test(pSuite, "util_utos_with_unit", - shrpx::test_util_utos_with_unit) || - !CU_add_test(pSuite, "util_utos_with_funit", - shrpx::test_util_utos_with_funit) || + !CU_add_test(pSuite, "util_utos_unit", shrpx::test_util_utos_unit) || + !CU_add_test(pSuite, "util_utos_funit", shrpx::test_util_utos_funit) || !CU_add_test(pSuite, "util_parse_uint_with_unit", shrpx::test_util_parse_uint_with_unit) || !CU_add_test(pSuite, "util_parse_uint", shrpx::test_util_parse_uint) || diff --git a/src/shrpx.cc b/src/shrpx.cc index 16daa620..6d603a9c 100644 --- a/src/shrpx.cc +++ b/src/shrpx.cc @@ -1234,13 +1234,11 @@ Performance: --backend-request-buffer= Set buffer size used to store backend request. Default: )" - << util::utos_with_unit(get_config()->downstream_request_buffer_size) - << R"( + << util::utos_unit(get_config()->downstream_request_buffer_size) << R"( --backend-response-buffer= Set buffer size used to store backend response. Default: )" - << util::utos_with_unit(get_config()->downstream_response_buffer_size) - << R"( + << util::utos_unit(get_config()->downstream_response_buffer_size) << R"( --fastopen= Enables "TCP Fast Open" for the listening socket and limits the maximum length for the queue of connections @@ -1434,7 +1432,7 @@ SSL/TLS: period. This behaviour applies to all TLS based frontends, and TLS HTTP/2 backends. Default: )" - << util::utos_with_unit(get_config()->tls_dyn_rec_warmup_threshold) << R"( + << util::utos_unit(get_config()->tls_dyn_rec_warmup_threshold) << R"( --tls-dyn-rec-idle-timeout= Specify TLS dynamic record size behaviour timeout. See --tls-dyn-rec-warmup-threshold for more information. @@ -1613,8 +1611,8 @@ HTTP: Set maximum buffer size for incoming HTTP request header field list. This is the sum of header name and value in bytes. - Default: )" - << util::utos_with_unit(get_config()->header_field_buffer) << R"( + Default: )" << util::utos_unit(get_config()->header_field_buffer) + << R"( --max-header-fields= Set maximum number of incoming HTTP request header fields, which appear in one request or response header diff --git a/src/util.h b/src/util.h index 8efd7407..b09bf550 100644 --- a/src/util.h +++ b/src/util.h @@ -342,7 +342,7 @@ template std::string utos(T n) { return res; } -template std::string utos_with_unit(T n) { +template std::string utos_unit(T n) { char u = 0; if (n >= (1 << 30)) { u = 'G'; @@ -360,8 +360,8 @@ template std::string utos_with_unit(T n) { return utos(n) + u; } -// Like utos_with_unit(), but 2 digits fraction part is followed. -template std::string utos_with_funit(T n) { +// Like utos_unit(), but 2 digits fraction part is followed. +template std::string utos_funit(T n) { char u = 0; int b = 0; if (n >= (1 << 30)) { diff --git a/src/util_test.cc b/src/util_test.cc index 9732ff15..0667b7a1 100644 --- a/src/util_test.cc +++ b/src/util_test.cc @@ -234,28 +234,28 @@ void test_util_ipv6_numeric_addr(void) { CU_ASSERT(!util::ipv6_numeric_addr("localhost")); } -void test_util_utos_with_unit(void) { - CU_ASSERT("0" == util::utos_with_unit(0)); - CU_ASSERT("1023" == util::utos_with_unit(1023)); - CU_ASSERT("1K" == util::utos_with_unit(1024)); - CU_ASSERT("1K" == util::utos_with_unit(1025)); - CU_ASSERT("1M" == util::utos_with_unit(1 << 20)); - CU_ASSERT("1G" == util::utos_with_unit(1 << 30)); - CU_ASSERT("1024G" == util::utos_with_unit(1LL << 40)); +void test_util_utos_unit(void) { + CU_ASSERT("0" == util::utos_unit(0)); + CU_ASSERT("1023" == util::utos_unit(1023)); + CU_ASSERT("1K" == util::utos_unit(1024)); + CU_ASSERT("1K" == util::utos_unit(1025)); + CU_ASSERT("1M" == util::utos_unit(1 << 20)); + CU_ASSERT("1G" == util::utos_unit(1 << 30)); + CU_ASSERT("1024G" == util::utos_unit(1LL << 40)); } -void test_util_utos_with_funit(void) { - CU_ASSERT("0" == util::utos_with_funit(0)); - CU_ASSERT("1023" == util::utos_with_funit(1023)); - CU_ASSERT("1.00K" == util::utos_with_funit(1024)); - CU_ASSERT("1.00K" == util::utos_with_funit(1025)); - CU_ASSERT("1.09K" == util::utos_with_funit(1119)); - CU_ASSERT("1.27K" == util::utos_with_funit(1300)); - CU_ASSERT("1.00M" == util::utos_with_funit(1 << 20)); - CU_ASSERT("1.18M" == util::utos_with_funit(1234567)); - CU_ASSERT("1.00G" == util::utos_with_funit(1 << 30)); - CU_ASSERT("4492450797.23G" == util::utos_with_funit(4823732313248234343LL)); - CU_ASSERT("1024.00G" == util::utos_with_funit(1LL << 40)); +void test_util_utos_funit(void) { + CU_ASSERT("0" == util::utos_funit(0)); + CU_ASSERT("1023" == util::utos_funit(1023)); + CU_ASSERT("1.00K" == util::utos_funit(1024)); + CU_ASSERT("1.00K" == util::utos_funit(1025)); + CU_ASSERT("1.09K" == util::utos_funit(1119)); + CU_ASSERT("1.27K" == util::utos_funit(1300)); + CU_ASSERT("1.00M" == util::utos_funit(1 << 20)); + CU_ASSERT("1.18M" == util::utos_funit(1234567)); + CU_ASSERT("1.00G" == util::utos_funit(1 << 30)); + CU_ASSERT("4492450797.23G" == util::utos_funit(4823732313248234343LL)); + CU_ASSERT("1024.00G" == util::utos_funit(1LL << 40)); } void test_util_parse_uint_with_unit(void) { diff --git a/src/util_test.h b/src/util_test.h index 352fec4c..45d654a1 100644 --- a/src/util_test.h +++ b/src/util_test.h @@ -44,8 +44,8 @@ void test_util_utox(void); void test_util_http_date(void); void test_util_select_h2(void); void test_util_ipv6_numeric_addr(void); -void test_util_utos_with_unit(void); -void test_util_utos_with_funit(void); +void test_util_utos_unit(void); +void test_util_utos_funit(void); void test_util_parse_uint_with_unit(void); void test_util_parse_uint(void); void test_util_parse_duration_with_unit(void);