Delete loadertest and cleanup some of the new api.
authorZack Rusin <zack@kde.org>
Sun, 18 Sep 2011 23:40:47 +0000 (19:40 -0400)
committerZack Rusin <zack@kde.org>
Sun, 18 Sep 2011 23:40:47 +0000 (19:40 -0400)
CMakeLists.txt
gui/apitrace.cpp
gui/apitrace.h
gui/apitracecall.cpp
gui/apitracecall.h
gui/apitracemodel.cpp
gui/mainwindow.cpp
gui/traceloader.cpp
loadertest.cpp [deleted file]

index 2ee433a..e327e28 100755 (executable)
@@ -205,9 +205,6 @@ link_libraries (common)
 add_executable (tracedump tracedump.cpp)
 install (TARGETS tracedump RUNTIME DESTINATION bin) 
 
-add_executable (loadertest loadertest.cpp)
-install (TARGETS loadertest RUNTIME DESTINATION bin)
-
 ##############################################################################
 # API tracers
 
index 6f101cd..ca5098d 100644 (file)
@@ -152,7 +152,6 @@ void ApiTrace::setFileName(const QString &name)
         m_needsSaving = false;
         emit invalidated();
 
-//        m_loader->loadTrace(m_fileName);
         emit loadTrace(m_fileName);
     }
 }
@@ -190,7 +189,7 @@ ApiTraceCall * ApiTrace::callWithIndex(int idx) const
 ApiTraceState ApiTrace::defaultState() const
 {
     ApiTraceFrame *frame = frameAt(0);
-    if (!frame || !frame->loaded() || frame->isEmpty())
+    if (!frame || !frame->isLoaded() || frame->isEmpty())
         return ApiTraceState();
 
     ApiTraceCall *firstCall = frame->calls().first();
@@ -264,14 +263,14 @@ bool ApiTrace::hasErrors() const
 
 void ApiTrace::loadFrame(ApiTraceFrame *frame)
 {
-    Q_ASSERT(!frame->loaded());
+    Q_ASSERT(!frame->isLoaded());
     emit requestFrame(frame);
 }
 
 void ApiTrace::finishedParsing()
 {
     ApiTraceFrame *firstFrame = m_frames[0];
-    if (firstFrame && !firstFrame->loaded()) {
+    if (firstFrame && !firstFrame->isLoaded()) {
         loadFrame(firstFrame);
     }
 }
@@ -319,10 +318,10 @@ void ApiTrace::findNext(ApiTraceFrame *frame,
     ApiTraceCall *foundCall = 0;
     int frameIdx = m_frames.indexOf(frame);
 
-    if (frame->loaded()) {
+    if (frame->isLoaded()) {
         foundCall = frame->findNextCall(from, str, sensitivity);
         if (foundCall) {
-            emit findResult(SearchFound, foundCall);
+            emit findResult(SearchResult_Found, foundCall);
             return;
         }
 
@@ -333,18 +332,18 @@ void ApiTrace::findNext(ApiTraceFrame *frame,
 
     for (int i = frameIdx; i < m_frames.count(); ++i) {
         ApiTraceFrame *frame = m_frames[i];
-        if (!frame->loaded()) {
+        if (!frame->isLoaded()) {
             emit loaderSearchNext(i, str, sensitivity);
             return;
         } else {
             ApiTraceCall *call = frame->findNextCall(0, str, sensitivity);
             if (call) {
-                emit findResult(SearchFound, call);
+                emit findResult(SearchResult_Found, call);
                 return;
             }
         }
     }
-    emit findResult(SearchWrapped, 0);
+    emit findResult(SearchResult_Wrapped, 0);
 }
 
 void ApiTrace::findPrev(ApiTraceFrame *frame,
@@ -355,10 +354,10 @@ void ApiTrace::findPrev(ApiTraceFrame *frame,
     ApiTraceCall *foundCall = 0;
     int frameIdx = m_frames.indexOf(frame);
 
-    if (frame->loaded()) {
+    if (frame->isLoaded()) {
         foundCall = frame->findPrevCall(from, str, sensitivity);
         if (foundCall) {
-            emit findResult(SearchFound, foundCall);
+            emit findResult(SearchResult_Found, foundCall);
             return;
         }
 
@@ -369,18 +368,18 @@ void ApiTrace::findPrev(ApiTraceFrame *frame,
 
     for (int i = frameIdx; i >= 0; --i) {
         ApiTraceFrame *frame = m_frames[i];
-        if (!frame->loaded()) {
+        if (!frame->isLoaded()) {
             emit loaderSearchPrev(i, str, sensitivity);
             return;
         } else {
             ApiTraceCall *call = frame->findPrevCall(0, str, sensitivity);
             if (call) {
-                emit findResult(SearchFound, call);
+                emit findResult(SearchResult_Found, call);
                 return;
             }
         }
     }
-    emit findResult(SearchWrapped, 0);
+    emit findResult(SearchResult_Wrapped, 0);
 }
 
 void ApiTrace::loaderSearchResult(ApiTrace::SearchResult result,
@@ -393,7 +392,7 @@ void ApiTrace::loaderSearchResult(ApiTrace::SearchResult result,
 
 void ApiTrace::findFrameStart(ApiTraceFrame *frame)
 {
-    if (frame->loaded()) {
+    if (frame->isLoaded()) {
         emit foundFrameStart(frame);
     } else {
         emit loaderFindFrameStart(frame);
@@ -402,7 +401,7 @@ void ApiTrace::findFrameStart(ApiTraceFrame *frame)
 
 void ApiTrace::findFrameEnd(ApiTraceFrame *frame)
 {
-    if (frame->loaded()) {
+    if (frame->isLoaded()) {
         emit foundFrameEnd(frame);
     } else {
         emit loaderFindFrameEnd(frame);
@@ -422,7 +421,7 @@ void ApiTrace::findCallIndex(int index)
     frame = m_frames[frameIdx];
 
     if (frame) {
-        if (frame->loaded()) {
+        if (frame->isLoaded()) {
             ApiTraceCall *call = frame->callWithIndex(index);
             emit foundCallIndex(call);
         } else {
@@ -437,7 +436,7 @@ int ApiTrace::callInFrame(int callIdx) const
 
     for (int frameIdx = 0; frameIdx <= m_frames.size(); ++frameIdx) {
         const ApiTraceFrame *frame = m_frames[frameIdx];
-        unsigned numCallsInFrame =  frame->loaded()
+        unsigned numCallsInFrame =  frame->isLoaded()
                 ? frame->numChildren()
                 : frame->numChildrenToLoad();
         unsigned firstCall = numCalls;
@@ -461,7 +460,7 @@ void ApiTrace::setCallError(const ApiTraceError &error)
     }
     frame = m_frames[frameIdx];
 
-    if (frame->loaded()) {
+    if (frame->isLoaded()) {
         ApiTraceCall *call = frame->callWithIndex(error.callIndex);
         call->setError(error.message);
         if (call->hasError()) {
index c5a2975..bf90d17 100644 (file)
@@ -21,9 +21,9 @@ public:
         FrameMarker_Clear
     };
     enum SearchResult {
-        SearchNotFound,
-        SearchFound,
-        SearchWrapped
+        SearchResult_NotFound,
+        SearchResult_Found,
+        SearchResult_Wrapped
     };
 
     static bool isCallAFrameMarker(const ApiTraceCall *call,
index 9a6a32e..67fc955 100644 (file)
@@ -1061,7 +1061,7 @@ void ApiTraceFrame::setCalls(const QVector<ApiTraceCall*> &calls,
     m_staticText = 0;
 }
 
-bool ApiTraceFrame::loaded() const
+bool ApiTraceFrame::isLoaded() const
 {
     return m_loaded;
 }
index 15dca13..12b0216 100644 (file)
@@ -330,7 +330,7 @@ public:
 
     int binaryDataSize() const;
 
-    bool loaded() const;
+    bool isLoaded() const;
     void setLoaded(bool l);
 
     void setLastCallIndex(unsigned index);
index 96a9888..7303ae1 100644 (file)
@@ -91,7 +91,7 @@ QVariant ApiTraceModel::data(const QModelIndex &index, int role) const
                 }
             }
 
-            int numCalls = frame->loaded()
+            int numCalls = frame->isLoaded()
                     ? frame->numChildren()
                     : frame->numChildrenToLoad();
 
@@ -350,7 +350,7 @@ bool ApiTraceModel::canFetchMore(const QModelIndex &parent) const
         ApiTraceEvent *event = item(parent);
         if (event && event->type() == ApiTraceEvent::Frame) {
             ApiTraceFrame *frame = static_cast<ApiTraceFrame*>(event);
-            return !frame->loaded() && !m_loadingFrames.contains(frame);
+            return !frame->isLoaded() && !m_loadingFrames.contains(frame);
         } else
             return false;
     } else {
@@ -366,7 +366,7 @@ void ApiTraceModel::fetchMore(const QModelIndex &parent)
             ApiTraceFrame *frame = static_cast<ApiTraceFrame*>(event);
             QModelIndex index = createIndex(frame->number, 0, frame);
 
-            Q_ASSERT(!frame->loaded());
+            Q_ASSERT(!frame->isLoaded());
             m_loadingFrames.insert(frame);
 
             m_trace->loadFrame(frame);
index 2974f31..3382fae 100644 (file)
@@ -875,7 +875,7 @@ void MainWindow::fillState(bool nonDefaults)
                 m_trace->frameAt(0);
             if (!firstFrame)
                 return;
-            if (!firstFrame->loaded()) {
+            if (!firstFrame->isLoaded()) {
                 m_trace->loadFrame(firstFrame);
                 return;
             }
@@ -1080,16 +1080,16 @@ void MainWindow::slotSearchResult(ApiTrace::SearchResult result,
                                   ApiTraceCall *call)
 {
     switch (result) {
-    case ApiTrace::SearchNotFound:
+    case ApiTrace::SearchResult_NotFound:
         m_searchWidget->setFound(false);
         break;
-    case ApiTrace::SearchFound: {
+    case ApiTrace::SearchResult_Found: {
         QModelIndex index = m_proxyModel->indexForCall(call);
         m_ui.callView->setCurrentIndex(index);
         m_searchWidget->setFound(true);
     }
         break;
-    case ApiTrace::SearchWrapped:
+    case ApiTrace::SearchResult_Wrapped:
         m_searchWidget->setFound(false);
         break;
     }
@@ -1151,7 +1151,7 @@ ApiTraceCall * MainWindow::currentCall() const
 
 void MainWindow::slotFoundFrameStart(ApiTraceFrame *frame)
 {
-    Q_ASSERT(frame->loaded());
+    Q_ASSERT(frame->isLoaded());
     if (!frame || frame->isEmpty()) {
         return;
     }
@@ -1173,7 +1173,7 @@ void MainWindow::slotFoundFrameStart(ApiTraceFrame *frame)
 
 void MainWindow::slotFoundFrameEnd(ApiTraceFrame *frame)
 {
-    Q_ASSERT(frame->loaded());
+    Q_ASSERT(frame->isLoaded());
     if (!frame || frame->isEmpty()) {
         return;
     }
index 9480f45..108d220 100644 (file)
@@ -291,7 +291,7 @@ void TraceLoader::searchNext(int startFrame,
                         fetchFrameContents(frame);
                 for (int i = 0; i < calls.count(); ++i) {
                     if (calls[i]->index() == call->no) {
-                        emit searchResult(ApiTrace::SearchFound, calls[i]);
+                        emit searchResult(ApiTrace::SearchResult_Found, calls[i]);
                         break;
                     }
                 }
@@ -302,7 +302,7 @@ void TraceLoader::searchNext(int startFrame,
             delete call;
         }
     }
-    emit searchResult(ApiTrace::SearchNotFound, 0);
+    emit searchResult(ApiTrace::SearchResult_NotFound, 0);
 }
 
 void TraceLoader::searchPrev(int startFrame,
@@ -346,7 +346,7 @@ void TraceLoader::searchPrev(int startFrame,
             }
         }
     }
-    emit searchResult(ApiTrace::SearchNotFound, 0);
+    emit searchResult(ApiTrace::SearchResult_NotFound, 0);
 }
 
 bool TraceLoader::searchCallsBackwards(const QList<Trace::Call*> &calls,
@@ -362,7 +362,7 @@ bool TraceLoader::searchCallsBackwards(const QList<Trace::Call*> &calls,
                     fetchFrameContents(frame);
             for (int i = 0; i < apiCalls.count(); ++i) {
                 if (apiCalls[i]->index() == call->no) {
-                    emit searchResult(ApiTrace::SearchFound, apiCalls[i]);
+                    emit searchResult(ApiTrace::SearchResult_Found, apiCalls[i]);
                     break;
                 }
             }
diff --git a/loadertest.cpp b/loadertest.cpp
deleted file mode 100644 (file)
index 9dc9074..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-#include "trace_loader.hpp"
-#include "os.hpp"
-
-#include <iostream>
-
-
-static const double msecsInSec = 1000000;
-
-static void timeFrameFetch(Trace::Loader &loader, unsigned frameIdx)
-{
-    long long t1, t2;
-    std::vector<Trace::Call*> frame;
-
-    t1 = OS::GetTime();
-    frame = loader.frame(frameIdx);
-    t2 = OS::GetTime();
-    std::cout << "Time to fetch the frame["
-              << frameIdx
-              << "] size "
-              << frame.size()
-              << " is = "
-              << (t2 - t1)/msecsInSec
-              << " secs "<<std::endl;
-
-    for (unsigned i = 0; i < frame.size(); ++i) {
-        delete frame[i];
-    }
-}
-
-
-int main(int argc, char **argv)
-{
-    int i;
-
-    for (i = 1; i < argc; ++i) {
-        Trace::Loader loader;
-
-        long long t1 = OS::GetTime();
-        if (!loader.open(argv[i])) {
-            std::cerr << "error: failed to open " << argv[i] << "\n";
-            return 1;
-        }
-        long long t2 = OS::GetTime();
-        std::cout << "Time to scan file = "<< (t2 - t1)/msecsInSec
-                  << " secs "<<std::endl;
-
-        std::cout << "Number of frames = "
-                  << loader.numberOfFrames()
-                  << std::endl;
-        std::cout << "Number of calls in frame 0 = "
-                  << loader.numberOfCallsInFrame(0)
-                  << std::endl;
-        int lastFrame = loader.numberOfFrames() - 1;
-        std::cout << "Number of calls in frame "
-                  << lastFrame << " = "
-                  << loader.numberOfCallsInFrame(lastFrame)
-                  << std::endl;
-
-        unsigned biggestFrameIdx = 0;
-        unsigned maxFrameSize = 0;
-        for (unsigned i = 0; i < loader.numberOfFrames(); ++i) {
-            if (loader.numberOfCallsInFrame(i) > maxFrameSize) {
-                maxFrameSize = loader.numberOfCallsInFrame(i);
-                biggestFrameIdx = i;
-            }
-        }
-
-        timeFrameFetch(loader, loader.numberOfFrames()/2);
-        timeFrameFetch(loader, 0);
-        timeFrameFetch(loader, loader.numberOfFrames() - 1);
-        timeFrameFetch(loader, biggestFrameIdx);
-    }
-
-    return 0;
-}
-