/[escript]/trunk/escript/src/DataProf.cpp
ViewVC logotype

Annotation of /trunk/escript/src/DataProf.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 478 - (hide annotations)
Tue Jan 31 02:21:49 2006 UTC (13 years, 9 months ago) by jgs
File size: 4498 byte(s)
rationalise #includes

1 jgs 123 /*
2     ******************************************************************************
3     * *
4     * COPYRIGHT ACcESS 2004 - All Rights Reserved *
5     * *
6     * This software is the property of ACcESS. No part of this code *
7     * may be copied in any form or by any means without the expressed written *
8     * consent of ACcESS. Copying, use or modification of this software *
9     * by any unauthorised person is illegal unless that person has a software *
10     * license agreement with ACcESS. *
11     * *
12     ******************************************************************************
13     */
14    
15 jgs 474 #include "DataProf.h"
16 jgs 123
17 jgs 478 #include <iostream>
18     #include <sstream>
19    
20 jgs 123 using namespace std;
21    
22     namespace escript {
23    
24     DataProf::DataProf() {
25     profDataTable_Root = 0;
26     totalDataObjects = 0;
27     }
28    
29     DataProf::~DataProf() {
30    
31     profDataTable* tempTable = profDataTable_Root;
32     profDataTable* lastTable;
33    
34     cout << compProf() << endl;
35    
36     while (tempTable != 0) {
37     lastTable = tempTable;
38     tempTable = tempTable->next;
39     delete lastTable->data;
40     delete lastTable;
41     }
42    
43     totalDataObjects = -1;
44    
45     }
46    
47     profDataEntry*
48     DataProf::newData(){
49    
50     profDataTable* tempTable;
51     profDataEntry* tempEntry;
52    
53     // create the new table and entry
54     tempTable = new profDataTable;
55     tempEntry = new profDataEntry;
56    
57     // add the new table to the beginning of the list
58     tempTable->next = profDataTable_Root;
59     profDataTable_Root = tempTable;
60    
61     // add the new entry to the new table
62     tempTable->data = tempEntry;
63    
64     // initialise the new entry
65     tempEntry->interpolate = 0;
66     tempEntry->grad = 0;
67     tempEntry->integrate = 0;
68     tempEntry->where = 0;
69     tempEntry->unary = 0;
70     tempEntry->binary = 0;
71     tempEntry->reduction1 = 0;
72     tempEntry->reduction2 = 0;
73     tempEntry->slicing = 0;
74    
75     // increment the Data objects counter
76     totalDataObjects++;
77    
78     // return the pointer to the new entry
79     return tempEntry;
80    
81     }
82    
83     std::string
84     DataProf::dumpProf(profDataEntry* entry) {
85    
86     stringstream temp_str;
87    
88     temp_str << "=============================\n";
89     temp_str << "interpolate: " << entry->interpolate << "\n";
90     temp_str << "grad : " << entry->grad << "\n";
91     temp_str << "integrate : " << entry->integrate << "\n";
92     temp_str << "where : " << entry->where << "\n";
93     temp_str << "unary : " << entry->unary << "\n";
94     temp_str << "binary : " << entry->binary << "\n";
95     temp_str << "reduction1 : " << entry->reduction1 << "\n";
96     temp_str << "reduction2 : " << entry->reduction2 << "\n";
97     temp_str << "slicing : " << entry->slicing << "\n";
98     temp_str << "=============================\n ";
99     temp_str << endl;
100    
101     return temp_str.str();
102    
103     }
104    
105     string
106     DataProf::compProf() {
107    
108     int comp_interpolate = 0;
109     int comp_grad = 0;
110     int comp_integrate = 0;
111     int comp_where = 0;
112     int comp_unary = 0;
113     int comp_binary = 0;
114     int comp_reduction1 = 0;
115     int comp_reduction2 = 0;
116     int comp_slicing = 0;
117    
118     profDataTable* tempTable = profDataTable_Root;
119    
120     while (tempTable != 0) {
121     comp_interpolate += tempTable->data->interpolate;
122     comp_grad += tempTable->data->grad;
123     comp_integrate += tempTable->data->integrate;
124     comp_where += tempTable->data->where;
125     comp_unary += tempTable->data->unary;
126     comp_binary += tempTable->data->binary;
127     comp_reduction1 += tempTable->data->reduction1;
128     comp_reduction2 += tempTable->data->reduction2;
129     comp_slicing += tempTable->data->slicing;
130     tempTable = tempTable->next;
131     }
132    
133     stringstream temp_str;
134    
135 jgs 149 temp_str << "========== Op Stats ===================\n";
136 jgs 123 temp_str << "Total objects: " << totalDataObjects << "\n";
137     temp_str << "interpolate : " << comp_interpolate << "\n";
138     temp_str << "grad : " << comp_grad << "\n";
139     temp_str << "integrate : " << comp_integrate << "\n";
140     temp_str << "where : " << comp_where << "\n";
141     temp_str << "unary : " << comp_unary << "\n";
142     temp_str << "binary : " << comp_binary << "\n";
143     temp_str << "reduction1 : " << comp_reduction1 << "\n";
144     temp_str << "reduction2 : " << comp_reduction2 << "\n";
145     temp_str << "slicing : " << comp_slicing << "\n";
146 jgs 149 temp_str << "======================================= ";
147 jgs 123 temp_str << endl;
148    
149     return temp_str.str();
150    
151     }
152    
153     } // end of namespace

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26