1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; version 2 of the License.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
#ifndef DRIZZLED_COST_VECT_H
21
#define DRIZZLED_COST_VECT_H
29
double io_count; /* number of I/O */
30
double avg_io_cost; /* cost of an average I/O oper. */
31
double cpu_cost; /* cost of operations in CPU */
32
double mem_cost; /* cost of used memory */
33
double import_cost; /* cost of remote operations */
35
static const uint32_t IO_COEFF=1;
36
static const uint32_t CPU_COEFF=1;
37
static const uint32_t MEM_COEFF=1;
38
static const uint32_t IMPORT_COEFF=1;
50
return IO_COEFF*io_count*avg_io_cost + CPU_COEFF * cpu_cost +
51
MEM_COEFF*mem_cost + IMPORT_COEFF*import_cost;
57
io_count= cpu_cost= mem_cost= import_cost= 0.0;
60
void multiply(double m)
65
/* Don't multiply mem_cost */
68
void add(const COST_VECT* cost)
70
double io_count_sum= io_count + cost->io_count;
71
add_io(cost->io_count, cost->avg_io_cost);
72
io_count= io_count_sum;
73
cpu_cost += cost->cpu_cost;
75
void add_io(double add_io_cnt, double add_avg_cost)
77
double io_count_sum= io_count + add_io_cnt;
78
avg_io_cost= (io_count * avg_io_cost +
79
add_io_cnt * add_avg_cost) / io_count_sum;
80
io_count= io_count_sum;
84
} /* namespace drizzled */
86
#endif /* DRIZZLED_COST_VECT_H */