Improve the polling statistics
The statistics of the polling system no longer match the implementation it measures. Modified the statistics to better represent the new system by calculating the number of epoll events each thread receives.
This commit is contained in:
@ -31,6 +31,15 @@ MXS_BEGIN_DECLS
|
||||
|
||||
typedef void* ts_stats_t;
|
||||
|
||||
/** Enum values for ts_stats_get */
|
||||
enum ts_stats_type
|
||||
{
|
||||
TS_STATS_MAX, /**< Maximum value */
|
||||
TS_STATS_MIX, /**< Minimum value */
|
||||
TS_STATS_SUM, /**< Sum of all value */
|
||||
TS_STATS_AVG /**< Average of all values */
|
||||
};
|
||||
|
||||
/** stats_init should be called only once */
|
||||
void ts_stats_init();
|
||||
|
||||
@ -39,7 +48,17 @@ void ts_stats_end();
|
||||
|
||||
ts_stats_t ts_stats_alloc();
|
||||
void ts_stats_free(ts_stats_t stats);
|
||||
int64_t ts_stats_sum(ts_stats_t stats);
|
||||
|
||||
/**
|
||||
* @brief Get statistics
|
||||
*
|
||||
* @param stats Statistics to read
|
||||
* @param type Type of statistics to get
|
||||
* @return Statistics value
|
||||
*
|
||||
* @see enum ts_stats_type
|
||||
*/
|
||||
int64_t ts_stats_get(ts_stats_t stats, enum ts_stats_type type);
|
||||
|
||||
/**
|
||||
* @brief Increment thread statistics by one
|
||||
@ -61,8 +80,6 @@ ts_stats_increment(ts_stats_t stats, int thread_id)
|
||||
* @param stats Statistics to set
|
||||
* @param value Value to set to
|
||||
* @param thread_id ID of thread
|
||||
*
|
||||
* @note Appears to be unused
|
||||
*/
|
||||
static void inline
|
||||
ts_stats_set(ts_stats_t stats, int value, int thread_id)
|
||||
@ -70,4 +87,44 @@ ts_stats_set(ts_stats_t stats, int value, int thread_id)
|
||||
((int64_t*)stats)[thread_id] = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Assign the maximum value to a statistics element
|
||||
*
|
||||
* This sets the value for the specified thread if the current value is smaller.
|
||||
*
|
||||
* @param stats Statistics to set
|
||||
* @param value Value to set to
|
||||
* @param thread_id ID of thread
|
||||
*/
|
||||
static void inline
|
||||
ts_stats_set_max(ts_stats_t stats, int value, int thread_id)
|
||||
{
|
||||
int64_t *p = (int64_t*) stats;
|
||||
|
||||
if (value > p[thread_id])
|
||||
{
|
||||
p[thread_id] = value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Assign the minimum value to a statistics element
|
||||
*
|
||||
* This sets the value for the specified thread if the current value is larger.
|
||||
*
|
||||
* @param stats Statistics to set
|
||||
* @param value Value to set to
|
||||
* @param thread_id ID of thread
|
||||
*/
|
||||
static void inline
|
||||
ts_stats_set_min(ts_stats_t stats, int value, int thread_id)
|
||||
{
|
||||
int64_t *p = (int64_t*) stats;
|
||||
|
||||
if (value < p[thread_id])
|
||||
{
|
||||
p[thread_id] = value;
|
||||
}
|
||||
}
|
||||
|
||||
MXS_END_DECLS
|
||||
|
Reference in New Issue
Block a user