Perfetto tracing in load tester
This commit is contained in:
@@ -13,6 +13,8 @@ set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -Wall -Wextra")
|
|||||||
set(CMAKE_CXX_FLAGS_RELEASE
|
set(CMAKE_CXX_FLAGS_RELEASE
|
||||||
"-g -O3 -Wall -Wextra -DNDEBUG -fno-omit-frame-pointer")
|
"-g -O3 -Wall -Wextra -DNDEBUG -fno-omit-frame-pointer")
|
||||||
|
|
||||||
|
add_subdirectory(third_party)
|
||||||
|
|
||||||
find_package(Threads REQUIRED)
|
find_package(Threads REQUIRED)
|
||||||
|
|
||||||
include(FetchContent)
|
include(FetchContent)
|
||||||
@@ -202,7 +204,7 @@ target_include_directories(debug_arena PRIVATE src)
|
|||||||
|
|
||||||
# Load tester
|
# Load tester
|
||||||
add_executable(load_tester tools/load_tester.cpp)
|
add_executable(load_tester tools/load_tester.cpp)
|
||||||
target_link_libraries(load_tester Threads::Threads llhttp_static)
|
target_link_libraries(load_tester Threads::Threads llhttp_static perfetto)
|
||||||
|
|
||||||
add_test(NAME arena_allocator_tests COMMAND test_arena_allocator)
|
add_test(NAME arena_allocator_tests COMMAND test_arena_allocator)
|
||||||
add_test(NAME commit_request_tests COMMAND test_commit_request)
|
add_test(NAME commit_request_tests COMMAND test_commit_request)
|
||||||
|
|||||||
@@ -27,6 +27,21 @@
|
|||||||
#define __has_feature(x) 0
|
#define __has_feature(x) 0
|
||||||
#endif
|
#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 {
|
namespace {
|
||||||
|
|
||||||
double now() {
|
double now() {
|
||||||
@@ -249,6 +264,8 @@ struct Connection {
|
|||||||
request = request.substr(w, request.size() - w);
|
request = request.substr(w, request.size() - w);
|
||||||
if (request.empty()) {
|
if (request.empty()) {
|
||||||
++requestsSent;
|
++requestsSent;
|
||||||
|
TRACE_EVENT("network", "send request",
|
||||||
|
perfetto::Flow::Global(currentRequestId));
|
||||||
if (requestsSent == g_config.requests_per_connection) {
|
if (requestsSent == g_config.requests_per_connection) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -290,6 +307,8 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
int on_message_complete() {
|
int on_message_complete() {
|
||||||
|
TRACE_EVENT("network", "receive response",
|
||||||
|
perfetto::Flow::Global(responseId));
|
||||||
responseId = 0;
|
responseId = 0;
|
||||||
++responsesReceived;
|
++responsesReceived;
|
||||||
initRequest();
|
initRequest();
|
||||||
@@ -455,6 +474,13 @@ void parse_args(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int main(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);
|
parse_args(argc, argv);
|
||||||
|
|
||||||
// Print configuration
|
// Print configuration
|
||||||
|
|||||||
Reference in New Issue
Block a user