src: Make util::utos_with_unit and utos_with_funit names shorter

This commit is contained in:
Tatsuhiro Tsujikawa 2016-01-11 18:12:31 +09:00
parent 0697de4691
commit fe8005327a
7 changed files with 38 additions and 43 deletions

View File

@ -2321,7 +2321,7 @@ int main(int argc, char **argv) {
std::cout << std::fixed << std::setprecision(2) << R"( std::cout << std::fixed << std::setprecision(2) << R"(
finished in )" << util::format_duration(duration) << ", " << rps << " req/s, " 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 requests: )" << stats.req_todo << " total, " << stats.req_started
<< " started, " << stats.req_done << " done, " << " started, " << stats.req_done << " done, "
<< stats.req_status_success << " succeeded, " << stats.req_failed << 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 << stats.req_timedout << R"( timeout
status codes: )" << stats.status[2] << " 2xx, " << stats.status[3] << " 3xx, " status codes: )" << stats.status[2] << " 2xx, " << stats.status[3] << " 3xx, "
<< stats.status[4] << " 4xx, " << stats.status[5] << R"( 5xx << stats.status[4] << " 4xx, " << stats.status[5] << R"( 5xx
traffic: )" << util::utos_with_funit(stats.bytes_total) << "B (" traffic: )" << util::utos_funit(stats.bytes_total) << "B (" << stats.bytes_total
<< stats.bytes_total << ") total, " << ") total, " << util::utos_funit(stats.bytes_head) << "B ("
<< util::utos_with_funit(stats.bytes_head) << "B ("
<< stats.bytes_head << ") headers (space savings " << stats.bytes_head << ") headers (space savings "
<< header_space_savings * 100 << "%), " << header_space_savings * 100 << "%), "
<< util::utos_with_funit(stats.bytes_body) << "B (" << util::utos_funit(stats.bytes_body) << "B (" << stats.bytes_body
<< stats.bytes_body << R"() data << R"() data
min max mean sd +/- sd min max mean sd +/- sd
time for request: )" << std::setw(10) << util::format_duration(ts.request.min) time for request: )" << std::setw(10) << util::format_duration(ts.request.min)
<< " " << std::setw(10) << util::format_duration(ts.request.max) << " " << std::setw(10) << util::format_duration(ts.request.max)

View File

@ -1974,7 +1974,7 @@ id responseEnd requestStart process code size request path)" << std::endl;
<< ("+" + util::format_duration(request_start)) << " " << ("+" + util::format_duration(request_start)) << " "
<< std::setw(8) << util::format_duration(total) << " " << std::setw(8) << util::format_duration(total) << " "
<< std::setw(4) << req->status << " " << std::setw(4) << 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; << req->make_reqpath() << std::endl;
} }
} }

View File

@ -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_select_h2", shrpx::test_util_select_h2) ||
!CU_add_test(pSuite, "util_ipv6_numeric_addr", !CU_add_test(pSuite, "util_ipv6_numeric_addr",
shrpx::test_util_ipv6_numeric_addr) || shrpx::test_util_ipv6_numeric_addr) ||
!CU_add_test(pSuite, "util_utos_with_unit", !CU_add_test(pSuite, "util_utos_unit", shrpx::test_util_utos_unit) ||
shrpx::test_util_utos_with_unit) || !CU_add_test(pSuite, "util_utos_funit", shrpx::test_util_utos_funit) ||
!CU_add_test(pSuite, "util_utos_with_funit",
shrpx::test_util_utos_with_funit) ||
!CU_add_test(pSuite, "util_parse_uint_with_unit", !CU_add_test(pSuite, "util_parse_uint_with_unit",
shrpx::test_util_parse_uint_with_unit) || shrpx::test_util_parse_uint_with_unit) ||
!CU_add_test(pSuite, "util_parse_uint", shrpx::test_util_parse_uint) || !CU_add_test(pSuite, "util_parse_uint", shrpx::test_util_parse_uint) ||

View File

@ -1234,13 +1234,11 @@ Performance:
--backend-request-buffer=<SIZE> --backend-request-buffer=<SIZE>
Set buffer size used to store backend request. Set buffer size used to store backend request.
Default: )" Default: )"
<< util::utos_with_unit(get_config()->downstream_request_buffer_size) << util::utos_unit(get_config()->downstream_request_buffer_size) << R"(
<< R"(
--backend-response-buffer=<SIZE> --backend-response-buffer=<SIZE>
Set buffer size used to store backend response. Set buffer size used to store backend response.
Default: )" Default: )"
<< util::utos_with_unit(get_config()->downstream_response_buffer_size) << util::utos_unit(get_config()->downstream_response_buffer_size) << R"(
<< R"(
--fastopen=<N> --fastopen=<N>
Enables "TCP Fast Open" for the listening socket and Enables "TCP Fast Open" for the listening socket and
limits the maximum length for the queue of connections limits the maximum length for the queue of connections
@ -1434,7 +1432,7 @@ SSL/TLS:
period. This behaviour applies to all TLS based period. This behaviour applies to all TLS based
frontends, and TLS HTTP/2 backends. frontends, and TLS HTTP/2 backends.
Default: )" 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=<DURATION> --tls-dyn-rec-idle-timeout=<DURATION>
Specify TLS dynamic record size behaviour timeout. See Specify TLS dynamic record size behaviour timeout. See
--tls-dyn-rec-warmup-threshold for more information. --tls-dyn-rec-warmup-threshold for more information.
@ -1613,8 +1611,8 @@ HTTP:
Set maximum buffer size for incoming HTTP request header Set maximum buffer size for incoming HTTP request header
field list. This is the sum of header name and value in field list. This is the sum of header name and value in
bytes. bytes.
Default: )" Default: )" << util::utos_unit(get_config()->header_field_buffer)
<< util::utos_with_unit(get_config()->header_field_buffer) << R"( << R"(
--max-header-fields=<N> --max-header-fields=<N>
Set maximum number of incoming HTTP request header Set maximum number of incoming HTTP request header
fields, which appear in one request or response header fields, which appear in one request or response header

View File

@ -342,7 +342,7 @@ template <typename T> std::string utos(T n) {
return res; return res;
} }
template <typename T> std::string utos_with_unit(T n) { template <typename T> std::string utos_unit(T n) {
char u = 0; char u = 0;
if (n >= (1 << 30)) { if (n >= (1 << 30)) {
u = 'G'; u = 'G';
@ -360,8 +360,8 @@ template <typename T> std::string utos_with_unit(T n) {
return utos(n) + u; return utos(n) + u;
} }
// Like utos_with_unit(), but 2 digits fraction part is followed. // Like utos_unit(), but 2 digits fraction part is followed.
template <typename T> std::string utos_with_funit(T n) { template <typename T> std::string utos_funit(T n) {
char u = 0; char u = 0;
int b = 0; int b = 0;
if (n >= (1 << 30)) { if (n >= (1 << 30)) {

View File

@ -234,28 +234,28 @@ void test_util_ipv6_numeric_addr(void) {
CU_ASSERT(!util::ipv6_numeric_addr("localhost")); CU_ASSERT(!util::ipv6_numeric_addr("localhost"));
} }
void test_util_utos_with_unit(void) { void test_util_utos_unit(void) {
CU_ASSERT("0" == util::utos_with_unit(0)); CU_ASSERT("0" == util::utos_unit(0));
CU_ASSERT("1023" == util::utos_with_unit(1023)); CU_ASSERT("1023" == util::utos_unit(1023));
CU_ASSERT("1K" == util::utos_with_unit(1024)); CU_ASSERT("1K" == util::utos_unit(1024));
CU_ASSERT("1K" == util::utos_with_unit(1025)); CU_ASSERT("1K" == util::utos_unit(1025));
CU_ASSERT("1M" == util::utos_with_unit(1 << 20)); CU_ASSERT("1M" == util::utos_unit(1 << 20));
CU_ASSERT("1G" == util::utos_with_unit(1 << 30)); CU_ASSERT("1G" == util::utos_unit(1 << 30));
CU_ASSERT("1024G" == util::utos_with_unit(1LL << 40)); CU_ASSERT("1024G" == util::utos_unit(1LL << 40));
} }
void test_util_utos_with_funit(void) { void test_util_utos_funit(void) {
CU_ASSERT("0" == util::utos_with_funit(0)); CU_ASSERT("0" == util::utos_funit(0));
CU_ASSERT("1023" == util::utos_with_funit(1023)); CU_ASSERT("1023" == util::utos_funit(1023));
CU_ASSERT("1.00K" == util::utos_with_funit(1024)); CU_ASSERT("1.00K" == util::utos_funit(1024));
CU_ASSERT("1.00K" == util::utos_with_funit(1025)); CU_ASSERT("1.00K" == util::utos_funit(1025));
CU_ASSERT("1.09K" == util::utos_with_funit(1119)); CU_ASSERT("1.09K" == util::utos_funit(1119));
CU_ASSERT("1.27K" == util::utos_with_funit(1300)); CU_ASSERT("1.27K" == util::utos_funit(1300));
CU_ASSERT("1.00M" == util::utos_with_funit(1 << 20)); CU_ASSERT("1.00M" == util::utos_funit(1 << 20));
CU_ASSERT("1.18M" == util::utos_with_funit(1234567)); CU_ASSERT("1.18M" == util::utos_funit(1234567));
CU_ASSERT("1.00G" == util::utos_with_funit(1 << 30)); CU_ASSERT("1.00G" == util::utos_funit(1 << 30));
CU_ASSERT("4492450797.23G" == util::utos_with_funit(4823732313248234343LL)); CU_ASSERT("4492450797.23G" == util::utos_funit(4823732313248234343LL));
CU_ASSERT("1024.00G" == util::utos_with_funit(1LL << 40)); CU_ASSERT("1024.00G" == util::utos_funit(1LL << 40));
} }
void test_util_parse_uint_with_unit(void) { void test_util_parse_uint_with_unit(void) {

View File

@ -44,8 +44,8 @@ void test_util_utox(void);
void test_util_http_date(void); void test_util_http_date(void);
void test_util_select_h2(void); void test_util_select_h2(void);
void test_util_ipv6_numeric_addr(void); void test_util_ipv6_numeric_addr(void);
void test_util_utos_with_unit(void); void test_util_utos_unit(void);
void test_util_utos_with_funit(void); void test_util_utos_funit(void);
void test_util_parse_uint_with_unit(void); void test_util_parse_uint_with_unit(void);
void test_util_parse_uint(void); void test_util_parse_uint(void);
void test_util_parse_duration_with_unit(void); void test_util_parse_duration_with_unit(void);