Start of a benchmark.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4076 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
@ -542,3 +542,38 @@ void tf_ssb_test_following(const tf_test_options_t* options)
|
||||
|
||||
sqlite3_close(db0);
|
||||
}
|
||||
|
||||
void tf_ssb_test_bench(const tf_test_options_t* options)
|
||||
{
|
||||
printf("Testing following.\n");
|
||||
sqlite3* db0 = NULL;
|
||||
int r = sqlite3_open(":memory:", &db0);
|
||||
(void)r;
|
||||
assert(r == SQLITE_OK);
|
||||
|
||||
uv_loop_t loop = { 0 };
|
||||
uv_loop_init(&loop);
|
||||
|
||||
tf_ssb_t* ssb0 = tf_ssb_create(&loop, NULL, db0);
|
||||
tf_ssb_generate_keys(ssb0);
|
||||
|
||||
char id0[k_id_base64_len] = { 0 };
|
||||
tf_ssb_whoami(ssb0, id0, sizeof(id0));
|
||||
|
||||
struct timespec start_time = { 0 };
|
||||
struct timespec end_time = { 0 };
|
||||
clock_gettime(CLOCK_REALTIME, &start_time);
|
||||
for (int i = 0; i < 10 * 1024; i++) {
|
||||
tf_ssb_append_post(ssb0, "Hello, world!");
|
||||
}
|
||||
clock_gettime(CLOCK_REALTIME, &end_time);
|
||||
printf("delta = %f seconds\n", (float)(end_time.tv_sec - start_time.tv_sec) + (end_time.tv_nsec - start_time.tv_nsec) / 1e9f);
|
||||
|
||||
uv_run(&loop, UV_RUN_DEFAULT);
|
||||
|
||||
tf_ssb_destroy(ssb0);
|
||||
|
||||
uv_loop_close(&loop);
|
||||
|
||||
sqlite3_close(db0);
|
||||
}
|
||||
|
Reference in New Issue
Block a user