ladybird/DevTools/ProfileViewer/main.cpp
Andreas Kling 19d8c675f1 ProfileViewer: Begin work on a visualization tool for profiles :^)
We begin with a simple treeview that shows a recorded profile.
To record and view a profile of a process with <PID>, simply do this:

$ profile <PID> on
... wait while PID does something interesting ...
$ profile <PID> off
$ cat /proc/profile > my-profile.prof
$ ProfileViewer my-profile.prof
2019-12-12 22:01:06 +01:00

33 lines
773 B
C++

#include "Profile.h"
#include <LibGUI/GApplication.h>
#include <LibGUI/GTreeView.h>
#include <LibGUI/GWindow.h>
#include <stdio.h>
int main(int argc, char** argv)
{
if (argc != 2) {
printf("usage: %s <profile-file>\n", argv[0]);
return 0;
}
auto profile = Profile::load_from_file(argv[1]);
if (!profile) {
fprintf(stderr, "Unable to load profile '%s'\n", argv[1]);
return 1;
}
GApplication app(argc, argv);
auto window = GWindow::construct();
window->set_title("ProfileViewer");
window->set_rect(100, 100, 800, 600);
auto tree_view = GTreeView::construct(nullptr);
tree_view->set_model(profile->model());
window->set_main_widget(tree_view);
window->show();
return app.exec();
}