benchmark-getaddrinfo.c
Go to the documentation of this file.
1 /* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
2  *
3  * Permission is hereby granted, free of charge, to any person obtaining a copy
4  * of this software and associated documentation files (the "Software"), to
5  * deal in the Software without restriction, including without limitation the
6  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7  * sell copies of the Software, and to permit persons to whom the Software is
8  * furnished to do so, subject to the following conditions:
9  *
10  * The above copyright notice and this permission notice shall be included in
11  * all copies or substantial portions of the Software.
12  *
13  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19  * IN THE SOFTWARE.
20  */
21 
22 #include "uv.h"
23 #include "task.h"
24 #include <stdlib.h>
25 
26 #define CONCURRENT_CALLS 10
27 #define TOTAL_CALLS 10000
28 
29 static const char* name = "localhost";
30 
31 static uv_loop_t* loop;
32 
34 
35 static int calls_initiated = 0;
36 static int calls_completed = 0;
39 
40 
42 
43 
45  struct addrinfo* res) {
46  ASSERT(status == 0);
50  }
51 
52  uv_freeaddrinfo(res);
53 }
54 
55 
57  int r;
58 
60 
61  r = uv_getaddrinfo(loop, handle, &getaddrinfo_cb, name, NULL, NULL);
62  ASSERT(r == 0);
63 }
64 
65 
66 BENCHMARK_IMPL(getaddrinfo) {
67  int i;
68 
70 
73 
74  for (i = 0; i < CONCURRENT_CALLS; i++) {
76  }
77 
79 
81  end_time = uv_now(loop);
82 
85 
86  fprintf(stderr, "getaddrinfo: %.0f req/s\n",
87  (double) calls_completed / (double) (end_time - start_time) * 1000.0);
88  fflush(stderr);
89 
91  return 0;
92 }
CONCURRENT_CALLS
#define CONCURRENT_CALLS
Definition: benchmark-getaddrinfo.c:26
loop
static uv_loop_t * loop
Definition: benchmark-getaddrinfo.c:31
task.h
uv_now
UV_EXTERN uint64_t uv_now(const uv_loop_t *)
Definition: uv-common.c:537
uv_getaddrinfo_s
Definition: uv.h:871
getaddrinfo_initiate
static void getaddrinfo_initiate(uv_getaddrinfo_t *handle)
Definition: benchmark-getaddrinfo.c:56
handles
Definition: test-ipc-send-recv.c:35
end_time
static int64_t end_time
Definition: benchmark-getaddrinfo.c:38
ASSERT
#define ASSERT(expr)
Definition: task.h:102
calls_initiated
static int calls_initiated
Definition: benchmark-getaddrinfo.c:35
status
absl::Status status
Definition: rls.cc:251
calls_completed
static int calls_completed
Definition: benchmark-getaddrinfo.c:36
start_time
static int64_t start_time
Definition: benchmark-getaddrinfo.c:37
uv_run
UV_EXTERN int uv_run(uv_loop_t *, uv_run_mode mode)
Definition: unix/core.c:361
python_utils.port_server.stderr
stderr
Definition: port_server.py:51
uv_update_time
UV_EXTERN void uv_update_time(uv_loop_t *)
Definition: unix/core.c:413
uv_default_loop
UV_EXTERN uv_loop_t * uv_default_loop(void)
Definition: uv-common.c:733
int64_t
signed __int64 int64_t
Definition: stdint-msvc2008.h:89
UV_RUN_DEFAULT
@ UV_RUN_DEFAULT
Definition: uv.h:254
uv_freeaddrinfo
UV_EXTERN void uv_freeaddrinfo(struct addrinfo *ai)
Definition: unix/getaddrinfo.c:223
uv.h
MAKE_VALGRIND_HAPPY
#define MAKE_VALGRIND_HAPPY()
Definition: task.h:229
fix_build_deps.r
r
Definition: fix_build_deps.py:491
getaddrinfo_cb
static void getaddrinfo_cb(uv_getaddrinfo_t *handle, int status, struct addrinfo *res)
Definition: benchmark-getaddrinfo.c:44
TOTAL_CALLS
#define TOTAL_CALLS
Definition: benchmark-getaddrinfo.c:27
uv_getaddrinfo
UV_EXTERN int uv_getaddrinfo(uv_loop_t *loop, uv_getaddrinfo_t *req, uv_getaddrinfo_cb getaddrinfo_cb, const char *node, const char *service, const struct addrinfo *hints)
Definition: unix/getaddrinfo.c:141
name
static const char * name
Definition: benchmark-getaddrinfo.c:29
handle
static csh handle
Definition: test_arm_regression.c:16
uv_loop_s
Definition: uv.h:1767
BENCHMARK_IMPL
BENCHMARK_IMPL(getaddrinfo)
Definition: benchmark-getaddrinfo.c:66
addrinfo
Definition: ares_ipv6.h:43
i
uint64_t i
Definition: abseil-cpp/absl/container/btree_benchmark.cc:230


grpc
Author(s):
autogenerated on Fri May 16 2025 02:57:45