forked from google/neper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lib.h
138 lines (119 loc) · 4.41 KB
/
lib.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/*
* Copyright 2016 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef THIRD_PARTY_NEPER_LIB_H
#define THIRD_PARTY_NEPER_LIB_H
#include <stdbool.h>
#include "countdown_cond.h"
#include "percentiles.h"
struct countdown_cond;
struct callbacks {
void *logger;
/* Print in key=value format and keep track of the line number.
* Not thread-safe. */
void (*print)(void *logger, const char *key, const char *value, ...)
__attribute__((format(printf, 3, 4)));
/* Use for undesired and unexpected events, that the program cannot
* recover from. Use these whenever an event happens from which you
* actually want all servers to die and dump a stack trace. */
void (*log_fatal)(void *logger, const char *file, int line,
const char *function, const char *format, ...)
__attribute__((format(printf, 5, 6)));
/* Use for undesired and unexpected events that the program can recover
* from. All ERRORs should be actionable - it should be appropriate to
* file a bug whenever an ERROR occurs in production. */
void (*log_error)(void *logger, const char *file, int line,
const char *function, const char *format, ...)
__attribute__((format(printf, 5, 6)));
/* Use for undesired but relatively expected events, which may indicate
* a problem. For example, the server received a malformed query. */
void (*log_warn)(void *logger, const char *file, int line,
const char *function, const char *format, ...)
__attribute__((format(printf, 5, 6)));
/* Use for state changes or other major events, or to aid debugging. */
void (*log_info)(void *logger, const char *file, int line,
const char *function, const char *format, ...)
__attribute__((format(printf, 5, 6)));
/* Notify the logger to log to stderr. */
void (*logtostderr)(void *logger);
};
struct options {
int magic;
int min_rto;
int maxevents;
int num_flows;
int num_threads;
int num_clients;
int num_ports;
int test_length;
int buffer_size;
int listen_backlog;
int suicide_length;
int recv_flags;
bool stime_use_proc; /* Enable use of /proc/stat values for stime */
bool ipv4;
bool ipv6;
bool client;
bool debug;
bool dry_run;
bool pin_cpu;
#ifndef NO_LIBNUMA
bool pin_numa;
#endif
bool reuseaddr;
bool logtostderr;
bool nolog;
bool nonblocking;
bool freebind;
bool tcp_fastopen;
bool skip_rx_copy;
double interval;
long long max_pacing_rate;
const char *local_hosts;
const char *host;
const char *control_port;
const char *port;
int source_port;
const char *all_samples;
const char secret[32]; /* includes test name */
bool async_connect;
/* tcp_stream */
bool enable_read;
bool enable_write;
bool enable_tcp_maerts;
bool edge_trigger;
unsigned long delay; /* ns, also used in tcp_rr */
const struct rate_conversion *throughput_opt;
unsigned long long local_rate; /* updated in report */
unsigned long long remote_rate; /* updated in final msg */
/* tcp_rr */
int request_size;
int response_size;
struct percentiles percentiles;
/* tcp_crr */
bool nostats;
};
#ifdef __cplusplus
extern "C" {
#endif
int tcp_stream(struct options *, struct callbacks *);
int udp_stream(struct options *, struct callbacks *);
int tcp_rr(struct options *, struct callbacks *);
int udp_rr(struct options *, struct callbacks *);
int tcp_crr(struct options *, struct callbacks *);
#ifdef __cplusplus
}
#endif
#endif