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
This commit is contained in:
Andreas Kling 2019-12-12 22:01:06 +01:00
commit 19d8c675f1
Notes: sideshowbarker 2024-07-19 10:52:43 +09:00
8 changed files with 350 additions and 0 deletions

View file

@ -0,0 +1,33 @@
#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();
}