1 /* ------------------------------------------------
2 Copyright 2014 AT&T Intellectual Property
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
7 http://www.apache.org/licenses/LICENSE-2.0
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14 ------------------------------------------- */
16 #ifndef __QNODE_H_DEFINED_
17 #define __QNODE_H_DEFINED_
26 unsigned long long int init_stime;
27 unsigned long long int init_utime;
28 unsigned long long int total_stime;
29 unsigned long long int total_utime;
33 unsigned long long int max_vm_size;
34 unsigned long long int max_rss;
59 bool update(int t, unsigned long long int u, unsigned long long int s,
60 unsigned long long int v, unsigned long long int r){
76 if(t<=last_update || u<total_utime || s<total_stime){
80 double tmps,tmpu,tmpt;
81 tmps = (double)((s-total_stime))/(t-last_update);
82 tmpu = (double)((u-total_utime))/(t-last_update);
98 std::string to_string(){
100 if(last_update - init_time>0){
101 sprintf(ret,"stime=%lf, utime=%lf, time=%lf max_stime=%lf, max_utime=%lf, max_time=%lf, max_vmsize=%lld, max_rss = %lld",
102 (double)(total_stime-init_stime)/(last_update - init_time),
103 (double)(total_utime-init_utime)/(last_update - init_time),
104 (double)(total_stime-init_stime)/(last_update - init_time) + (double)(total_utime-init_utime)/(last_update - init_time),
105 max_stime,max_utime,max_time,
110 return("(no perf results)");
113 static std::string to_csv_hdr(){
114 return "avg_system_time,avg_user_time,avg_cpu_time,max_sys_time,max_user_time,max_total_time,max_vm_size,max_rss";
117 std::string to_csv(){
119 if(last_update - init_time>0){
120 sprintf(ret,"%lf,%lf,%lf,%lf,%lf,%lf,%lld,%lld",
121 (double)(total_stime-init_stime)/(last_update - init_time),
122 (double)(total_utime-init_utime)/(last_update - init_time),
123 (double)(total_stime-init_stime)/(last_update - init_time) + (double)(total_utime-init_utime)/(last_update - init_time),
124 max_stime,max_utime,max_time,
132 double avg_cpu_time(){
133 return ((double)((total_stime-init_stime)+(total_utime-init_utime))/(last_update - init_time))/100.0;
137 return last_update > 0;
151 field_str(std::string n, int p, std::string t, std::string m){
162 std::string executable_name;
163 std::string qnode_type;
165 std::vector<field_str *> fields;
166 std::vector<std::string> reads_from;
167 std::vector<int> reads_from_idx;
168 std::vector<int> sources_to_idx;
169 std::string src_interface;
171 int start_tick, end_tick;
173 unsigned long long int in_tup,out_tup,out_sz;
174 unsigned long long int accepted_tup,cycles,collisions,evictions;
175 double inferred_in_sz;
186 inferred_in_sz = 0.0;
188 start_tick = end_tick = -1;
189 perf = new perf_struct(d);
192 qnode(std::string type, std::string n,int d){
204 inferred_in_sz = 0.0;
206 start_tick = end_tick = -1;
207 perf = new perf_struct(d);
210 double output_rate(){
211 if(end_tick == start_tick){
214 return( ((double)out_sz)/(end_tick-start_tick) );
217 void add_field(field_str *fld){
218 fields.push_back(fld);
221 void add_source(std::string src){
222 reads_from.push_back(src);