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 /other | |
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 'other')
-rw-r--r-- | other/DHT_bootstrap.c | 4 | ||||
-rw-r--r-- | other/bootstrap_daemon/src/tox-bootstrapd.c | 4 |
2 files changed, 8 insertions, 0 deletions
diff --git a/other/DHT_bootstrap.c b/other/DHT_bootstrap.c index 347e5c82..fc1bba47 100644 --- a/other/DHT_bootstrap.c +++ b/other/DHT_bootstrap.c | |||
@@ -115,6 +115,8 @@ int main(int argc, char *argv[]) | |||
115 | IP ip; | 115 | IP ip; |
116 | ip_init(&ip, ipv6enabled); | 116 | ip_init(&ip, ipv6enabled); |
117 | 117 | ||
118 | unix_time_update(); | ||
119 | |||
118 | Logger *logger = logger_new(); | 120 | Logger *logger = logger_new(); |
119 | DHT *dht = new_dht(logger, new_networking(logger, ip, PORT), true); | 121 | DHT *dht = new_dht(logger, new_networking(logger, ip, PORT), true); |
120 | Onion *onion = new_onion(dht); | 122 | Onion *onion = new_onion(dht); |
@@ -186,6 +188,8 @@ int main(int argc, char *argv[]) | |||
186 | lan_discovery_init(dht); | 188 | lan_discovery_init(dht); |
187 | 189 | ||
188 | while (1) { | 190 | while (1) { |
191 | unix_time_update(); | ||
192 | |||
189 | if (is_waiting_for_dht_connection && dht_isconnected(dht)) { | 193 | if (is_waiting_for_dht_connection && dht_isconnected(dht)) { |
190 | printf("Connected to other bootstrap node successfully.\n"); | 194 | printf("Connected to other bootstrap node successfully.\n"); |
191 | is_waiting_for_dht_connection = 0; | 195 | is_waiting_for_dht_connection = 0; |
diff --git a/other/bootstrap_daemon/src/tox-bootstrapd.c b/other/bootstrap_daemon/src/tox-bootstrapd.c index b17fc2ba..d75018d8 100644 --- a/other/bootstrap_daemon/src/tox-bootstrapd.c +++ b/other/bootstrap_daemon/src/tox-bootstrapd.c | |||
@@ -230,6 +230,8 @@ int main(int argc, char *argv[]) | |||
230 | IP ip; | 230 | IP ip; |
231 | ip_init(&ip, enable_ipv6); | 231 | ip_init(&ip, enable_ipv6); |
232 | 232 | ||
233 | unix_time_update(); | ||
234 | |||
233 | Logger *logger = logger_new(); | 235 | Logger *logger = logger_new(); |
234 | 236 | ||
235 | Networking_Core *net = new_networking(logger, ip, port); | 237 | Networking_Core *net = new_networking(logger, ip, port); |
@@ -336,6 +338,8 @@ int main(int argc, char *argv[]) | |||
336 | } | 338 | } |
337 | 339 | ||
338 | while (1) { | 340 | while (1) { |
341 | unix_time_update(); | ||
342 | |||
339 | do_dht(dht); | 343 | do_dht(dht); |
340 | 344 | ||
341 | if (enable_lan_discovery && is_timeout(last_LANdiscovery, LAN_DISCOVERY_INTERVAL)) { | 345 | if (enable_lan_discovery && is_timeout(last_LANdiscovery, LAN_DISCOVERY_INTERVAL)) { |