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:
parent
c30b3bbb64
commit
b406501263
@ -279,7 +279,6 @@ bool tf_ssb_db_store_message(tf_ssb_t* ssb, JSContext* context, const char* id,
|
|||||||
{
|
{
|
||||||
printf("%s\n", sqlite3_errmsg(db));
|
printf("%s\n", sqlite3_errmsg(db));
|
||||||
}
|
}
|
||||||
printf("changes = %d\n", sqlite3_changes(db));
|
|
||||||
stored = r == SQLITE_DONE && sqlite3_changes(db) != 0;
|
stored = r == SQLITE_DONE && sqlite3_changes(db) != 0;
|
||||||
if (stored)
|
if (stored)
|
||||||
{
|
{
|
||||||
|
@ -542,3 +542,38 @@ void tf_ssb_test_following(const tf_test_options_t* options)
|
|||||||
|
|
||||||
sqlite3_close(db0);
|
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);
|
||||||
|
}
|
||||||
|
@ -6,3 +6,4 @@ void tf_ssb_test_id_conversion(const tf_test_options_t* options);
|
|||||||
void tf_ssb_test_ssb(const tf_test_options_t* options);
|
void tf_ssb_test_ssb(const tf_test_options_t* options);
|
||||||
void tf_ssb_test_following(const tf_test_options_t* options);
|
void tf_ssb_test_following(const tf_test_options_t* options);
|
||||||
void tf_ssb_test_rooms(const tf_test_options_t* options);
|
void tf_ssb_test_rooms(const tf_test_options_t* options);
|
||||||
|
void tf_ssb_test_bench(const tf_test_options_t* options);
|
||||||
|
@ -697,5 +697,6 @@ void tf_tests(const tf_test_options_t* options)
|
|||||||
_tf_test_run(options, "sign", _test_sign);
|
_tf_test_run(options, "sign", _test_sign);
|
||||||
_tf_test_run(options, "b64", _test_b64);
|
_tf_test_run(options, "b64", _test_b64);
|
||||||
_tf_test_run(options, "rooms", tf_ssb_test_rooms);
|
_tf_test_run(options, "rooms", tf_ssb_test_rooms);
|
||||||
|
_tf_test_run(options, "bench", tf_ssb_test_bench);
|
||||||
printf("Tests completed.\n");
|
printf("Tests completed.\n");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user