CUBRID Engine  latest
unittests_lf.c File Reference
#include "porting.h"
#include "lock_free.h"
#include <stdio.h>
#include <pthread.h>
#include <time.h>
#include <sys/time.h>
#include <assert.h>
Include dependency graph for unittests_lf.c:

Go to the source code of this file.

Classes

struct  xentry
 

Macros

#define strlen(s1)   ((int) strlen(s1))
 
#define RAND_BLOCKS   64
 
#define RAND_BLOCK_SIZE   1000000
 
#define RAND_SIZE   RAND_BLOCKS * RAND_BLOCK_SIZE
 
#define PTHREAD_ABORT_AND_EXIT(code)
 
#define MSG_LEN   40
 
#define NOPS   1000000 /* 1M */
 
#define NOPS   1000000 /* 1M */
 
#define NOPS   1000000
 
#define NOPS   1000000
 
#define NOPS   1000000
 
#define NOPS   1000000
 
#define NOPS   1000000
 
#define NOPS   1000000
 
#define MAX_THREADS   64
 
#define MAX_THREADS   1024
 
#define HASH_SIZE   113
 
#define HASH_SIZE   200
 
#define HASH_POPULATION   HASH_SIZE * 5
 
#define NUM_THREADS   16
 

Typedefs

typedef struct xentry XENTRY
 
using my_hashmap = lf_hash_table_cpp< int, xentry >
 
using my_hashmap_iterator = my_hashmap::iterator
 

Functions

static void generate_random ()
 
static void * xentry_alloc ()
 
static int xentry_free (void *entry)
 
static int xentry_init (void *entry)
 
static int xentry_uninit (void *entry)
 
static unsigned int xentry_hash (void *key, int htsize)
 
static int xentry_key_compare (void *k1, void *k2)
 
static int xentry_key_copy (void *src, void *dest)
 
static void begin (const char *test_name)
 
static int fail (const char *message)
 
static int success ()
 
void * test_freelist_proc (void *param)
 
void * test_freelist_proc_local_tran (void *param)
 
void * test_hash_proc_1 (void *param)
 
void * test_hash_proc_2 (void *param)
 
void * test_hash_proc_3 (void *param)
 
void * test_clear_proc_1 (void *param)
 
void * test_clear_proc_2 (void *param)
 
void * test_clear_proc_3 (void *param)
 
static int test_freelist (LF_ENTRY_DESCRIPTOR *edesc, int nthreads, bool test_local_tran)
 
static int test_hash_table (LF_ENTRY_DESCRIPTOR *edesc, int nthreads, void *(*proc)(void *))
 
static int test_hash_iterator ()
 
int main (int argc, char **argv)
 

Variables

static int random_numbers [RAND_SIZE]
 
static LF_ENTRY_DESCRIPTOR xentry_desc
 
static struct timeval start_time
 
static int del_op_count = -1
 

Macro Definition Documentation

#define HASH_POPULATION   HASH_SIZE * 5

Referenced by test_hash_iterator().

#define HASH_SIZE   113
#define HASH_SIZE   200
#define MAX_THREADS   64

Referenced by test_freelist(), and test_hash_table().

#define MAX_THREADS   1024
#define MSG_LEN   40

Referenced by begin().

#define NOPS   1000000 /* 1M */
#define NOPS   1000000
#define NOPS   1000000
#define NOPS   1000000
#define NOPS   1000000
#define NOPS   1000000
#define NOPS   1000000
#define NUM_THREADS   16

Referenced by test_hash_iterator().

#define PTHREAD_ABORT_AND_EXIT (   code)
Value:
do \
{ \
int rc = (code); \
abort (); \
pthread_exit (&rc); \
} \
while (0)
static int rc
Definition: serial.c:50
while(1)
Definition: cnvlex.c:816

Definition at line 39 of file unittests_lf.c.

Referenced by test_clear_proc_1(), test_clear_proc_2(), test_clear_proc_3(), test_freelist_proc(), test_freelist_proc_local_tran(), test_hash_proc_1(), test_hash_proc_2(), and test_hash_proc_3().

#define RAND_BLOCK_SIZE   1000000
#define RAND_BLOCKS   64
#define RAND_SIZE   RAND_BLOCKS * RAND_BLOCK_SIZE

Definition at line 36 of file unittests_lf.c.

Referenced by generate_random().

#define strlen (   s1)    ((int) strlen(s1))

Definition at line 31 of file unittests_lf.c.

Referenced by begin().

Typedef Documentation

Definition at line 76 of file unittests_lf.c.

Definition at line 77 of file unittests_lf.c.

typedef struct xentry XENTRY

Definition at line 62 of file unittests_lf.c.

Function Documentation

static void begin ( const char *  test_name)
static

Definition at line 181 of file unittests_lf.c.

References i, MSG_LEN, NULL, start_time, and strlen.

Referenced by test_freelist(), test_hash_iterator(), and test_hash_table().

Here is the caller graph for this function:

static int fail ( const char *  message)
static

Definition at line 199 of file unittests_lf.c.

References ER_FAILED.

Referenced by main(), test_freelist(), test_hash_iterator(), and test_hash_table().

Here is the caller graph for this function:

static void generate_random ( )
static

Definition at line 49 of file unittests_lf.c.

References i, NULL, RAND_SIZE, and random_numbers.

Referenced by main().

Here is the caller graph for this function:

static int success ( )
static

Definition at line 207 of file unittests_lf.c.

References NO_ERROR, NULL, start_time, and test_freelist_proc().

Referenced by test_clear_proc_3(), test_freelist(), test_hash_iterator(), test_hash_proc_3(), and test_hash_table().

Here is the caller graph for this function:

void * test_freelist_proc ( void *  param)
void * test_freelist_proc_local_tran ( void *  param)
static void* xentry_alloc ( )
static

Definition at line 82 of file unittests_lf.c.

References xentry::data, xentry::mutex, NULL, and pthread_mutex_init.

static int xentry_free ( void *  entry)
static

Definition at line 94 of file unittests_lf.c.

References xentry::mutex, NO_ERROR, and pthread_mutex_destroy.

static unsigned int xentry_hash ( void *  key,
int  htsize 
)
static

Definition at line 131 of file unittests_lf.c.

static int xentry_init ( void *  entry)
static

Definition at line 102 of file unittests_lf.c.

References ER_FAILED, NO_ERROR, and NULL.

static int xentry_key_compare ( void *  k1,
void *  k2 
)
static

Definition at line 138 of file unittests_lf.c.

static int xentry_key_copy ( void *  src,
void *  dest 
)
static

Definition at line 145 of file unittests_lf.c.

References NO_ERROR.

static int xentry_uninit ( void *  entry)
static

Definition at line 116 of file unittests_lf.c.

References ER_FAILED, NO_ERROR, and NULL.

Variable Documentation

int del_op_count = -1
static

Definition at line 432 of file unittests_lf.c.

Referenced by main(), test_hash_proc_3(), and test_hash_table().

struct timeval start_time
static

Definition at line 178 of file unittests_lf.c.

Referenced by begin(), and success().

LF_ENTRY_DESCRIPTOR xentry_desc
static
Initial value:
= {
offsetof (XENTRY, stack),
offsetof (XENTRY, next),
offsetof (XENTRY, del_tran_id),
offsetof (XENTRY, key),
offsetof (XENTRY, mutex),
}
#define LF_EM_NOT_USING_MUTEX
Definition: lock_free.h:59
static int xentry_free(void *entry)
Definition: unittests_lf.c:94
static unsigned int xentry_hash(void *key, int htsize)
Definition: unittests_lf.c:131
static API_MUTEX mutex
Definition: api_util.c:72
static int xentry_key_compare(void *k1, void *k2)
Definition: unittests_lf.c:138
static int xentry_init(void *entry)
Definition: unittests_lf.c:102
#define NULL
Definition: freelistheap.h:34
static int xentry_uninit(void *entry)
Definition: unittests_lf.c:116
static int xentry_key_copy(void *src, void *dest)
Definition: unittests_lf.c:145
static void * xentry_alloc()
Definition: unittests_lf.c:82

Definition at line 155 of file unittests_lf.c.