rename profiling structure

This commit is contained in:
Jeremy Lakeman 2012-07-02 16:04:00 +09:30
parent e705696896
commit 132d3a6f9b
9 changed files with 31 additions and 31 deletions

View File

@ -25,7 +25,7 @@ struct pollfd fds[MAX_WATCHED_FDS];
int fdcount=0;
struct sched_ent *fd_callbacks[MAX_WATCHED_FDS];
struct sched_ent *next_alarm=NULL;
struct callback_stats poll_stats={NULL,0,"Idle (in poll)",0,0,0};
struct profile_total poll_stats={NULL,0,"Idle (in poll)",0,0,0};
void list_alarms(){
long long now=overlay_gettime_ms();
@ -129,7 +129,7 @@ int unwatch(struct sched_ent *alarm){
void call_alarm(struct sched_ent *alarm, int revents){
struct call_stats call_stats;
struct callback_stats *stats = alarm->stats;
struct profile_total *stats = alarm->stats;
if (stats)
fd_func_enter(&call_stats);

View File

@ -61,8 +61,8 @@ int monitor_process_data(struct monitor_context *c);
static void monitor_new_client(int s);
struct sched_ent named_socket;
struct callback_stats named_stats;
struct callback_stats client_stats;
struct profile_total named_stats;
struct profile_total client_stats;
int monitor_setup_sockets()
{

View File

@ -114,7 +114,7 @@ int overlayServerMode()
#define SCHEDULE(X, Y) \
struct sched_ent _sched_##X; \
struct callback_stats _stats_##X; \
struct profile_total _stats_##X; \
bzero(&_sched_##X, sizeof(struct sched_ent)); \
_sched_##X.stats = &_stats_##X; \
_sched_##X.function=X;\

View File

@ -41,8 +41,8 @@ struct interface_rules {
struct interface_rules *interface_filter=NULL;
struct callback_stats interface_poll_stats;
struct callback_stats dummy_poll_stats;
struct profile_total interface_poll_stats;
struct profile_total dummy_poll_stats;
unsigned int overlay_sequence_number=0;

View File

@ -21,7 +21,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
struct sched_ent mdp_abstract;
struct sched_ent mdp_named;
struct callback_stats mdp_stats;
struct profile_total mdp_stats;
int overlay_mdp_setup_sockets()
{

View File

@ -19,23 +19,23 @@
#include "serval.h"
struct callback_stats *stats_head=NULL;
struct profile_total *stats_head=NULL;
struct call_stats *current_call=NULL;
void fd_clearstat(struct callback_stats *s){
void fd_clearstat(struct profile_total *s){
s->max_time = 0;
s->total_time = 0;
s->calls = 0;
}
void fd_update_stats(struct callback_stats *s,long long elapsed)
void fd_update_stats(struct profile_total *s,long long elapsed)
{
s->total_time+=elapsed;
if (elapsed>s->max_time) s->max_time=elapsed;
s->calls++;
}
int fd_tallystats(struct callback_stats *total,struct callback_stats *a)
int fd_tallystats(struct profile_total *total,struct profile_total *a)
{
total->total_time+=a->total_time;
total->calls+=a->calls;
@ -43,7 +43,7 @@ int fd_tallystats(struct callback_stats *total,struct callback_stats *a)
return 0;
}
int fd_showstat(struct callback_stats *total, struct callback_stats *a)
int fd_showstat(struct profile_total *total, struct profile_total *a)
{
INFOF("%lldms (%2.1f%%) in %d calls (max %lldms, avg %.1fms) : %s",
a->total_time,a->total_time*100.0/total->total_time,
@ -54,14 +54,14 @@ int fd_showstat(struct callback_stats *total, struct callback_stats *a)
}
// sort the list of call times
struct callback_stats *sort(struct callback_stats *list){
struct callback_stats *first = list;
struct profile_total *sort(struct profile_total *list){
struct profile_total *first = list;
// the left hand list will contain all items that took longer than the first item
struct callback_stats *left_head = NULL;
struct callback_stats *left_tail = NULL;
struct profile_total *left_head = NULL;
struct profile_total *left_tail = NULL;
// the right hand list will contain all items that took less time than the first item
struct callback_stats *right_head = NULL;
struct callback_stats *right_tail = NULL;
struct profile_total *right_head = NULL;
struct profile_total *right_tail = NULL;
// most of the cpu time is likely to be the same offenders
// don't sort a list that's already sorted
@ -130,7 +130,7 @@ struct callback_stats *sort(struct callback_stats *list){
int fd_clearstats()
{
struct callback_stats *stats = stats_head;
struct profile_total *stats = stats_head;
while(stats!=NULL){
fd_clearstat(stats);
stats = stats->_next;
@ -140,11 +140,11 @@ int fd_clearstats()
int fd_showstats()
{
struct callback_stats total={NULL, 0, "Total", 0,0,0};
struct profile_total total={NULL, 0, "Total", 0,0,0};
stats_head = sort(stats_head);
struct callback_stats *stats = stats_head;
struct profile_total *stats = stats_head;
while(stats!=NULL){
/* Get total time spent doing everything */
fd_tallystats(&total,stats);
@ -182,7 +182,7 @@ int fd_func_enter(struct call_stats *this_call)
return 0;
}
int fd_func_exit(struct call_stats *this_call, struct callback_stats *aggregate_stats)
int fd_func_exit(struct call_stats *this_call, struct profile_total *aggregate_stats)
{
if (current_call != this_call)
WHYF("stack mismatch, exited through %s()",aggregate_stats->name);

View File

@ -47,7 +47,7 @@ typedef struct rhizome_file_fetch_record {
} rhizome_file_fetch_record;
struct callback_stats fetch_stats;
struct profile_total fetch_stats;
/* List of queued transfers */
#define MAX_QUEUED_FILES 4

View File

@ -83,9 +83,9 @@ int rhizome_server_sql_query_fill_buffer(rhizome_http_request *r, char *table, c
#define RHIZOME_SERVER_MAX_LIVE_REQUESTS 32
struct sched_ent server_alarm;
struct callback_stats server_stats;
struct profile_total server_stats;
struct callback_stats connection_stats;
struct profile_total connection_stats;
/*
HTTP server and client code for rhizome transfers.

View File

@ -479,8 +479,8 @@ struct call_stats{
struct call_stats *prev;
};
struct callback_stats {
struct callback_stats *_next;
struct profile_total {
struct profile_total *_next;
int _initialised;
const char *name;
long long max_time;
@ -500,7 +500,7 @@ struct sched_ent{
void *context;
struct pollfd poll;
long long alarm;
struct callback_stats *stats;
struct profile_total *stats;
int _poll_index;
};
@ -1575,10 +1575,10 @@ void rhizome_server_poll(struct sched_ent *alarm);
/* function timing routines */
int fd_checkalarms();
int fd_func_exit(struct call_stats *this_call, struct callback_stats *call_stats);
int fd_func_exit(struct call_stats *this_call, struct profile_total *call_stats);
int fd_func_enter(struct call_stats *this_call);
#define IN() static struct callback_stats _aggregate_stats={NULL,0,__FUNCTION__,0,0,0}; struct call_stats _this_call; fd_func_enter(&_this_call);
#define IN() static struct profile_total _aggregate_stats={NULL,0,__FUNCTION__,0,0,0}; struct call_stats _this_call; fd_func_enter(&_this_call);
#define OUT() fd_func_exit(&_this_call, &_aggregate_stats);
#define RETURN(X) { OUT() return(X); }