diff --git a/external/tox_ngc_ft1/tox_ngc_ft1 b/external/tox_ngc_ft1/tox_ngc_ft1 index aa9c7c4..3675c2a 160000 --- a/external/tox_ngc_ft1/tox_ngc_ft1 +++ b/external/tox_ngc_ft1/tox_ngc_ft1 @@ -1 +1 @@ -Subproject commit aa9c7c44bab594cd03b0ad5af70fd5c39a34cf6b +Subproject commit 3675c2a1a8dc01e3a892d4f487f98657a9ea0ce6 diff --git a/src/states/sha1.cpp b/src/states/sha1.cpp index 68330be..cc50cd7 100644 --- a/src/states/sha1.cpp +++ b/src/states/sha1.cpp @@ -182,6 +182,25 @@ bool SHA1::iterate(float delta) { } } + // log + _io_log_timer += delta; + static const float log_interval {15.f}; + if (_io_log_timer >= log_interval) { + _io_log_timer = 0.f; + + size_t bytes_up_since {_bytes_up - _bytes_up_last_log}; + _bytes_up_last_log = _bytes_up; + + size_t bytes_down_since {_bytes_down - _bytes_down_last_log}; + _bytes_down_last_log = _bytes_down; + + float up_kibs {(bytes_up_since / 1024.f) / log_interval}; + float down_kibs {(bytes_down_since / 1024.f) / log_interval}; + + std::cout << "SHA1 speed down: " << down_kibs << "KiB/s up: " << up_kibs << "KiB/s\n"; + std::cout << "SHA1 total down: " << _bytes_down / 1024 << "KiB up: " << _bytes_up / 1024 << "KiB\n"; + } + // TODO: unmap and remap the file every couple of minutes to keep ram usage down? // TODO: when to stop? return false; @@ -324,6 +343,8 @@ void SHA1::onFT1ReceiveDataSHA1Chunk(uint32_t group_number, uint32_t peer_number // check transfers for (auto it = _transfers_receiving_chunk.begin(); it != _transfers_receiving_chunk.end(); it++) { if (std::get<0>(*it) == group_number && std::get<1>(*it) == peer_number && std::get<2>(*it) == transfer_id) { + _bytes_down += data_size; + std::get(*it) = 0.f; // time const size_t chunk_index = std::get<4>(*it); @@ -364,6 +385,8 @@ void SHA1::onFT1SendDataSHA1Chunk(uint32_t group_number, uint32_t peer_number, u // TODO: sub optimal for (auto it = _transfers_sending_chunk.begin(); it != _transfers_sending_chunk.end(); it++) { if (std::get<0>(*it) == group_number && std::get<1>(*it) == peer_number && std::get<2>(*it) == transfer_id) { + _bytes_up += data_size; + std::get(*it) = 0.f; // time const size_t chunk_index = std::get<4>(*it); diff --git a/src/states/sha1.hpp b/src/states/sha1.hpp index 19413f6..c818346 100644 --- a/src/states/sha1.hpp +++ b/src/states/sha1.hpp @@ -61,6 +61,12 @@ struct SHA1 final : public StateI { const std::vector _sha1_info_data; const SHA1Digest _sha1_info_hash; + float _io_log_timer {0.f}; + size_t _bytes_up {0}; + size_t _bytes_up_last_log {0}; + size_t _bytes_down {0}; + size_t _bytes_down_last_log {0}; + // index is the same as for info std::vector _have_chunk; bool _have_all {false}; diff --git a/src/tox_client.cpp b/src/tox_client.cpp index b2bbaea..6c0eb4b 100644 --- a/src/tox_client.cpp +++ b/src/tox_client.cpp @@ -278,7 +278,7 @@ void ToxClient::onToxGroupPeerJoin(uint32_t group_number, uint32_t peer_id) { } void ToxClient::onToxGroupPeerExit(uint32_t group_number, uint32_t peer_id, Tox_Group_Exit_Type exit_type, std::string_view name, std::string_view part_message) { - std::cout << "TCL group peer exit " << group_number << ":" << peer_id << "\n"; + std::cout << "TCL group peer exit " << group_number << ":" << peer_id << " " << name << "\n"; _groups[group_number].erase(peer_id); _tox_profile_dirty = true; }