[haiku-commits] r34758 - haiku/trunk/src/apps/debuganalyzer/model

  • From: ingo_weinhold@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 23 Dec 2009 18:03:26 +0100 (CET)

Author: bonefish
Date: 2009-12-23 18:03:26 +0100 (Wed, 23 Dec 2009)
New Revision: 34758
Changeset: http://dev.haiku-os.org/changeset/34758/haiku

Modified:
   haiku/trunk/src/apps/debuganalyzer/model/Model.cpp
   haiku/trunk/src/apps/debuganalyzer/model/Model.h
Log:
Added IOOperation and IORequest accessors and support methods.


Modified: haiku/trunk/src/apps/debuganalyzer/model/Model.cpp
===================================================================
--- haiku/trunk/src/apps/debuganalyzer/model/Model.cpp  2009-12-23 16:43:51 UTC 
(rev 34757)
+++ haiku/trunk/src/apps/debuganalyzer/model/Model.cpp  2009-12-23 17:03:26 UTC 
(rev 34758)
@@ -78,6 +78,22 @@
 // #pragma mark - IORequest
 
 
+Model::IORequest::IORequest(
+       system_profiler_io_request_scheduled* scheduledEvent,
+       system_profiler_io_request_finished* finishedEvent, size_t 
operationCount)
+       :
+       scheduledEvent(scheduledEvent),
+       finishedEvent(finishedEvent),
+       operationCount(operationCount)
+{
+}
+
+
+Model::IORequest::~IORequest()
+{
+}
+
+
 /*static*/ Model::IORequest*
 Model::IORequest::Create(system_profiler_io_request_scheduled* scheduledEvent,
        system_profiler_io_request_finished* finishedEvent, size_t 
operationCount)
@@ -98,22 +114,6 @@
 }
 
 
-Model::IORequest::IORequest(
-       system_profiler_io_request_scheduled* scheduledEvent,
-       system_profiler_io_request_finished* finishedEvent, size_t 
operationCount)
-       :
-       scheduledEvent(scheduledEvent),
-       finishedEvent(finishedEvent),
-       operationCount(operationCount)
-{
-}
-
-
-Model::IORequest::~IORequest()
-{
-}
-
-
 // #pragma mark - IOScheduler
 
 
@@ -352,6 +352,25 @@
 }
 
 
+size_t
+Model::Thread::ClosestRequestStartIndex(nanotime_t minRequestStartTime) const
+{
+       size_t lower = 0;
+       size_t upper = fIORequestCount;
+       while (lower < upper) {
+               size_t mid = (lower + upper) / 2;
+               IORequest* request = fIORequests[mid];
+
+               if (request->ScheduledTime() < minRequestStartTime)
+                       lower = mid + 1;
+               else
+                       upper = mid;
+       }
+
+       return lower;
+}
+
+
 Model::ThreadWaitObjectGroup*
 Model::Thread::ThreadWaitObjectGroupFor(uint32 type, addr_t object) const
 {

Modified: haiku/trunk/src/apps/debuganalyzer/model/Model.h
===================================================================
--- haiku/trunk/src/apps/debuganalyzer/model/Model.h    2009-12-23 16:43:51 UTC 
(rev 34757)
+++ haiku/trunk/src/apps/debuganalyzer/model/Model.h    2009-12-23 17:03:26 UTC 
(rev 34758)
@@ -193,6 +193,15 @@
 
        static inline int                       CompareByTime(const 
IOOperation* a,
                                                                        const 
IOOperation* b);
+
+       inline  nanotime_t                      StartedTime() const;
+       inline  nanotime_t                      FinishedTime() const;
+       inline  bool                            IsFinished() const;
+       inline  off_t                           Offset() const;
+       inline  size_t                          Length() const;
+       inline  bool                            IsWrite() const;
+       inline  status_t                        Status() const;
+       inline  size_t                          BytesTransferred() const;
 };
 
 
@@ -202,6 +211,14 @@
        size_t                                                                  
operationCount;
        IOOperation                                                             
operations[0];
 
+                                                               IORequest(
+                                                                       
system_profiler_io_request_scheduled*
+                                                                               
scheduledEvent,
+                                                                       
system_profiler_io_request_finished*
+                                                                               
finishedEvent,
+                                                                       size_t 
operationCount);
+                                                               ~IORequest();
+
        static  IORequest*                      Create(
                                                                        
system_profiler_io_request_scheduled*
                                                                                
scheduledEvent,
@@ -210,19 +227,24 @@
                                                                        size_t 
operationCount);
                        void                            Delete();
 
+       inline  nanotime_t                      ScheduledTime() const;
+       inline  nanotime_t                      FinishedTime() const;
+       inline  bool                            IsFinished() const;
+       inline  int32                           Scheduler() const;
+       inline  off_t                           Offset() const;
+       inline  size_t                          Length() const;
+       inline  bool                            IsWrite() const;
+       inline  uint8                           Priority() const;
+       inline  status_t                        Status() const;
+       inline  size_t                          BytesTransferred() const;
+
+
        static inline bool                      TimeLess(const IORequest* a,
                                                                        const 
IORequest* b);
        static inline bool                      SchedulerTimeLess(const 
IORequest* a,
                                                                        const 
IORequest* b);
-
-private:
-                                                               IORequest(
-                                                                       
system_profiler_io_request_scheduled*
-                                                                               
scheduledEvent,
-                                                                       
system_profiler_io_request_finished*
-                                                                               
finishedEvent,
-                                                                       size_t 
operationCount);
-                                                               ~IORequest();
+       static inline int                       CompareSchedulerTime(const 
IORequest* a,
+                                                                       const 
IORequest* b);
 };
 
 
@@ -424,6 +446,12 @@
        inline  size_t                          CountIORequests() const;
                        void                            
SetIORequests(IORequest** requests,
                                                                        size_t 
requestCount);
+                       size_t                          
ClosestRequestStartIndex(
+                                                                       
nanotime_t minRequestStartTime) const;
+                                                                       // 
Returns the index of the first request
+                                                                       // with 
a start time >= minRequestStartTime.
+                                                                       // 
minRequestStartTime is absolute, not
+                                                                       // base 
time relative.
 
        inline  nanotime_t                      CreationTime() const;
        inline  nanotime_t                      DeletionTime() const;
@@ -702,6 +730,62 @@
 // #pragma mark - IOOperation
 
 
+nanotime_t
+Model::IOOperation::StartedTime() const
+{
+       return startedEvent->time;
+}
+
+
+nanotime_t
+Model::IOOperation::FinishedTime() const
+{
+       return finishedEvent != NULL ? finishedEvent->time : 0;
+}
+
+
+bool
+Model::IOOperation::IsFinished() const
+{
+       return finishedEvent != NULL;
+}
+
+
+off_t
+Model::IOOperation::Offset() const
+{
+       return startedEvent->offset;
+}
+
+
+size_t
+Model::IOOperation::Length() const
+{
+       return startedEvent->length;
+}
+
+
+bool
+Model::IOOperation::IsWrite() const
+{
+       return startedEvent->write;
+}
+
+
+status_t
+Model::IOOperation::Status() const
+{
+       return finishedEvent != NULL ? finishedEvent->status : B_OK;
+}
+
+
+size_t
+Model::IOOperation::BytesTransferred() const
+{
+       return finishedEvent != NULL ? finishedEvent->transferred : 0;
+}
+
+
 /*static*/ int
 Model::IOOperation::CompareByTime(const IOOperation* a, const IOOperation* b)
 {
@@ -717,6 +801,76 @@
 // #pragma mark - IORequest
 
 
+nanotime_t
+Model::IORequest::ScheduledTime() const
+{
+       return scheduledEvent->time;
+}
+
+
+nanotime_t
+Model::IORequest::FinishedTime() const
+{
+       return finishedEvent != NULL ? finishedEvent->time : 0;
+}
+
+
+bool
+Model::IORequest::IsFinished() const
+{
+       return finishedEvent != NULL;
+}
+
+
+int32
+Model::IORequest::Scheduler() const
+{
+       return scheduledEvent->scheduler;
+}
+
+
+off_t
+Model::IORequest::Offset() const
+{
+       return scheduledEvent->offset;
+}
+
+
+size_t
+Model::IORequest::Length() const
+{
+       return scheduledEvent->length;
+}
+
+
+bool
+Model::IORequest::IsWrite() const
+{
+       return scheduledEvent->write;
+}
+
+
+uint8
+Model::IORequest::Priority() const
+{
+       return scheduledEvent->priority;
+}
+
+
+status_t
+Model::IORequest::Status() const
+{
+       return finishedEvent != NULL ? finishedEvent->status : B_OK;
+}
+
+
+size_t
+Model::IORequest::BytesTransferred() const
+{
+       return finishedEvent != NULL ? finishedEvent->transferred : 0;
+}
+
+
 /*static*/ bool
 Model::IORequest::TimeLess(const IORequest* a, const IORequest* b)
 {
@@ -735,6 +889,20 @@
 }
 
 
+/*static*/ int
+Model::IORequest::CompareSchedulerTime(const IORequest* a, const IORequest* b)
+{
+       int32 cmp = a->scheduledEvent->scheduler - b->scheduledEvent->scheduler;
+       if (cmp != 0)
+               return cmp < 0;
+
+       nanotime_t timeCmp = a->scheduledEvent->time - b->scheduledEvent->time;
+       if (timeCmp == 0)
+               return 0;
+       return timeCmp < 0 ? -1 : 1;
+}
+
+
 // #pragma mark - IOScheduler
 
 


Other related posts:

  • » [haiku-commits] r34758 - haiku/trunk/src/apps/debuganalyzer/model - ingo_weinhold