forked from cory/tildefriends
Fixed multiple trace problems.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4357 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
@ -5,6 +5,7 @@
|
||||
#include "ssb.db.h"
|
||||
#include "ssb.js.h"
|
||||
#include "tests.h"
|
||||
#include "trace.h"
|
||||
#include "util.js.h"
|
||||
|
||||
#include "sqlite3.h"
|
||||
@ -596,8 +597,11 @@ void tf_ssb_test_bench(const tf_test_options_t* options)
|
||||
uv_loop_t loop = { 0 };
|
||||
uv_loop_init(&loop);
|
||||
|
||||
tf_trace_t* trace = tf_trace_create();
|
||||
|
||||
unlink("out/test_db0.sqlite");
|
||||
tf_ssb_t* ssb0 = tf_ssb_create(&loop, NULL, "file:out/test_db0.sqlite");
|
||||
tf_ssb_set_trace(ssb0, trace);
|
||||
tf_ssb_generate_keys(ssb0);
|
||||
|
||||
char id0[k_id_base64_len] = { 0 };
|
||||
@ -627,6 +631,7 @@ void tf_ssb_test_bench(const tf_test_options_t* options)
|
||||
|
||||
unlink("out/test_db1.sqlite");
|
||||
tf_ssb_t* ssb1 = tf_ssb_create(&loop, NULL, "file:out/test_db1.sqlite");
|
||||
tf_ssb_set_trace(ssb1, trace);
|
||||
tf_ssb_generate_keys(ssb1);
|
||||
uint8_t id0bin[k_id_bin_len];
|
||||
tf_ssb_id_str_to_bin(id0bin, id0);
|
||||
@ -648,13 +653,19 @@ void tf_ssb_test_bench(const tf_test_options_t* options)
|
||||
tf_printf("Waiting for messages.\n");
|
||||
clock_gettime(CLOCK_REALTIME, &start_time);
|
||||
int count = 0;
|
||||
tf_ssb_add_message_added_callback(ssb1, _message_added, NULL, &count);
|
||||
while (count < k_messages)
|
||||
{
|
||||
//tf_printf("%d / %d\n", count, k_messages);
|
||||
uv_run(&loop, UV_RUN_ONCE);
|
||||
count = _ssb_test_count_messages(ssb1);
|
||||
}
|
||||
tf_ssb_remove_message_added_callback(ssb1, _message_added, &count);
|
||||
clock_gettime(CLOCK_REALTIME, &end_time);
|
||||
|
||||
count = _ssb_test_count_messages(ssb1);
|
||||
if (count < k_messages)
|
||||
{
|
||||
abort();
|
||||
}
|
||||
tf_printf("Done.\n");
|
||||
tf_printf("replicate = %f seconds\n", (end_time.tv_sec - start_time.tv_sec) + (end_time.tv_nsec - start_time.tv_nsec) / 1e9);
|
||||
|
||||
@ -666,8 +677,19 @@ void tf_ssb_test_bench(const tf_test_options_t* options)
|
||||
|
||||
uv_run(&loop, UV_RUN_DEFAULT);
|
||||
|
||||
char* trace_data = tf_trace_export(trace);
|
||||
FILE* file = fopen("out/trace.json", "wb");
|
||||
if (file)
|
||||
{
|
||||
fwrite(trace_data, 1, strlen(trace_data), file);
|
||||
fclose(file);
|
||||
}
|
||||
tf_free(trace_data);
|
||||
|
||||
tf_ssb_destroy(ssb1);
|
||||
tf_ssb_destroy(ssb0);
|
||||
|
||||
tf_trace_destroy(trace);
|
||||
|
||||
uv_loop_close(&loop);
|
||||
}
|
||||
|
Reference in New Issue
Block a user