Perfetto tracing in load tester
This commit is contained in:
@@ -27,6 +27,21 @@
|
||||
#define __has_feature(x) 0
|
||||
#endif
|
||||
|
||||
#define ENABLE_PERFETTO 1
|
||||
|
||||
#if ENABLE_PERFETTO
|
||||
#include <perfetto.h>
|
||||
#else
|
||||
#define PERFETTO_DEFINE_CATEGORIES(...)
|
||||
#define PERFETTO_TRACK_EVENT_STATIC_STORAGE(...)
|
||||
#define TRACE_EVENT(...)
|
||||
#endif
|
||||
|
||||
PERFETTO_DEFINE_CATEGORIES(
|
||||
perfetto::Category("network").SetDescription("Network"));
|
||||
|
||||
PERFETTO_TRACK_EVENT_STATIC_STORAGE();
|
||||
|
||||
namespace {
|
||||
|
||||
double now() {
|
||||
@@ -249,6 +264,8 @@ struct Connection {
|
||||
request = request.substr(w, request.size() - w);
|
||||
if (request.empty()) {
|
||||
++requestsSent;
|
||||
TRACE_EVENT("network", "send request",
|
||||
perfetto::Flow::Global(currentRequestId));
|
||||
if (requestsSent == g_config.requests_per_connection) {
|
||||
return true;
|
||||
}
|
||||
@@ -290,6 +307,8 @@ private:
|
||||
}
|
||||
|
||||
int on_message_complete() {
|
||||
TRACE_EVENT("network", "receive response",
|
||||
perfetto::Flow::Global(responseId));
|
||||
responseId = 0;
|
||||
++responsesReceived;
|
||||
initRequest();
|
||||
@@ -455,6 +474,13 @@ void parse_args(int argc, char *argv[]) {
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
#if ENABLE_PERFETTO
|
||||
perfetto::TracingInitArgs args;
|
||||
args.backends |= perfetto::kSystemBackend;
|
||||
perfetto::Tracing::Initialize(args);
|
||||
perfetto::TrackEvent::Register();
|
||||
#endif
|
||||
|
||||
parse_args(argc, argv);
|
||||
|
||||
// Print configuration
|
||||
|
||||
Reference in New Issue
Block a user