|
Asterisk - The Open Source Telephony Project GIT-master-5467495
|
Performance Experimentation Tests. More...
#include "asterisk.h"#include "asterisk/module.h"#include "asterisk/cli.h"#include "asterisk/time.h"#include "asterisk/astobj2.h"#include "asterisk/vector.h"#include "asterisk/utils.h"#include "asterisk/strings.h"#include "asterisk/hashtab.h"#include "asterisk/linkedlists.h"#include <stdlib.h>
Go to the source code of this file.
Data Structures | |
| struct | list_node |
| A node in the linked list for string lookups. More... | |
Macros | |
| #define | DEFAULT_DURATION_SEC 10 |
| The default duration of the performance test in seconds. | |
| #define | DEFAULT_KEY_COUNT 250 |
| The default number of keys to generate for performance tests. | |
| #define | RANDOM_STRING_ATTEMPTS 100 |
| The number of attempts for random strings before we give up. | |
| #define | TEST_KEY_LENGTH 32 |
| The length of each test key. | |
Functions | |
| static void | __reg_module (void) |
| static void | __unreg_module (void) |
| struct ast_module * | AST_MODULE_SELF_SYM (void) |
| static void | free_random_strings (struct ast_vector_string *vec) |
| Frees the memory used by a vector of random strings. | |
| static struct ast_vector_string * | generate_random_strings (int count) |
| Generates a vector of random strings to use as keys. | |
| static char * | handle_cli_ao2_string_hash (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| Handles the CLI command for testing ao2_container hash string lookups. | |
| static char * | handle_cli_ao2_string_list (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| Handles the CLI command for testing ao2_container list string lookups. | |
| static char * | handle_cli_ao2_string_rbtree (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| Handles the CLI command for testing ao2_container rbtree string lookups. | |
| static char * | handle_cli_container_key_lookup_all (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| Handles the CLI command for running all container key lookup performance tests. | |
| static char * | handle_cli_hashtab_string (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| Handles the CLI command for testing hashtab string lookups. | |
| static char * | handle_cli_list_string (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| Handle the 'performance test list_string' command. | |
| static char * | handle_cli_vector_bsearch_lookup (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| Handles the CLI command for testing vector string binary search lookups. | |
| static char * | handle_cli_vector_linear_lookup (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| Handles the CLI command for testing vector string linear search lookups. | |
| static void | hashtab_free_string (void *obj) |
| Frees a string object placed into a hashtab. | |
| static int | load_module (void) |
| Loads the performance testing module. | |
| static int | next_prime (int n) |
| Finds the next prime number greater than or equal to n. | |
| static int | rbtree_str_cmp (void *lhs, void *rhs, int flags) |
| Compares two strings for finding in the RBTree. | |
| static int | rbtree_str_sort (const void *lhs, const void *rhs, int flags) |
| Compares two strings for sorting in the RBTree. | |
| static int | unload_module (void) |
| Unloads the performance testing module. | |
| static int | vector_string_cmp (const void *_a, const void *_b) |
| Compares two strings for sorting. | |
Variables | |
| static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Performance Test Experimentation Module" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, } |
| static const struct ast_module_info * | ast_module_info = &__mod_info |
| static struct ast_cli_entry | cli_performance [] |
| The CLI commands for performance experimentation testing. | |
Performance Experimentation Tests.
Definition in file test_performance.c.
| #define DEFAULT_DURATION_SEC 10 |
The default duration of the performance test in seconds.
Definition at line 49 of file test_performance.c.
| #define DEFAULT_KEY_COUNT 250 |
The default number of keys to generate for performance tests.
Definition at line 46 of file test_performance.c.
| #define RANDOM_STRING_ATTEMPTS 100 |
The number of attempts for random strings before we give up.
Definition at line 55 of file test_performance.c.
| #define TEST_KEY_LENGTH 32 |
The length of each test key.
Definition at line 52 of file test_performance.c.
|
static |
Definition at line 1013 of file test_performance.c.
|
static |
Definition at line 1013 of file test_performance.c.
| struct ast_module * AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 1013 of file test_performance.c.
|
static |
Frees the memory used by a vector of random strings.
The following tests cover the most common usage of containers in Asterisk - a key lookup based on a string which then resolves to an underlying object. The CLI commands assume that the underlying container implementations are working properly and return the requested object. These tests also only test single threaded performance. They do not test concurrent access or thread safety.
| vec | The vector of random strings to free |
Definition at line 69 of file test_performance.c.
References ast_free, AST_VECTOR_FREE, and AST_VECTOR_RESET.
Referenced by generate_random_strings(), handle_cli_ao2_string_hash(), handle_cli_ao2_string_list(), handle_cli_ao2_string_rbtree(), handle_cli_hashtab_string(), handle_cli_list_string(), handle_cli_vector_bsearch_lookup(), and handle_cli_vector_linear_lookup().
|
static |
Generates a vector of random strings to use as keys.
| count | The number of strings to generate |
Definition at line 81 of file test_performance.c.
References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_cleanup, ao2_find, ao2_ref, ast_free, ast_generate_random_string(), ast_malloc, ast_str_container_add(), ast_str_container_alloc_options(), ast_strdup, AST_VECTOR_APPEND, AST_VECTOR_INIT, buf, free_random_strings(), NULL, OBJ_SEARCH_KEY, RANDOM_STRING_ATTEMPTS, and TEST_KEY_LENGTH.
Referenced by handle_cli_ao2_string_hash(), handle_cli_ao2_string_list(), handle_cli_ao2_string_rbtree(), handle_cli_hashtab_string(), handle_cli_list_string(), handle_cli_vector_bsearch_lookup(), and handle_cli_vector_linear_lookup().
|
static |
Handles the CLI command for testing ao2_container hash string lookups.
| e | The CLI entry |
| cmd | The command to execute |
| a | The CLI arguments |
Definition at line 203 of file test_performance.c.
References a, AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_cleanup, ao2_find, ao2_ref, ast_cli(), ast_random(), ast_str_container_add(), ast_str_container_alloc_options(), ast_tvdiff_ms(), ast_tvnow(), AST_VECTOR_GET, AST_VECTOR_SIZE, CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SUCCESS, ast_cli_entry::command, container, DEFAULT_DURATION_SEC, DEFAULT_KEY_COUNT, free_random_strings(), generate_random_strings(), next_prime(), NULL, OBJ_SEARCH_KEY, and ast_cli_entry::usage.
Referenced by handle_cli_container_key_lookup_all().
|
static |
Handles the CLI command for testing ao2_container list string lookups.
| e | The CLI entry |
| cmd | The command to execute |
| a | The CLI arguments |
Definition at line 431 of file test_performance.c.
References a, AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_alloc_options, ao2_cleanup, ao2_container_alloc_list, ao2_find, ao2_link, ao2_ref, ast_cli(), ast_random(), ast_tvdiff_ms(), ast_tvnow(), AST_VECTOR_GET, AST_VECTOR_SIZE, CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SUCCESS, ast_cli_entry::command, container, DEFAULT_DURATION_SEC, DEFAULT_KEY_COUNT, free_random_strings(), generate_random_strings(), NULL, OBJ_SEARCH_KEY, rbtree_str_cmp(), rbtree_str_sort(), and ast_cli_entry::usage.
Referenced by handle_cli_container_key_lookup_all().
|
static |
Handles the CLI command for testing ao2_container rbtree string lookups.
| e | The CLI entry |
| cmd | The command to execute |
| a | The CLI arguments |
Definition at line 337 of file test_performance.c.
References a, AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_alloc_options, ao2_cleanup, ao2_container_alloc_rbtree, ao2_find, ao2_link, ao2_ref, ast_cli(), ast_random(), ast_tvdiff_ms(), ast_tvnow(), AST_VECTOR_GET, AST_VECTOR_SIZE, CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SUCCESS, ast_cli_entry::command, container, DEFAULT_DURATION_SEC, DEFAULT_KEY_COUNT, free_random_strings(), generate_random_strings(), NULL, OBJ_SEARCH_KEY, rbtree_str_cmp(), rbtree_str_sort(), and ast_cli_entry::usage.
Referenced by handle_cli_container_key_lookup_all().
|
static |
Handles the CLI command for running all container key lookup performance tests.
| e | The CLI entry |
| cmd | The command to execute |
| a | The CLI arguments |
Definition at line 948 of file test_performance.c.
References a, CLI_GENERATE, CLI_INIT, CLI_SUCCESS, ast_cli_entry::command, handle_cli_ao2_string_hash(), handle_cli_ao2_string_list(), handle_cli_ao2_string_rbtree(), handle_cli_hashtab_string(), handle_cli_list_string(), handle_cli_vector_bsearch_lookup(), handle_cli_vector_linear_lookup(), NULL, and ast_cli_entry::usage.
|
static |
Handles the CLI command for testing hashtab string lookups.
| e | The CLI entry |
| cmd | The command to execute |
| a | The CLI arguments |
Definition at line 534 of file test_performance.c.
References a, ast_cli(), ast_free, ast_hashtab_compare_strings(), ast_hashtab_create, ast_hashtab_destroy(), ast_hashtab_hash_string(), ast_hashtab_insert_immediate, ast_hashtab_lookup(), ast_random(), ast_strdup, ast_tvdiff_ms(), ast_tvnow(), AST_VECTOR_GET, AST_VECTOR_SIZE, CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SUCCESS, ast_cli_entry::command, DEFAULT_DURATION_SEC, DEFAULT_KEY_COUNT, free_random_strings(), generate_random_strings(), hashtab_free_string(), next_prime(), NULL, and ast_cli_entry::usage.
Referenced by handle_cli_container_key_lookup_all().
|
static |
Handle the 'performance test list_string' command.
| e | The CLI entry |
| cmd | The command to execute |
| a | The CLI arguments |
Definition at line 643 of file test_performance.c.
References a, ast_calloc, ast_cli(), ast_free, AST_LIST_HEAD_INIT_NOLOCK, AST_LIST_HEAD_NOLOCK, AST_LIST_INSERT_TAIL, AST_LIST_REMOVE_HEAD, AST_LIST_TRAVERSE, ast_random(), ast_strdup, ast_tvdiff_ms(), ast_tvnow(), AST_VECTOR_GET, AST_VECTOR_SIZE, cleanup(), CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SUCCESS, ast_cli_entry::command, DEFAULT_DURATION_SEC, DEFAULT_KEY_COUNT, free_random_strings(), generate_random_strings(), NULL, and ast_cli_entry::usage.
Referenced by handle_cli_container_key_lookup_all().
|
static |
Handles the CLI command for testing vector string binary search lookups.
| e | The CLI entry |
| cmd | The command to execute |
| a | The CLI arguments |
Definition at line 744 of file test_performance.c.
References a, ast_cli(), ast_free, ast_random(), ast_strdup, ast_tvdiff_ms(), ast_tvnow(), AST_VECTOR_APPEND, AST_VECTOR_BSEARCH, AST_VECTOR_FREE, AST_VECTOR_GET, AST_VECTOR_INIT, AST_VECTOR_RESET, AST_VECTOR_SIZE, AST_VECTOR_SORT, CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SUCCESS, ast_cli_entry::command, DEFAULT_DURATION_SEC, DEFAULT_KEY_COUNT, free_random_strings(), generate_random_strings(), NULL, ast_cli_entry::usage, and vector_string_cmp().
Referenced by handle_cli_container_key_lookup_all().
|
static |
Handles the CLI command for testing vector string linear search lookups.
| e | The CLI entry |
| cmd | The command to execute |
| a | The CLI arguments |
Definition at line 848 of file test_performance.c.
References a, ast_cli(), ast_free, ast_random(), ast_strdup, ast_tvdiff_ms(), ast_tvnow(), AST_VECTOR_APPEND, AST_VECTOR_FREE, AST_VECTOR_GET, AST_VECTOR_INIT, AST_VECTOR_RESET, AST_VECTOR_SIZE, CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SUCCESS, ast_cli_entry::command, DEFAULT_DURATION_SEC, DEFAULT_KEY_COUNT, free_random_strings(), generate_random_strings(), NULL, and ast_cli_entry::usage.
Referenced by handle_cli_container_key_lookup_all().
|
static |
Frees a string object placed into a hashtab.
| obj | The string object to free |
Definition at line 522 of file test_performance.c.
References ast_free.
Referenced by handle_cli_hashtab_string().
|
static |
Loads the performance testing module.
Definition at line 1007 of file test_performance.c.
References ARRAY_LEN, ast_cli_register_multiple, AST_MODULE_LOAD_SUCCESS, and cli_performance.
|
static |
Finds the next prime number greater than or equal to n.
| n | The number to find the next prime for |
Definition at line 173 of file test_performance.c.
References ast_is_prime().
Referenced by handle_cli_ao2_string_hash(), and handle_cli_hashtab_string().
|
static |
Compares two strings for finding in the RBTree.
| lhs | The first string to compare |
| rhs | The second string to compare |
| flags | The search flags |
Definition at line 317 of file test_performance.c.
References CMP_MATCH, OBJ_SEARCH_MASK, and OBJ_SEARCH_PARTIAL_KEY.
Referenced by handle_cli_ao2_string_list(), and handle_cli_ao2_string_rbtree().
|
static |
Compares two strings for sorting in the RBTree.
| lhs | The first string to compare |
| rhs | The second string to compare |
| flags | The search flags |
Definition at line 301 of file test_performance.c.
References OBJ_SEARCH_MASK, and OBJ_SEARCH_PARTIAL_KEY.
Referenced by handle_cli_ao2_string_list(), and handle_cli_ao2_string_rbtree().
|
static |
Unloads the performance testing module.
Definition at line 997 of file test_performance.c.
References ARRAY_LEN, ast_cli_unregister_multiple(), and cli_performance.
|
static |
Compares two strings for sorting.
| a | The first string to compare |
| b | The second string to compare |
Definition at line 161 of file test_performance.c.
Referenced by handle_cli_vector_bsearch_lookup().
|
static |
Definition at line 1013 of file test_performance.c.
|
static |
Definition at line 1013 of file test_performance.c.
|
static |
The CLI commands for performance experimentation testing.
Definition at line 982 of file test_performance.c.
Referenced by load_module(), and unload_module().