benchmarking for various operations More...
#include "platform.h"
#include "gnunet_util_lib.h"
#include "benchmark.h"
#include <pthread.h>
#include <sys/syscall.h>
Go to the source code of this file.
Macros | |
#define | WRITE_BENCHMARK_OP(opname) |
Functions | |
static void | write_benchmark_data (struct BenchmarkData *bd) |
Write benchmark data to a file. More... | |
static void | main_thread_destructor () |
Called when the main thread exits and benchmark data for it was created. More... | |
static void | thread_destructor (void *cls) |
Called when a thread exits and benchmark data for it was created. More... | |
static void | make_key () |
Initialize the thread-local variable key for benchmark data. More... | |
struct BenchmarkData * | get_benchmark_data (void) |
Acquire the benchmark data for the current thread, allocate if necessary. More... | |
struct UrlRequestData * | get_url_benchmark_data (char *url, unsigned int status) |
Get benchmark data for a URL. More... | |
Variables | |
static pthread_key_t | key |
Thread-local storage key for the benchmark data. More... | |
static pthread_once_t | key_once = PTHREAD_ONCE_INIT |
One-time initialization marker for key. More... | |
benchmarking for various operations
Definition in file benchmark.c.
#define WRITE_BENCHMARK_OP | ( | opname | ) |
|
static |
Write benchmark data to a file.
bd | the benchmark data |
Definition at line 51 of file benchmark.c.
References UrlRequestData::bytes_received, UrlRequestData::bytes_sent, UrlRequestData::count, getenv(), GNUNET_asprintf(), GNUNET_assert, GNUNET_break, GNUNET_DISK_directory_create(), GNUNET_DISK_file_close(), GNUNET_DISK_file_open(), GNUNET_DISK_file_write_blocking(), GNUNET_DISK_OPEN_CREATE, GNUNET_DISK_OPEN_TRUNCATE, GNUNET_DISK_OPEN_WRITE, GNUNET_DISK_PERM_USER_READ, GNUNET_DISK_PERM_USER_WRITE, GNUNET_free, GNUNET_OK, GNUNET_SYSERR, pid, GNUNET_TIME_Relative::rel_value_us, UrlRequestData::request_url, UrlRequestData::status, UrlRequestData::time, UrlRequestData::time_max, BenchmarkData::urd, BenchmarkData::urd_len, and WRITE_BENCHMARK_OP.
Referenced by main_thread_destructor(), and thread_destructor().
|
static |
Called when the main thread exits and benchmark data for it was created.
Definition at line 166 of file benchmark.c.
References key, and write_benchmark_data().
Referenced by get_benchmark_data().
|
static |
Called when a thread exits and benchmark data for it was created.
cls | closure |
Definition at line 182 of file benchmark.c.
References GNUNET_assert, and write_benchmark_data().
Referenced by make_key().
|
static |
Initialize the thread-local variable key for benchmark data.
Definition at line 199 of file benchmark.c.
References key, and thread_destructor().
Referenced by get_benchmark_data().
struct BenchmarkData * get_benchmark_data | ( | void | ) |
Acquire the benchmark data for the current thread, allocate if necessary.
Installs handler to collect the benchmark data on thread termination.
Definition at line 212 of file benchmark.c.
References GNUNET_new, key, key_once, main_thread_destructor(), and make_key().
Referenced by get_url_benchmark_data().
struct UrlRequestData * get_url_benchmark_data | ( | char * | url, |
unsigned int | status | ||
) |
Get benchmark data for a URL.
If the URL is too long, it's truncated before looking up the corresponding benchmark data.
Statistics are bucketed by URL and status code.
url | url to get request data for |
status | http status code |
Definition at line 242 of file benchmark.c.
References get_benchmark_data(), GNUNET_assert, GNUNET_break, GNUNET_realloc, MAX_BENCHMARK_URL_LEN, UrlRequestData::request_url, status, UrlRequestData::status, BenchmarkData::urd, BenchmarkData::urd_capacity, and BenchmarkData::urd_len.
|
static |
Thread-local storage key for the benchmark data.
Definition at line 37 of file benchmark.c.
Referenced by get_benchmark_data(), main_thread_destructor(), and make_key().
|
static |
One-time initialization marker for key.
Definition at line 42 of file benchmark.c.
Referenced by get_benchmark_data().