From 54066f338f185f2fbd6694d9a4877f42cbfa21c8 Mon Sep 17 00:00:00 2001 From: iphydf Date: Thu, 9 Aug 2018 23:53:39 +0000 Subject: Reduce the number of times `unix_time_update` is called. Reduced by, e.g.: * `file_transfer_test`: 33% of the `clock_gettime` calls. * `tox_many_test`: 53% of the `clock_gettime` calls. Other tests will see similar improvements. Real world applications will be closer to 40-50% improvement, since tox_many_test has 100 nodes, while file_transfer_test has 2 nodes. --- toxcore/tox.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'toxcore/tox.c') diff --git a/toxcore/tox.c b/toxcore/tox.c index cd1b71f0..879b5c09 100644 --- a/toxcore/tox.c +++ b/toxcore/tox.c @@ -38,6 +38,7 @@ #include "Messenger.h" #include "group.h" #include "logger.h" +#include "mono_time.h" #include "../toxencryptsave/defines.h" @@ -335,6 +336,8 @@ Tox *tox_new(const struct Tox_Options *options, Tox_Err_New *error) return nullptr; } + unix_time_update(); + Messenger_Options m_options = {0}; bool load_savedata_sk = false, load_savedata_tox = false; @@ -653,6 +656,8 @@ uint32_t tox_iteration_interval(const Tox *tox) void tox_iterate(Tox *tox, void *user_data) { + unix_time_update(); + Messenger *m = tox->m; struct Tox_Userdata tox_data = { tox, user_data }; do_messenger(m, &tox_data); -- cgit v1.2.3