diff options
author | Craig Tiller <ctiller@google.com> | 2015-09-22 12:33:20 -0700 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2015-09-22 12:33:20 -0700 |
commit | a82950e68318a6aab6fe894fa39f7fa616c4647b (patch) | |
tree | 7d02bd1e9e1cbae1f14ad4ad1e06d3ae81a96dfe /src/core/profiling | |
parent | 8af4c337181322cc4fb396199c90f574cfb4163f (diff) |
clang-format all core files
Diffstat (limited to 'src/core/profiling')
-rw-r--r-- | src/core/profiling/basic_timers.c | 106 | ||||
-rw-r--r-- | src/core/profiling/stap_timers.c | 28 | ||||
-rw-r--r-- | src/core/profiling/timers.h | 94 |
3 files changed, 101 insertions, 127 deletions
diff --git a/src/core/profiling/basic_timers.c b/src/core/profiling/basic_timers.c index d4506857b1..2f6c88daac 100644 --- a/src/core/profiling/basic_timers.c +++ b/src/core/profiling/basic_timers.c @@ -44,16 +44,14 @@ #include <grpc/support/thd.h> #include <stdio.h> -typedef enum -{ +typedef enum { BEGIN = '{', END = '}', MARK = '.', IMPORTANT = '!' } marker_type; -typedef struct grpc_timer_entry -{ +typedef struct grpc_timer_entry { gpr_timespec tm; int tag; const char *tagstr; @@ -68,34 +66,32 @@ typedef struct grpc_timer_entry static __thread grpc_timer_entry log[MAX_COUNT]; static __thread int count; -static void -log_report () -{ +static void log_report() { int i; - for (i = 0; i < count; i++) - { - grpc_timer_entry *entry = &(log[i]); - printf ("GRPC_LAT_PROF %ld.%09d %p %c %d(%s) %p %s %d\n", entry->tm.tv_sec, entry->tm.tv_nsec, (void *) (gpr_intptr) gpr_thd_currentid (), entry->type, entry->tag, entry->tagstr, entry->id, entry->file, entry->line); - } + for (i = 0; i < count; i++) { + grpc_timer_entry *entry = &(log[i]); + printf("GRPC_LAT_PROF %ld.%09d %p %c %d(%s) %p %s %d\n", entry->tm.tv_sec, + entry->tm.tv_nsec, (void *)(gpr_intptr)gpr_thd_currentid(), + entry->type, entry->tag, entry->tagstr, entry->id, entry->file, + entry->line); + } /* Now clear out the log */ count = 0; } -static void -grpc_timers_log_add (int tag, const char *tagstr, marker_type type, void *id, const char *file, int line) -{ +static void grpc_timers_log_add(int tag, const char *tagstr, marker_type type, + void *id, const char *file, int line) { grpc_timer_entry *entry; /* TODO (vpai) : Improve concurrency */ - if (count == MAX_COUNT) - { - log_report (); - } + if (count == MAX_COUNT) { + log_report(); + } entry = &log[count++]; - entry->tm = gpr_now (GPR_CLOCK_PRECISE); + entry->tm = gpr_now(GPR_CLOCK_PRECISE); entry->tag = tag; entry->tagstr = tagstr; entry->type = type; @@ -105,61 +101,41 @@ grpc_timers_log_add (int tag, const char *tagstr, marker_type type, void *id, co } /* Latency profiler API implementation. */ -void -grpc_timer_add_mark (int tag, const char *tagstr, void *id, const char *file, int line) -{ - if (tag < GRPC_PTAG_IGNORE_THRESHOLD) - { - grpc_timers_log_add (tag, tagstr, MARK, id, file, line); - } +void grpc_timer_add_mark(int tag, const char *tagstr, void *id, + const char *file, int line) { + if (tag < GRPC_PTAG_IGNORE_THRESHOLD) { + grpc_timers_log_add(tag, tagstr, MARK, id, file, line); + } } -void -grpc_timer_add_important_mark (int tag, const char *tagstr, void *id, const char *file, int line) -{ - if (tag < GRPC_PTAG_IGNORE_THRESHOLD) - { - grpc_timers_log_add (tag, tagstr, IMPORTANT, id, file, line); - } +void grpc_timer_add_important_mark(int tag, const char *tagstr, void *id, + const char *file, int line) { + if (tag < GRPC_PTAG_IGNORE_THRESHOLD) { + grpc_timers_log_add(tag, tagstr, IMPORTANT, id, file, line); + } } -void -grpc_timer_begin (int tag, const char *tagstr, void *id, const char *file, int line) -{ - if (tag < GRPC_PTAG_IGNORE_THRESHOLD) - { - grpc_timers_log_add (tag, tagstr, BEGIN, id, file, line); - } +void grpc_timer_begin(int tag, const char *tagstr, void *id, const char *file, + int line) { + if (tag < GRPC_PTAG_IGNORE_THRESHOLD) { + grpc_timers_log_add(tag, tagstr, BEGIN, id, file, line); + } } -void -grpc_timer_end (int tag, const char *tagstr, void *id, const char *file, int line) -{ - if (tag < GRPC_PTAG_IGNORE_THRESHOLD) - { - grpc_timers_log_add (tag, tagstr, END, id, file, line); - } +void grpc_timer_end(int tag, const char *tagstr, void *id, const char *file, + int line) { + if (tag < GRPC_PTAG_IGNORE_THRESHOLD) { + grpc_timers_log_add(tag, tagstr, END, id, file, line); + } } /* Basic profiler specific API functions. */ -void -grpc_timers_global_init (void) -{ -} +void grpc_timers_global_init(void) {} -void -grpc_timers_global_destroy (void) -{ -} +void grpc_timers_global_destroy(void) {} -#else /* !GRPC_BASIC_PROFILER */ -void -grpc_timers_global_init (void) -{ -} +#else /* !GRPC_BASIC_PROFILER */ +void grpc_timers_global_init(void) {} -void -grpc_timers_global_destroy (void) -{ -} +void grpc_timers_global_destroy(void) {} #endif /* GRPC_BASIC_PROFILER */ diff --git a/src/core/profiling/stap_timers.c b/src/core/profiling/stap_timers.c index f284e32433..6868a674a9 100644 --- a/src/core/profiling/stap_timers.c +++ b/src/core/profiling/stap_timers.c @@ -42,28 +42,24 @@ #include "src/core/profiling/stap_probes.h" /* Latency profiler API implementation. */ -void -grpc_timer_add_mark (int tag, const char *tagstr, void *id, const char *file, int line) -{ - _STAP_ADD_MARK (tag); +void grpc_timer_add_mark(int tag, const char *tagstr, void *id, + const char *file, int line) { + _STAP_ADD_MARK(tag); } -void -grpc_timer_add_important_mark (int tag, const char *tagstr, void *id, const char *file, int line) -{ - _STAP_ADD_IMPORTANT_MARK (tag); +void grpc_timer_add_important_mark(int tag, const char *tagstr, void *id, + const char *file, int line) { + _STAP_ADD_IMPORTANT_MARK(tag); } -void -grpc_timer_begin (int tag, const char *tagstr, void *id, const char *file, int line) -{ - _STAP_TIMING_NS_BEGIN (tag); +void grpc_timer_begin(int tag, const char *tagstr, void *id, const char *file, + int line) { + _STAP_TIMING_NS_BEGIN(tag); } -void -grpc_timer_end (int tag, const char *tagstr, void *id, const char *file, int line) -{ - _STAP_TIMING_NS_END (tag); +void grpc_timer_end(int tag, const char *tagstr, void *id, const char *file, + int line) { + _STAP_TIMING_NS_END(tag); } #endif /* GRPC_STAP_PROFILER */ diff --git a/src/core/profiling/timers.h b/src/core/profiling/timers.h index 34929d8217..a70520408c 100644 --- a/src/core/profiling/timers.h +++ b/src/core/profiling/timers.h @@ -35,49 +35,51 @@ #define GRPC_CORE_PROFILING_TIMERS_H #ifdef __cplusplus -extern "C" -{ +extern "C" { #endif - void grpc_timers_global_init (void); - void grpc_timers_global_destroy (void); - - void grpc_timer_add_mark (int tag, const char *tagstr, void *id, const char *file, int line); - void grpc_timer_add_important_mark (int tag, const char *tagstr, void *id, const char *file, int line); - void grpc_timer_begin (int tag, const char *tagstr, void *id, const char *file, int line); - void grpc_timer_end (int tag, const char *tagstr, void *id, const char *file, int line); - - enum grpc_profiling_tags - { - /* Any GRPC_PTAG_* >= than the threshold won't generate any profiling mark. */ - GRPC_PTAG_IGNORE_THRESHOLD = 1000000, - - /* Re. Protos. */ - GRPC_PTAG_PROTO_SERIALIZE = 100 + GRPC_PTAG_IGNORE_THRESHOLD, - GRPC_PTAG_PROTO_DESERIALIZE = 101 + GRPC_PTAG_IGNORE_THRESHOLD, - - /* Re. sockets. */ - GRPC_PTAG_HANDLE_READ = 200 + GRPC_PTAG_IGNORE_THRESHOLD, - GRPC_PTAG_SENDMSG = 201 + GRPC_PTAG_IGNORE_THRESHOLD, - GRPC_PTAG_RECVMSG = 202 + GRPC_PTAG_IGNORE_THRESHOLD, - GRPC_PTAG_POLL_FINISHED = 203 + GRPC_PTAG_IGNORE_THRESHOLD, - GRPC_PTAG_TCP_CB_WRITE = 204 + GRPC_PTAG_IGNORE_THRESHOLD, - GRPC_PTAG_TCP_WRITE = 205 + GRPC_PTAG_IGNORE_THRESHOLD, - GRPC_PTAG_CALL_ON_DONE_RECV = 206 + GRPC_PTAG_IGNORE_THRESHOLD, - - /* C++ */ - GRPC_PTAG_CPP_CALL_CREATED = 300 + GRPC_PTAG_IGNORE_THRESHOLD, - GRPC_PTAG_CPP_PERFORM_OPS = 301 + GRPC_PTAG_IGNORE_THRESHOLD, - - /* Transports */ - GRPC_PTAG_HTTP2_UNLOCK = 401 + GRPC_PTAG_IGNORE_THRESHOLD, - GRPC_PTAG_HTTP2_UNLOCK_CLEANUP = 402 + GRPC_PTAG_IGNORE_THRESHOLD, - - /* > 1024 Unassigned reserved. For any miscellaneous use. - * Use addition to generate tags from this base or take advantage of the 10 - * zero'd bits for OR-ing. */ - GRPC_PTAG_OTHER_BASE = 1024 - }; +void grpc_timers_global_init(void); +void grpc_timers_global_destroy(void); + +void grpc_timer_add_mark(int tag, const char *tagstr, void *id, + const char *file, int line); +void grpc_timer_add_important_mark(int tag, const char *tagstr, void *id, + const char *file, int line); +void grpc_timer_begin(int tag, const char *tagstr, void *id, const char *file, + int line); +void grpc_timer_end(int tag, const char *tagstr, void *id, const char *file, + int line); + +enum grpc_profiling_tags { + /* Any GRPC_PTAG_* >= than the threshold won't generate any profiling mark. */ + GRPC_PTAG_IGNORE_THRESHOLD = 1000000, + + /* Re. Protos. */ + GRPC_PTAG_PROTO_SERIALIZE = 100 + GRPC_PTAG_IGNORE_THRESHOLD, + GRPC_PTAG_PROTO_DESERIALIZE = 101 + GRPC_PTAG_IGNORE_THRESHOLD, + + /* Re. sockets. */ + GRPC_PTAG_HANDLE_READ = 200 + GRPC_PTAG_IGNORE_THRESHOLD, + GRPC_PTAG_SENDMSG = 201 + GRPC_PTAG_IGNORE_THRESHOLD, + GRPC_PTAG_RECVMSG = 202 + GRPC_PTAG_IGNORE_THRESHOLD, + GRPC_PTAG_POLL_FINISHED = 203 + GRPC_PTAG_IGNORE_THRESHOLD, + GRPC_PTAG_TCP_CB_WRITE = 204 + GRPC_PTAG_IGNORE_THRESHOLD, + GRPC_PTAG_TCP_WRITE = 205 + GRPC_PTAG_IGNORE_THRESHOLD, + GRPC_PTAG_CALL_ON_DONE_RECV = 206 + GRPC_PTAG_IGNORE_THRESHOLD, + + /* C++ */ + GRPC_PTAG_CPP_CALL_CREATED = 300 + GRPC_PTAG_IGNORE_THRESHOLD, + GRPC_PTAG_CPP_PERFORM_OPS = 301 + GRPC_PTAG_IGNORE_THRESHOLD, + + /* Transports */ + GRPC_PTAG_HTTP2_UNLOCK = 401 + GRPC_PTAG_IGNORE_THRESHOLD, + GRPC_PTAG_HTTP2_UNLOCK_CLEANUP = 402 + GRPC_PTAG_IGNORE_THRESHOLD, + + /* > 1024 Unassigned reserved. For any miscellaneous use. + * Use addition to generate tags from this base or take advantage of the 10 + * zero'd bits for OR-ing. */ + GRPC_PTAG_OTHER_BASE = 1024 +}; #if !(defined(GRPC_STAP_PROFILER) + defined(GRPC_BASIC_PROFILER)) /* No profiling. No-op all the things. */ @@ -97,7 +99,7 @@ extern "C" do { \ } while (0) -#else /* at least one profiler requested... */ +#else /* at least one profiler requested... */ /* ... hopefully only one. */ #if defined(GRPC_STAP_PROFILER) && defined(GRPC_BASIC_PROFILER) #error "GRPC_STAP_PROFILER and GRPC_BASIC_PROFILER are mutually exclusive." @@ -129,16 +131,16 @@ extern "C" #ifdef GRPC_STAP_PROFILER /* Empty placeholder for now. */ -#endif /* GRPC_STAP_PROFILER */ +#endif /* GRPC_STAP_PROFILER */ #ifdef GRPC_BASIC_PROFILER /* Empty placeholder for now. */ -#endif /* GRPC_BASIC_PROFILER */ +#endif /* GRPC_BASIC_PROFILER */ -#endif /* at least one profiler requested. */ +#endif /* at least one profiler requested. */ #ifdef __cplusplus } #endif -#endif /* GRPC_CORE_PROFILING_TIMERS_H */ +#endif /* GRPC_CORE_PROFILING_TIMERS_H */ |