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"(
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)

View File

@ -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;
}
}

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_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) ||

View File

@ -1234,13 +1234,11 @@ Performance:
--backend-request-buffer=<SIZE>
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=<SIZE>
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=<N>
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=<DURATION>
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=<N>
Set maximum number of incoming HTTP request 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;
}
template <typename T> std::string utos_with_unit(T n) {
template <typename T> std::string utos_unit(T n) {
char u = 0;
if (n >= (1 << 30)) {
u = 'G';
@ -360,8 +360,8 @@ template <typename T> std::string utos_with_unit(T n) {
return utos(n) + u;
}
// Like utos_with_unit(), but 2 digits fraction part is followed.
template <typename T> std::string utos_with_funit(T n) {
// Like utos_unit(), but 2 digits fraction part is followed.
template <typename T> std::string utos_funit(T n) {
char u = 0;
int b = 0;
if (n >= (1 << 30)) {

View File

@ -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) {

View File

@ -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);