mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 20:52:45 +00:00 
			
		
		
		
	Profiler: Move everything into the "Profiler" namespace
This commit is contained in:
		
							parent
							
								
									d29e2dd2d7
								
							
						
					
					
						commit
						dbbc6096a9
					
				
					 17 changed files with 66 additions and 0 deletions
				
			
		|  | @ -14,6 +14,8 @@ | ||||||
| #include <ctype.h> | #include <ctype.h> | ||||||
| #include <stdio.h> | #include <stdio.h> | ||||||
| 
 | 
 | ||||||
|  | namespace Profiler { | ||||||
|  | 
 | ||||||
| static const Gfx::Bitmap& heat_gradient() | static const Gfx::Bitmap& heat_gradient() | ||||||
| { | { | ||||||
|     static RefPtr<Gfx::Bitmap> bitmap; |     static RefPtr<Gfx::Bitmap> bitmap; | ||||||
|  | @ -185,3 +187,5 @@ void DisassemblyModel::update() | ||||||
| { | { | ||||||
|     did_update(); |     did_update(); | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | } | ||||||
|  |  | ||||||
|  | @ -9,6 +9,8 @@ | ||||||
| #include <LibGUI/Model.h> | #include <LibGUI/Model.h> | ||||||
| #include <LibX86/Instruction.h> | #include <LibX86/Instruction.h> | ||||||
| 
 | 
 | ||||||
|  | namespace Profiler { | ||||||
|  | 
 | ||||||
| class Profile; | class Profile; | ||||||
| class ProfileNode; | class ProfileNode; | ||||||
| 
 | 
 | ||||||
|  | @ -53,3 +55,5 @@ private: | ||||||
| 
 | 
 | ||||||
|     Vector<InstructionData> m_instructions; |     Vector<InstructionData> m_instructions; | ||||||
| }; | }; | ||||||
|  | 
 | ||||||
|  | } | ||||||
|  |  | ||||||
|  | @ -9,6 +9,8 @@ | ||||||
| #include <AK/StringBuilder.h> | #include <AK/StringBuilder.h> | ||||||
| #include <stdio.h> | #include <stdio.h> | ||||||
| 
 | 
 | ||||||
|  | namespace Profiler { | ||||||
|  | 
 | ||||||
| IndividualSampleModel::IndividualSampleModel(Profile& profile, size_t event_index) | IndividualSampleModel::IndividualSampleModel(Profile& profile, size_t event_index) | ||||||
|     : m_profile(profile) |     : m_profile(profile) | ||||||
|     , m_event_index(event_index) |     , m_event_index(event_index) | ||||||
|  | @ -69,3 +71,5 @@ void IndividualSampleModel::update() | ||||||
| { | { | ||||||
|     did_update(Model::InvalidateAllIndices); |     did_update(Model::InvalidateAllIndices); | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | } | ||||||
|  |  | ||||||
|  | @ -8,6 +8,8 @@ | ||||||
| 
 | 
 | ||||||
| #include <LibGUI/Model.h> | #include <LibGUI/Model.h> | ||||||
| 
 | 
 | ||||||
|  | namespace Profiler { | ||||||
|  | 
 | ||||||
| class Profile; | class Profile; | ||||||
| 
 | 
 | ||||||
| class IndividualSampleModel final : public GUI::Model { | class IndividualSampleModel final : public GUI::Model { | ||||||
|  | @ -38,3 +40,5 @@ private: | ||||||
|     Profile& m_profile; |     Profile& m_profile; | ||||||
|     const size_t m_event_index { 0 }; |     const size_t m_event_index { 0 }; | ||||||
| }; | }; | ||||||
|  | 
 | ||||||
|  | } | ||||||
|  |  | ||||||
|  | @ -6,6 +6,8 @@ | ||||||
| 
 | 
 | ||||||
| #include "Process.h" | #include "Process.h" | ||||||
| 
 | 
 | ||||||
|  | namespace Profiler { | ||||||
|  | 
 | ||||||
| Thread* Process::find_thread(pid_t tid, u64 timestamp) | Thread* Process::find_thread(pid_t tid, u64 timestamp) | ||||||
| { | { | ||||||
|     auto it = threads.find(tid); |     auto it = threads.find(tid); | ||||||
|  | @ -115,3 +117,5 @@ const LibraryMetadata::Library* LibraryMetadata::library_containing(FlatPtr ptr) | ||||||
|     } |     } | ||||||
|     return nullptr; |     return nullptr; | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | } | ||||||
|  |  | ||||||
|  | @ -12,6 +12,8 @@ | ||||||
| #include <AK/Vector.h> | #include <AK/Vector.h> | ||||||
| #include <LibELF/Image.h> | #include <LibELF/Image.h> | ||||||
| 
 | 
 | ||||||
|  | namespace Profiler { | ||||||
|  | 
 | ||||||
| struct MappedObject { | struct MappedObject { | ||||||
|     NonnullRefPtr<MappedFile> file; |     NonnullRefPtr<MappedFile> file; | ||||||
|     ELF::Image elf; |     ELF::Image elf; | ||||||
|  | @ -66,3 +68,5 @@ struct Process { | ||||||
|         return timestamp >= start_valid && (end_valid == 0 || timestamp <= end_valid); |         return timestamp >= start_valid && (end_valid == 0 || timestamp <= end_valid); | ||||||
|     } |     } | ||||||
| }; | }; | ||||||
|  | 
 | ||||||
|  | } | ||||||
|  |  | ||||||
|  | @ -10,6 +10,8 @@ | ||||||
| #include <LibGUI/ItemListModel.h> | #include <LibGUI/ItemListModel.h> | ||||||
| #include <LibGUI/Label.h> | #include <LibGUI/Label.h> | ||||||
| 
 | 
 | ||||||
|  | namespace Profiler { | ||||||
|  | 
 | ||||||
| ProcessPickerWidget::ProcessPickerWidget(Profile& profile) | ProcessPickerWidget::ProcessPickerWidget(Profile& profile) | ||||||
|     : m_profile(profile) |     : m_profile(profile) | ||||||
| { | { | ||||||
|  | @ -46,3 +48,5 @@ ProcessPickerWidget::ProcessPickerWidget(Profile& profile) | ||||||
| ProcessPickerWidget::~ProcessPickerWidget() | ProcessPickerWidget::~ProcessPickerWidget() | ||||||
| { | { | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | } | ||||||
|  |  | ||||||
|  | @ -9,6 +9,8 @@ | ||||||
| #include <LibGUI/ComboBox.h> | #include <LibGUI/ComboBox.h> | ||||||
| #include <LibGUI/Frame.h> | #include <LibGUI/Frame.h> | ||||||
| 
 | 
 | ||||||
|  | namespace Profiler { | ||||||
|  | 
 | ||||||
| class Profile; | class Profile; | ||||||
| 
 | 
 | ||||||
| class ProcessPickerWidget final : public GUI::Frame { | class ProcessPickerWidget final : public GUI::Frame { | ||||||
|  | @ -29,3 +31,5 @@ private: | ||||||
| 
 | 
 | ||||||
|     RefPtr<GUI::ComboBox> m_process_combo; |     RefPtr<GUI::ComboBox> m_process_combo; | ||||||
| }; | }; | ||||||
|  | 
 | ||||||
|  | } | ||||||
|  |  | ||||||
|  | @ -18,6 +18,8 @@ | ||||||
| #include <LibELF/Image.h> | #include <LibELF/Image.h> | ||||||
| #include <sys/stat.h> | #include <sys/stat.h> | ||||||
| 
 | 
 | ||||||
|  | namespace Profiler { | ||||||
|  | 
 | ||||||
| static void sort_profile_nodes(Vector<NonnullRefPtr<ProfileNode>>& nodes) | static void sort_profile_nodes(Vector<NonnullRefPtr<ProfileNode>>& nodes) | ||||||
| { | { | ||||||
|     quick_sort(nodes.begin(), nodes.end(), [](auto& a, auto& b) { |     quick_sort(nodes.begin(), nodes.end(), [](auto& a, auto& b) { | ||||||
|  | @ -459,3 +461,5 @@ const Process* ProfileNode::process(Profile& profile, u64 timestamp) const | ||||||
| { | { | ||||||
|     return profile.find_process(m_pid, timestamp); |     return profile.find_process(m_pid, timestamp); | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | } | ||||||
|  |  | ||||||
|  | @ -20,6 +20,8 @@ | ||||||
| #include <LibGUI/Forward.h> | #include <LibGUI/Forward.h> | ||||||
| #include <LibGUI/ModelIndex.h> | #include <LibGUI/ModelIndex.h> | ||||||
| 
 | 
 | ||||||
|  | namespace Profiler { | ||||||
|  | 
 | ||||||
| class DisassemblyModel; | class DisassemblyModel; | ||||||
| class Profile; | class Profile; | ||||||
| class ProfileModel; | class ProfileModel; | ||||||
|  | @ -229,3 +231,5 @@ private: | ||||||
|     bool m_show_top_functions { false }; |     bool m_show_top_functions { false }; | ||||||
|     bool m_show_percentages { false }; |     bool m_show_percentages { false }; | ||||||
| }; | }; | ||||||
|  | 
 | ||||||
|  | } | ||||||
|  |  | ||||||
|  | @ -10,6 +10,8 @@ | ||||||
| #include <ctype.h> | #include <ctype.h> | ||||||
| #include <stdio.h> | #include <stdio.h> | ||||||
| 
 | 
 | ||||||
|  | namespace Profiler { | ||||||
|  | 
 | ||||||
| ProfileModel::ProfileModel(Profile& profile) | ProfileModel::ProfileModel(Profile& profile) | ||||||
|     : m_profile(profile) |     : m_profile(profile) | ||||||
| { | { | ||||||
|  | @ -129,3 +131,5 @@ void ProfileModel::update() | ||||||
| { | { | ||||||
|     did_update(Model::InvalidateAllIndices); |     did_update(Model::InvalidateAllIndices); | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | } | ||||||
|  |  | ||||||
|  | @ -8,6 +8,8 @@ | ||||||
| 
 | 
 | ||||||
| #include <LibGUI/Model.h> | #include <LibGUI/Model.h> | ||||||
| 
 | 
 | ||||||
|  | namespace Profiler { | ||||||
|  | 
 | ||||||
| class Profile; | class Profile; | ||||||
| 
 | 
 | ||||||
| class ProfileModel final : public GUI::Model { | class ProfileModel final : public GUI::Model { | ||||||
|  | @ -44,3 +46,5 @@ private: | ||||||
|     GUI::Icon m_user_frame_icon; |     GUI::Icon m_user_frame_icon; | ||||||
|     GUI::Icon m_kernel_frame_icon; |     GUI::Icon m_kernel_frame_icon; | ||||||
| }; | }; | ||||||
|  | 
 | ||||||
|  | } | ||||||
|  |  | ||||||
|  | @ -9,6 +9,8 @@ | ||||||
| #include <LibGUI/Painter.h> | #include <LibGUI/Painter.h> | ||||||
| #include <LibGfx/Font.h> | #include <LibGfx/Font.h> | ||||||
| 
 | 
 | ||||||
|  | namespace Profiler { | ||||||
|  | 
 | ||||||
| ProfileTimelineWidget::ProfileTimelineWidget(Profile& profile) | ProfileTimelineWidget::ProfileTimelineWidget(Profile& profile) | ||||||
|     : m_profile(profile) |     : m_profile(profile) | ||||||
| { | { | ||||||
|  | @ -121,3 +123,5 @@ void ProfileTimelineWidget::mouseup_event(GUI::MouseEvent& event) | ||||||
|     if (m_select_start_time == m_select_end_time) |     if (m_select_start_time == m_select_end_time) | ||||||
|         m_profile.clear_timestamp_filter_range(); |         m_profile.clear_timestamp_filter_range(); | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | } | ||||||
|  |  | ||||||
|  | @ -8,6 +8,8 @@ | ||||||
| 
 | 
 | ||||||
| #include <LibGUI/Frame.h> | #include <LibGUI/Frame.h> | ||||||
| 
 | 
 | ||||||
|  | namespace Profiler { | ||||||
|  | 
 | ||||||
| class Profile; | class Profile; | ||||||
| 
 | 
 | ||||||
| class ProfileTimelineWidget final : public GUI::Frame { | class ProfileTimelineWidget final : public GUI::Frame { | ||||||
|  | @ -32,3 +34,5 @@ private: | ||||||
|     u64 m_select_end_time { 0 }; |     u64 m_select_end_time { 0 }; | ||||||
|     u64 m_hover_time { 0 }; |     u64 m_hover_time { 0 }; | ||||||
| }; | }; | ||||||
|  | 
 | ||||||
|  | } | ||||||
|  |  | ||||||
|  | @ -9,6 +9,8 @@ | ||||||
| #include <AK/StringBuilder.h> | #include <AK/StringBuilder.h> | ||||||
| #include <stdio.h> | #include <stdio.h> | ||||||
| 
 | 
 | ||||||
|  | namespace Profiler { | ||||||
|  | 
 | ||||||
| SamplesModel::SamplesModel(Profile& profile) | SamplesModel::SamplesModel(Profile& profile) | ||||||
|     : m_profile(profile) |     : m_profile(profile) | ||||||
| { | { | ||||||
|  | @ -91,3 +93,5 @@ void SamplesModel::update() | ||||||
| { | { | ||||||
|     did_update(Model::InvalidateAllIndices); |     did_update(Model::InvalidateAllIndices); | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | } | ||||||
|  |  | ||||||
|  | @ -8,6 +8,8 @@ | ||||||
| 
 | 
 | ||||||
| #include <LibGUI/Model.h> | #include <LibGUI/Model.h> | ||||||
| 
 | 
 | ||||||
|  | namespace Profiler { | ||||||
|  | 
 | ||||||
| class Profile; | class Profile; | ||||||
| 
 | 
 | ||||||
| class SamplesModel final : public GUI::Model { | class SamplesModel final : public GUI::Model { | ||||||
|  | @ -43,3 +45,5 @@ private: | ||||||
|     GUI::Icon m_user_frame_icon; |     GUI::Icon m_user_frame_icon; | ||||||
|     GUI::Icon m_kernel_frame_icon; |     GUI::Icon m_kernel_frame_icon; | ||||||
| }; | }; | ||||||
|  | 
 | ||||||
|  | } | ||||||
|  |  | ||||||
|  | @ -32,6 +32,8 @@ | ||||||
| #include <serenity.h> | #include <serenity.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
| 
 | 
 | ||||||
|  | using namespace Profiler; | ||||||
|  | 
 | ||||||
| static bool generate_profile(pid_t& pid); | static bool generate_profile(pid_t& pid); | ||||||
| 
 | 
 | ||||||
| int main(int argc, char** argv) | int main(int argc, char** argv) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling