~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/benchmark/benchmarkudf.cc

  • Committer: Stewart Smith
  • Date: 2009-06-16 00:46:49 UTC
  • mto: (1119.2.6 merge)
  • mto: This revision was merged to the branch mainline in revision 1124.
  • Revision ID: stewart@flamingspork.com-20090616004649-k2qt6b31sorpi6am
make type_blob test not leave tables behind

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA 
18
18
 */
19
19
 
20
 
#include "config.h"
 
20
#include <drizzled/server_includes.h>
21
21
#include <drizzled/error.h>
22
22
#include <drizzled/session.h>
23
 
#include "drizzled/internal/m_string.h"
24
23
 
25
24
using namespace std;
26
 
using namespace drizzled;
27
25
 
28
26
class BenchmarkFunction :public Item_int_func
29
27
{
57
55
 
58
56
  char buff[MAX_FIELD_WIDTH];
59
57
  String tmp(buff,sizeof(buff), &my_charset_bin);
60
 
  type::Decimal tmp_decimal;
 
58
  my_decimal tmp_decimal;
61
59
  Session *session= current_session;
62
60
  uint64_t loop_count;
63
61
 
68
66
  {
69
67
    if (args[0]->null_value == false)
70
68
    {
71
 
      internal::int64_t10_to_str((int64_t)loop_count, buff, -10);
 
69
      llstr(((int64_t) loop_count), buff);
72
70
      push_warning_printf(current_session, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
73
71
                          ER_WRONG_VALUE_FOR_TYPE, ER(ER_WRONG_VALUE_FOR_TYPE),
74
72
                          "count", buff, "benchmark");
81
79
  null_value= false;
82
80
 
83
81
  uint64_t loop;
84
 
  for (loop= 0 ; loop < loop_count && not session->getKilled(); loop++)
 
82
  for (loop= 0 ; loop < loop_count && !session->killed; loop++)
85
83
  {
86
84
    switch (args[1]->result_type()) 
87
85
    {
116
114
  str->append(')');
117
115
}
118
116
 
119
 
plugin::Create_function<BenchmarkFunction> *benchmarkudf= NULL;
 
117
Create_function<BenchmarkFunction> benchmarkudf(string("benchmark"));
120
118
 
121
 
static int initialize(module::Context &context)
 
119
static int initialize(drizzled::plugin::Registry &registry)
122
120
{
123
 
  benchmarkudf= new plugin::Create_function<BenchmarkFunction>("benchmark");
124
 
  context.add(benchmarkudf);
 
121
  registry.add(&benchmarkudf);
125
122
  return 0;
126
123
}
127
124
 
128
 
DRIZZLE_DECLARE_PLUGIN
129
 
{
130
 
  DRIZZLE_VERSION_ID,
 
125
static int finalize(drizzled::plugin::Registry &registry)
 
126
{
 
127
   registry.remove(&benchmarkudf);
 
128
   return 0;
 
129
}
 
130
 
 
131
drizzle_declare_plugin(benchmark)
 
132
{
131
133
  "benchmark",
132
134
  "1.0",
133
135
  "Devananda van der Veen",
134
136
  "Measure time for repeated calls to a function.",
135
137
  PLUGIN_LICENSE_GPL,
136
138
  initialize, /* Plugin Init */
137
 
  NULL,   /* depends */
 
139
  finalize,   /* Plugin Deinit */
 
140
  NULL,   /* status variables */
 
141
  NULL,   /* system variables */
138
142
  NULL    /* config options */
139
143
}
140
 
DRIZZLE_DECLARE_PLUGIN_END;
 
144
drizzle_declare_plugin_end;