1 /*
2  * Copyright 2006-2008 The FLWOR Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef ZORBA_DEBUGGER_PROFILER_H
18 #define ZORBA_DEBUGGER_PROFILER_H
19 
20 #include <fstream>
21 #include <string>
22 #include <stack>
23 
24 namespace zorba {
25 
26 class String;
27 class FnCallEntry;
28 class QueryLoc;
29 
30 class Profiler
31 {
32   private:
33     std::string theFileName;
34     double theTimeTaken;
35     std::ofstream theProfile;
36     std::stack<FnCallEntry *> theStack;
37     FnCallEntry* theRoot;
38     FnCallEntry* theCurrent;
39 
40     void print(FnCallEntry* aCall);
41 
42   public:
43     Profiler(const String& aFileName, const std::string& aProfileName);
44     ~Profiler();
45 
46     void beginFn(const std::string& aFnName, const QueryLoc& aQueryLoc);
47     void endFn();
48 };
49 }//end of namespace
50 #endif
51