diff options
author | iphydf <iphydf@users.noreply.github.com> | 2018-08-09 23:53:39 +0000 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2018-08-16 21:01:38 +0000 |
commit | 54066f338f185f2fbd6694d9a4877f42cbfa21c8 (patch) | |
tree | e056e50af1009bf373c040812e46cd1de8de9979 /testing | |
parent | 31ea1aa06e59d24d5196b17be9a7105d85c25080 (diff) |
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.
Diffstat (limited to 'testing')
-rw-r--r-- | testing/DHT_test.c | 3 | ||||
-rw-r--r-- | testing/Messenger_test.c | 5 |
2 files changed, 8 insertions, 0 deletions
diff --git a/testing/DHT_test.c b/testing/DHT_test.c index c9372847..1d01f0a2 100644 --- a/testing/DHT_test.c +++ b/testing/DHT_test.c | |||
@@ -42,6 +42,7 @@ | |||
42 | 42 | ||
43 | #include "../toxcore/DHT.h" | 43 | #include "../toxcore/DHT.h" |
44 | #include "../toxcore/friend_requests.h" | 44 | #include "../toxcore/friend_requests.h" |
45 | #include "../toxcore/mono_time.h" | ||
45 | #include "misc_tools.h" | 46 | #include "misc_tools.h" |
46 | 47 | ||
47 | #define PORT 33445 | 48 | #define PORT 33445 |
@@ -237,6 +238,8 @@ int main(int argc, char *argv[]) | |||
237 | #endif | 238 | #endif |
238 | 239 | ||
239 | while (1) { | 240 | while (1) { |
241 | unix_time_update(); | ||
242 | |||
240 | do_dht(dht); | 243 | do_dht(dht); |
241 | 244 | ||
242 | #if 0 /* TODO(slvr): */ | 245 | #if 0 /* TODO(slvr): */ |
diff --git a/testing/Messenger_test.c b/testing/Messenger_test.c index c02681f8..a5abfda0 100644 --- a/testing/Messenger_test.c +++ b/testing/Messenger_test.c | |||
@@ -47,6 +47,7 @@ | |||
47 | #endif | 47 | #endif |
48 | 48 | ||
49 | #include "../toxcore/Messenger.h" | 49 | #include "../toxcore/Messenger.h" |
50 | #include "../toxcore/mono_time.h" | ||
50 | #include "misc_tools.h" | 51 | #include "misc_tools.h" |
51 | 52 | ||
52 | static void print_message(Messenger *m, uint32_t friendnumber, unsigned int type, const uint8_t *string, size_t length, | 53 | static void print_message(Messenger *m, uint32_t friendnumber, unsigned int type, const uint8_t *string, size_t length, |
@@ -106,6 +107,8 @@ int main(int argc, char *argv[]) | |||
106 | exit(0); | 107 | exit(0); |
107 | } | 108 | } |
108 | 109 | ||
110 | unix_time_update(); | ||
111 | |||
109 | Messenger_Options options = {0}; | 112 | Messenger_Options options = {0}; |
110 | options.ipv6enabled = ipv6enabled; | 113 | options.ipv6enabled = ipv6enabled; |
111 | m = new_messenger(&options, nullptr); | 114 | m = new_messenger(&options, nullptr); |
@@ -177,6 +180,8 @@ int main(int argc, char *argv[]) | |||
177 | perror("Initialization"); | 180 | perror("Initialization"); |
178 | 181 | ||
179 | while (1) { | 182 | while (1) { |
183 | unix_time_update(); | ||
184 | |||
180 | uint8_t name[128]; | 185 | uint8_t name[128]; |
181 | const char *const filename = "Save.bak"; | 186 | const char *const filename = "Save.bak"; |
182 | getname(m, num, name); | 187 | getname(m, num, name); |