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
#include <drizzled/server_includes.h>
22
#include <drizzled/function/benchmark.h>
23
#include <drizzled/error.h>
24
#include <drizzled/session.h>
27
/* This function is just used to test speed of different functions */
29
int64_t Item_func_benchmark::val_int()
32
char buff[MAX_FIELD_WIDTH];
33
String tmp(buff,sizeof(buff), &my_charset_bin);
34
my_decimal tmp_decimal;
35
Session *session=current_session;
38
loop_count= (uint64_t) args[0]->val_int();
40
if (args[0]->null_value ||
41
(!args[0]->unsigned_flag && (((int64_t) loop_count) < 0)))
43
if (!args[0]->null_value)
45
llstr(((int64_t) loop_count), buff);
46
push_warning_printf(current_session, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
47
ER_WRONG_VALUE_FOR_TYPE, ER(ER_WRONG_VALUE_FOR_TYPE),
48
"count", buff, "benchmark");
56
for (uint64_t loop=0 ; loop < loop_count && !session->killed; loop++)
58
switch (args[1]->result_type()) {
60
(void) args[1]->val_real();
63
(void) args[1]->val_int();
66
(void) args[1]->val_str(&tmp);
69
(void) args[1]->val_decimal(&tmp_decimal);
73
// This case should never be chosen
82
void Item_func_benchmark::print(String *str, enum_query_type query_type)
84
str->append(STRING_WITH_LEN("benchmark("));
85
args[0]->print(str, query_type);
87
args[1]->print(str, query_type);