unbound 0.1
perf.c File Reference

This program estimates DNS name server performance. More...

#include "config.h"
#include <signal.h>
#include "util/log.h"
#include "util/locks.h"
#include "util/net_help.h"
#include "util/data/msgencode.h"
#include "util/data/msgreply.h"
#include "util/data/msgparse.h"
#include "sldns/sbuffer.h"
#include "sldns/wire2str.h"
#include "sldns/str2wire.h"
#include <sys/time.h>

Data Structures

struct  perfinfo
 Global info for perf. More...
struct  perfio
 I/O port for perf. More...

Macros

#define START_IO_INTERVAL   10
 number of msec between starting io ports
#define IO_TIMEOUT   10
 number of msec timeout on io ports

Functions

static void usage (char *nm)
 usage information for perf
static RETSIGTYPE perf_sigh (int sig)
 signal handler for user quit
static int perf_tv_smaller (struct timeval *t1, struct timeval *t2)
 timeval compare, t1 < t2
static void perf_tv_add (struct timeval *t1, struct timeval *t2)
 timeval add, t1 += t2
static void perf_tv_subtract (struct timeval *t1, struct timeval *t2)
 timeval subtract, t1 -= t2
static void perfsetup (struct perfinfo *info)
 setup perf test environment
static void perffree (struct perfinfo *info)
 cleanup perf test environment
static void perfsend (struct perfinfo *info, size_t n, struct timeval *now)
 send new query for io
static void perfreply (struct perfinfo *info, size_t n, struct timeval *now)
 got reply for io
static void perftimeout (struct perfinfo *info, size_t n, struct timeval *now)
 got timeout for io
static void stat_printout (struct perfinfo *info, struct timeval *now, struct timeval *elapsed)
 print nice stats about qps
static void perfselect (struct perfinfo *info)
 wait for new events for performance test
static void perfendstats (struct perfinfo *info)
 show end stats
static void perfmain (struct perfinfo *info)
 perform the performance test
static int qlist_parse_line (sldns_buffer *buf, char *p)
 parse a query line to a packet into buffer
static void qlist_grow_capacity (struct perfinfo *info)
 grow query list capacity
static void qlist_add_line (struct perfinfo *info, char *line, int no)
 setup query list in info
static void qlist_read_file (struct perfinfo *info, char *fname)
 setup query list in info
int main (int argc, char *argv[])
 main program for perf

Variables

static struct perfinfo * sig_info
 signal handler global info
int optind
 getopt global, in case header files fail to declare it.
char * optarg
 getopt global, in case header files fail to declare it.

Detailed Description

This program estimates DNS name server performance.

Macro Definition Documentation

◆ START_IO_INTERVAL

#define START_IO_INTERVAL   10

number of msec between starting io ports

Referenced by perfsetup().

◆ IO_TIMEOUT

#define IO_TIMEOUT   10

number of msec timeout on io ports

Referenced by perfsend().

Function Documentation

◆ usage()

void usage ( char * nm)
static

usage information for perf

References usage().

◆ perf_sigh()

RETSIGTYPE perf_sigh ( int sig)
static

signal handler for user quit

References perfinfo::exit, log_assert, perf_sigh(), perfinfo::quiet, and sig_info.

Referenced by perf_sigh(), and perfsetup().

◆ perf_tv_smaller()

int perf_tv_smaller ( struct timeval * t1,
struct timeval * t2 )
static

timeval compare, t1 < t2

References perf_tv_smaller().

Referenced by perf_tv_smaller(), and perfselect().

◆ perf_tv_add()

void perf_tv_add ( struct timeval * t1,
struct timeval * t2 )
static

timeval add, t1 += t2

References perf_tv_add().

Referenced by perf_tv_add(), perfsend(), and perfsetup().

◆ perf_tv_subtract()

void perf_tv_subtract ( struct timeval * t1,
struct timeval * t2 )
static

timeval subtract, t1 -= t2

References perf_tv_subtract().

Referenced by perf_tv_subtract(), perfendstats(), and perfselect().

◆ perfsetup()

◆ perffree()

void perffree ( struct perfinfo * info)
static

◆ perfsend()

◆ perfreply()

void perfreply ( struct perfinfo * info,
size_t n,
struct timeval * now )
static

◆ perftimeout()

void perftimeout ( struct perfinfo * info,
size_t n,
struct timeval * now )
static

got timeout for io

References perfio::info, perfsend(), and perftimeout().

Referenced by perfselect(), and perftimeout().

◆ stat_printout()

void stat_printout ( struct perfinfo * info,
struct timeval * now,
struct timeval * elapsed )
static

◆ perfselect()

◆ perfendstats()

◆ perfmain()

void perfmain ( struct perfinfo * info)
static

perform the performance test

References perfinfo::exit, perfendstats(), perffree(), perfmain(), perfselect(), and perfsetup().

Referenced by main(), and perfmain().

◆ qlist_parse_line()

◆ qlist_grow_capacity()

void qlist_grow_capacity ( struct perfinfo * info)
static

◆ qlist_add_line()

◆ qlist_read_file()

void qlist_read_file ( struct perfinfo * info,
char * fname )
static

setup query list in info

References qlist_add_line(), qlist_read_file(), and perfinfo::qlist_size.

Referenced by main(), and qlist_read_file().

◆ main()

Variable Documentation

◆ sig_info

struct perfinfo* sig_info
static

signal handler global info

Referenced by perf_sigh(), and perfsetup().