clang-format results

pull/1267/head
Vijay Pai 10 years ago
parent 9cccb08311
commit 0310f13fd9
  1. 30
      src/core/profiling/timers.c
  2. 12
      src/core/profiling/timers.h
  3. 1
      src/core/profiling/timers_preciseclock.h
  4. 6
      test/core/profiling/timers_test.c

@ -56,12 +56,12 @@ struct grpc_timers_log {
int num_entries;
int capacity;
int capacity_limit;
FILE *fp;
FILE* fp;
};
grpc_timers_log* grpc_timers_log_global = NULL;
grpc_timers_log* grpc_timers_log_create(int capacity_limit, FILE *dump) {
grpc_timers_log* grpc_timers_log_create(int capacity_limit, FILE* dump) {
grpc_timers_log* log = gpr_malloc(sizeof(*log));
/* TODO (vpai): Allow allocation below limit */
@ -78,22 +78,22 @@ grpc_timers_log* grpc_timers_log_create(int capacity_limit, FILE *dump) {
return log;
}
static void log_report_locked(grpc_timers_log *log) {
FILE *fp = log->fp;
static void log_report_locked(grpc_timers_log* log) {
FILE* fp = log->fp;
int i;
for (i=0;i<log->num_entries;i++) {
for (i = 0; i < log->num_entries; i++) {
grpc_timer_entry* entry = &(log->log[i]);
fprintf(fp, "GRPC_LAT_PROF ");
grpc_precise_clock_print(&entry->tm, fp);
fprintf(fp, " %s#%d,%s:%d\n", entry->tag, entry->seq,
entry->file, entry->line);
fprintf(fp, " %s#%d,%s:%d\n", entry->tag, entry->seq, entry->file,
entry->line);
}
/* Now clear out the log */
log->num_entries=0;
log->num_entries = 0;
}
void grpc_timers_log_destroy(grpc_timers_log *log) {
void grpc_timers_log_destroy(grpc_timers_log* log) {
gpr_mu_lock(&log->mu);
log_report_locked(log);
gpr_mu_unlock(&log->mu);
@ -104,8 +104,8 @@ void grpc_timers_log_destroy(grpc_timers_log *log) {
gpr_free(log);
}
void grpc_timers_log_add(grpc_timers_log *log, const char *tag, int seq,
const char *file, int line) {
void grpc_timers_log_add(grpc_timers_log* log, const char* tag, int seq,
const char* file, int line) {
grpc_timer_entry* entry;
/* TODO (vpai) : Improve concurrency */
@ -132,9 +132,7 @@ void grpc_timers_log_global_init(void) {
void grpc_timers_log_global_destroy(void) {
grpc_timers_log_destroy(grpc_timers_log_global);
}
#else /* !GRPC_LATENCY_PROFILER */
void grpc_timers_log_global_init(void) {
}
void grpc_timers_log_global_destroy(void) {
}
#else /* !GRPC_LATENCY_PROFILER */
void grpc_timers_log_global_init(void) {}
void grpc_timers_log_global_destroy(void) {}
#endif /* GRPC_LATENCY_PROFILER */

@ -44,18 +44,20 @@ extern "C" {
typedef struct grpc_timers_log grpc_timers_log;
grpc_timers_log* grpc_timers_log_create(int capacity_limit, FILE *dump);
grpc_timers_log *grpc_timers_log_create(int capacity_limit, FILE *dump);
void grpc_timers_log_add(grpc_timers_log *, const char *tag, int seq,
const char *file, int line);
const char *file, int line);
void grpc_timers_log_destroy(grpc_timers_log *);
extern grpc_timers_log *grpc_timers_log_global;
#define GRPC_TIMER_MARK(x, s) grpc_timers_log_add(grpc_timers_log_global, #x, \
s, __FILE__, __LINE__)
#define GRPC_TIMER_MARK(x, s) \
grpc_timers_log_add(grpc_timers_log_global, #x, s, __FILE__, __LINE__)
#else /* !GRPC_LATENCY_PROFILER */
#define GRPC_TIMER_MARK(x, s) do {} while (0)
#define GRPC_TIMER_MARK(x, s) \
do { \
} while (0)
#endif /* GRPC_LATENCY_PROFILER */
void grpc_timers_log_global_init(void);

@ -53,5 +53,4 @@ static void grpc_precise_clock_print(const grpc_precise_clock* clk, FILE* fp) {
}
#endif /* GRPC_TIMERS_RDTSC */
#endif /* GRPC_CORE_PROFILING_TIMERS_PRECISECLOCK_H */

@ -38,7 +38,7 @@
void test_log_events(int num_seqs) {
int start = 0;
int *state;
state = calloc(num_seqs,sizeof(state[0]));
state = calloc(num_seqs, sizeof(state[0]));
while (start < num_seqs) {
int i;
int row;
@ -48,10 +48,10 @@ void test_log_events(int num_seqs) {
}
row = rand() % 10; /* how many in a row */
for (i = start; (i < start+row) && (i < num_seqs); i++) {
for (i = start; (i < start + row) && (i < num_seqs); i++) {
int j;
int advance = 1 + rand() % 3; /* how many to advance by */
for (j=0; j<advance; j++) {
for (j = 0; j < advance; j++) {
switch (state[i]) {
case 0:
GRPC_TIMER_MARK(STATE_0, i);

Loading…
Cancel
Save