-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
178 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#pragma once | ||
#include "iobuf.h" | ||
|
||
#if MG_ENABLE_PROFILE | ||
struct mg_profitem { | ||
const char *name; | ||
uint32_t timestamp; | ||
}; | ||
|
||
#define MG_PROF_ADD(c, name_) \ | ||
do { \ | ||
struct mg_iobuf *io = &c->prof; \ | ||
struct mg_profitem *first = (struct mg_profitem *) io->buf; \ | ||
struct mg_profitem item = {name_, (uint32_t) mg_millis()}; \ | ||
if (io->len >= sizeof(*first)) item.timestamp -= first->timestamp; \ | ||
mg_iobuf_add(io, io->len, &item, sizeof(item)); \ | ||
} while (0) | ||
|
||
#define MG_PROF_INIT(c) \ | ||
do { \ | ||
mg_iobuf_init(&(c)->prof, 0, 256); \ | ||
MG_PROF_ADD((c), "init"); \ | ||
} while (0) | ||
|
||
#define MG_PROF_FREE(c) mg_iobuf_free(&(c)->prof) | ||
|
||
#define MG_PROF_DUMP(c) \ | ||
do { \ | ||
struct mg_iobuf *io = &c->prof; \ | ||
struct mg_profitem *p = (struct mg_profitem *) io->buf; \ | ||
struct mg_profitem *e = &p[io->len / sizeof(*p)]; \ | ||
MG_INFO(("%lu profile:", c->id)); \ | ||
while (p < e) { \ | ||
MG_INFO(("%5lx %s", (unsigned long) p->timestamp, p->name)); \ | ||
p++; \ | ||
} \ | ||
} while (0) | ||
|
||
#else | ||
#define MG_PROF_INIT(c) | ||
#define MG_PROF_FREE(c) | ||
#define MG_PROF_ADD(c, name) | ||
#define MG_PROF_DUMP(c) | ||
#endif |
Oops, something went wrong.