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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 155 - (show annotations)
Wed Nov 9 02:02:19 2005 UTC (13 years, 11 months ago) by jgs
Original Path: trunk/escript/src/Data/DataProf.cpp
File size: 4530 byte(s)
move all directories from trunk/esys2 into trunk and remove esys2

1 /*
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 #include <iostream>
16 #include <sstream>
17 #include <string>
18
19 #include "escript/Data/DataProf.h"
20
21 using namespace std;
22
23 namespace escript {
24
25 DataProf::DataProf() {
26 profDataTable_Root = 0;
27 totalDataObjects = 0;
28 }
29
30 DataProf::~DataProf() {
31
32 profDataTable* tempTable = profDataTable_Root;
33 profDataTable* lastTable;
34
35 cout << compProf() << endl;
36
37 while (tempTable != 0) {
38 lastTable = tempTable;
39 tempTable = tempTable->next;
40 delete lastTable->data;
41 delete lastTable;
42 }
43
44 totalDataObjects = -1;
45
46 }
47
48 profDataEntry*
49 DataProf::newData(){
50
51 profDataTable* tempTable;
52 profDataEntry* tempEntry;
53
54 // create the new table and entry
55 tempTable = new profDataTable;
56 tempEntry = new profDataEntry;
57
58 // add the new table to the beginning of the list
59 tempTable->next = profDataTable_Root;
60 profDataTable_Root = tempTable;
61
62 // add the new entry to the new table
63 tempTable->data = tempEntry;
64
65 // initialise the new entry
66 tempEntry->interpolate = 0;
67 tempEntry->grad = 0;
68 tempEntry->integrate = 0;
69 tempEntry->where = 0;
70 tempEntry->unary = 0;
71 tempEntry->binary = 0;
72 tempEntry->reduction1 = 0;
73 tempEntry->reduction2 = 0;
74 tempEntry->slicing = 0;
75
76 // increment the Data objects counter
77 totalDataObjects++;
78
79 // return the pointer to the new entry
80 return tempEntry;
81
82 }
83
84 std::string
85 DataProf::dumpProf(profDataEntry* entry) {
86
87 stringstream temp_str;
88
89 temp_str << "=============================\n";
90 temp_str << "interpolate: " << entry->interpolate << "\n";
91 temp_str << "grad : " << entry->grad << "\n";
92 temp_str << "integrate : " << entry->integrate << "\n";
93 temp_str << "where : " << entry->where << "\n";
94 temp_str << "unary : " << entry->unary << "\n";
95 temp_str << "binary : " << entry->binary << "\n";
96 temp_str << "reduction1 : " << entry->reduction1 << "\n";
97 temp_str << "reduction2 : " << entry->reduction2 << "\n";
98 temp_str << "slicing : " << entry->slicing << "\n";
99 temp_str << "=============================\n ";
100 temp_str << endl;
101
102 return temp_str.str();
103
104 }
105
106 string
107 DataProf::compProf() {
108
109 int comp_interpolate = 0;
110 int comp_grad = 0;
111 int comp_integrate = 0;
112 int comp_where = 0;
113 int comp_unary = 0;
114 int comp_binary = 0;
115 int comp_reduction1 = 0;
116 int comp_reduction2 = 0;
117 int comp_slicing = 0;
118
119 profDataTable* tempTable = profDataTable_Root;
120
121 while (tempTable != 0) {
122 comp_interpolate += tempTable->data->interpolate;
123 comp_grad += tempTable->data->grad;
124 comp_integrate += tempTable->data->integrate;
125 comp_where += tempTable->data->where;
126 comp_unary += tempTable->data->unary;
127 comp_binary += tempTable->data->binary;
128 comp_reduction1 += tempTable->data->reduction1;
129 comp_reduction2 += tempTable->data->reduction2;
130 comp_slicing += tempTable->data->slicing;
131 tempTable = tempTable->next;
132 }
133
134 stringstream temp_str;
135
136 temp_str << "========== Op Stats ===================\n";
137 temp_str << "Total objects: " << totalDataObjects << "\n";
138 temp_str << "interpolate : " << comp_interpolate << "\n";
139 temp_str << "grad : " << comp_grad << "\n";
140 temp_str << "integrate : " << comp_integrate << "\n";
141 temp_str << "where : " << comp_where << "\n";
142 temp_str << "unary : " << comp_unary << "\n";
143 temp_str << "binary : " << comp_binary << "\n";
144 temp_str << "reduction1 : " << comp_reduction1 << "\n";
145 temp_str << "reduction2 : " << comp_reduction2 << "\n";
146 temp_str << "slicing : " << comp_slicing << "\n";
147 temp_str << "======================================= ";
148 temp_str << endl;
149
150 return temp_str.str();
151
152 }
153
154 } // end of namespace

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26