2 * Copyright 2010, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
7 #include "SummaryProfileResult.h"
12 // #pragma mark - SummaryImage
15 SummaryImage::SummaryImage(ImageProfileResult
* result
)
19 fResult
->AcquireReference();
23 SummaryImage::~SummaryImage()
25 fResult
->ReleaseReference();
29 // #pragma mark - SummaryProfileResult
32 SummaryProfileResult::SummaryProfileResult(ProfileResult
* result
)
37 fResult
->AcquireReference();
41 SummaryProfileResult::~SummaryProfileResult()
43 fResult
->ReleaseReference();
48 SummaryProfileResult::SetInterval(bigtime_t interval
)
50 ProfileResult::SetInterval(interval
);
51 fResult
->SetInterval(interval
);
56 SummaryProfileResult::Init(ProfiledEntity
* entity
)
58 status_t error
= ProfileResult::Init(entity
);
62 error
= fImages
.Init();
71 SummaryProfileResult::AddSamples(ImageProfileResultContainer
* container
,
72 addr_t
* samples
, int32 sampleCount
)
74 fResult
->AddSamples(container
, samples
, sampleCount
);
79 SummaryProfileResult::AddDroppedTicks(int32 dropped
)
81 fResult
->AddDroppedTicks(dropped
);
86 SummaryProfileResult::PrintResults(ImageProfileResultContainer
* container
)
88 // This is called for individual threads. We only print results in
89 // PrintSummaryResults(), though.
94 SummaryProfileResult::PrintSummaryResults()
96 fResult
->PrintResults(this);
101 SummaryProfileResult::GetImageProfileResult(SharedImage
* image
, image_id id
,
102 ImageProfileResult
*& _imageResult
)
104 // Check whether we do already know the image.
105 SummaryImage
* summaryImage
= fImages
.Lookup(image
);
106 if (summaryImage
== NULL
) {
108 ImageProfileResult
* imageResult
;
109 status_t error
= fResult
->GetImageProfileResult(image
, fNextImageID
++,
114 BReference
<ImageProfileResult
> imageResultReference(imageResult
, true);
116 summaryImage
= new(std::nothrow
) SummaryImage(imageResult
);
117 if (summaryImage
== NULL
)
120 fImages
.Insert(summaryImage
);
123 _imageResult
= summaryImage
->Result();
124 _imageResult
->AcquireReference();
131 SummaryProfileResult::CountImages() const
133 return fImages
.CountElements();
138 SummaryProfileResult::VisitImages(Visitor
& visitor
) const
140 for (ImageTable::Iterator it
= fImages
.GetIterator();
141 SummaryImage
* image
= it
.Next();) {
142 if (visitor
.VisitImage(image
->Result()))
143 return image
->Result();
151 SummaryProfileResult::FindImage(addr_t address
, addr_t
& _loadDelta
) const
153 // We cannot and don't need to implement this. It's only relevant for
154 // AddSamples(), where we use the caller's container implementation.