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 AddExpectedTicks(int32 expected); 70 virtual void AddDroppedTicks(int32 dropped); 71 virtual void PrintResults( 72 ImageProfileResultContainer* container); 73 74 virtual status_t GetImageProfileResult(SharedImage* image, 75 image_id id, 76 ImageProfileResult*& _imageResult); 77 78 void PrintSummaryResults(); 79 80 private: 81 typedef BOpenHashTable<SummaryImageHashDefinition> ImageTable; 82 83 private: 84 // ImageProfileResultContainer 85 virtual int32 CountImages() const; 86 virtual ImageProfileResult* VisitImages(Visitor& visitor) const; 87 virtual ImageProfileResult* FindImage(addr_t address, 88 addr_t& _loadDelta) const; 89 90 private: 91 ProfileResult* fResult; 92 ImageTable fImages; 93 image_id fNextImageID; 94 }; 95 96 97 #endif // SUMMARY_PROFILE_RESULT_H 98