1 /* 2 * Copyright 2010, Ingo Weinhold, ingo_weinhold@gmx.de. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef SUMMARY_PROFILE_RESULT_H 6 #define SUMMARY_PROFILE_RESULT_H 7 8 9 #include <util/OpenHashTable.h> 10 11 #include "ProfileResult.h" 12 13 14 class SummaryImage { 15 public: 16 SummaryImage(ImageProfileResult* result); 17 ~SummaryImage(); 18 19 ImageProfileResult* Result() const { return fResult; } 20 SharedImage* GetImage() const { return fResult->GetImage(); } 21 22 SummaryImage*& HashNext() { return fHashNext; } 23 24 private: 25 ImageProfileResult* fResult; 26 SummaryImage* fHashNext; 27 }; 28 29 30 struct SummaryImageHashDefinition { 31 typedef SharedImage* KeyType; 32 typedef SummaryImage ValueType; 33 34 size_t HashKey(SharedImage* key) const 35 { 36 return (addr_t)key / (2 * sizeof(void*)); 37 } 38 39 size_t Hash(SummaryImage* value) const 40 { 41 return HashKey(value->GetImage()); 42 } 43 44 bool Compare(SharedImage* key, SummaryImage* value) const 45 { 46 return value->GetImage() == key; 47 } 48 49 SummaryImage*& GetLink(SummaryImage* value) const 50 { 51 return value->HashNext(); 52 } 53 }; 54 55 56 class SummaryProfileResult : public ProfileResult, 57 private ImageProfileResultContainer { 58 public: 59 SummaryProfileResult(ProfileResult* result); 60 virtual ~SummaryProfileResult(); 61 62 virtual status_t Init(ProfiledEntity* entity); 63 64 virtual void SetInterval(bigtime_t interval); 65 66 virtual void AddSamples( 67 ImageProfileResultContainer* container, 68 addr_t* samples, int32 sampleCount); 69 virtual void AddDroppedTicks(int32 dropped); 70 virtual void PrintResults( 71 ImageProfileResultContainer* container); 72 73 virtual status_t GetImageProfileResult(SharedImage* image, 74 image_id id, 75 ImageProfileResult*& _imageResult); 76 77 void PrintSummaryResults(); 78 79 private: 80 typedef BOpenHashTable<SummaryImageHashDefinition> ImageTable; 81 82 private: 83 // ImageProfileResultContainer 84 virtual int32 CountImages() const; 85 virtual ImageProfileResult* VisitImages(Visitor& visitor) const; 86 virtual ImageProfileResult* FindImage(addr_t address, 87 addr_t& _loadDelta) const; 88 89 private: 90 ProfileResult* fResult; 91 ImageTable fImages; 92 image_id fNextImageID; 93 }; 94 95 96 #endif // SUMMARY_PROFILE_RESULT_H 97