MessageQueue - Fix max usage performance statistic
Fixes to keep track of the maximum usage over time, rather than current usage.
This commit is contained in:
parent
e09ca30b32
commit
cc60359a6c
|
@ -251,8 +251,7 @@ void MessageQueue::statistics() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int MessageQueue::get_max_buffer_usage() const {
|
int MessageQueue::get_max_buffer_usage() const {
|
||||||
// Note this may be better read_buffer, or a combination, depending when this is read.
|
return _buffer_size_monitor.max_size_overall;
|
||||||
return buffers[write_buffer].data.size();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageQueue::_call_function(Object *p_target, const StringName &p_func, const Variant *p_args, int p_argcount, bool p_show_error) {
|
void MessageQueue::_call_function(Object *p_target, const StringName &p_func, const Variant *p_args, int p_argcount, bool p_show_error) {
|
||||||
|
@ -392,6 +391,7 @@ void MessageQueue::flush() {
|
||||||
_THREAD_SAFE_LOCK_
|
_THREAD_SAFE_LOCK_
|
||||||
// keep track of the maximum used size, so we can downsize buffers when appropriate
|
// keep track of the maximum used size, so we can downsize buffers when appropriate
|
||||||
_buffer_size_monitor.max_size = MAX(buffer_data_size, _buffer_size_monitor.max_size);
|
_buffer_size_monitor.max_size = MAX(buffer_data_size, _buffer_size_monitor.max_size);
|
||||||
|
_buffer_size_monitor.max_size_overall = MAX(buffer_data_size, _buffer_size_monitor.max_size_overall);
|
||||||
|
|
||||||
// flip buffers, this is the only part that requires a lock
|
// flip buffers, this is the only part that requires a lock
|
||||||
SWAP(read_buffer, write_buffer);
|
SWAP(read_buffer, write_buffer);
|
||||||
|
|
|
@ -70,6 +70,9 @@ class MessageQueue {
|
||||||
struct BufferSizeMonitor {
|
struct BufferSizeMonitor {
|
||||||
uint32_t max_size = 0;
|
uint32_t max_size = 0;
|
||||||
uint32_t flush_count = 0;
|
uint32_t flush_count = 0;
|
||||||
|
|
||||||
|
// Only used for performance statistics.
|
||||||
|
uint32_t max_size_overall = 0;
|
||||||
} _buffer_size_monitor;
|
} _buffer_size_monitor;
|
||||||
|
|
||||||
void _call_function(Object *p_target, const StringName &p_func, const Variant *p_args, int p_argcount, bool p_show_error);
|
void _call_function(Object *p_target, const StringName &p_func, const Variant *p_args, int p_argcount, bool p_show_error);
|
||||||
|
@ -97,6 +100,7 @@ public:
|
||||||
bool is_flushing() const;
|
bool is_flushing() const;
|
||||||
|
|
||||||
int get_max_buffer_usage() const;
|
int get_max_buffer_usage() const;
|
||||||
|
int get_current_buffer_usage() const;
|
||||||
|
|
||||||
MessageQueue();
|
MessageQueue();
|
||||||
~MessageQueue();
|
~MessageQueue();
|
||||||
|
|
Loading…
Reference in New Issue