MYDDAS: New internal organization and new MYDDAS statistics
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1645 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
40178a0285
commit
f77458e11f
6
H/Regs.h
6
H/Regs.h
@ -10,7 +10,7 @@
|
||||
* File: Regs.h *
|
||||
* mods: *
|
||||
* comments: YAP abstract machine registers *
|
||||
* version: $Id: Regs.h,v 1.38 2006-04-11 16:45:43 rslopes Exp $ *
|
||||
* version: $Id: Regs.h,v 1.39 2006-05-22 16:29:58 tiagosoares Exp $ *
|
||||
*************************************************************************/
|
||||
|
||||
|
||||
@ -19,8 +19,8 @@
|
||||
#include "cut_c.h"
|
||||
#endif
|
||||
|
||||
#if defined CUT_C && (defined MYDDAS_ODBC || defined MYDDAS_MYSQL)
|
||||
#include "myddas_util.h"
|
||||
#if defined MYDDAS_ODBC || defined MYDDAS_MYSQL
|
||||
#include "myddas.h"
|
||||
#endif
|
||||
|
||||
#define MaxTemps 512
|
||||
|
117
MYDDAS/myddas.h
Normal file
117
MYDDAS/myddas.h
Normal file
@ -0,0 +1,117 @@
|
||||
#ifndef __MYDDAS_H__
|
||||
#define __MYDDAS_H__
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef MYDDAS_ODBC
|
||||
#include <sql.h>
|
||||
#endif
|
||||
|
||||
#ifdef MYDDAS_MYSQL
|
||||
#include <mysql/mysql.h>
|
||||
#endif
|
||||
|
||||
/* MYDDAS TYPES */
|
||||
/* sizeof(MyddasPointer) Equal to the size of a integer on the given architecture */
|
||||
/* sizeof(MyddasInt32) = 4 (Always) */
|
||||
/* sizeof(MyddasUInt32) = 4 (Always) */
|
||||
|
||||
#if SIZEOF_INT_P==4
|
||||
|
||||
# if SIZEOF_INT==4
|
||||
/* */ typedef int MyddasInt;
|
||||
/* */ typedef unsigned int MyddasUInt;
|
||||
/* */ typedef unsigned int MyddasPointer;
|
||||
/* */ typedef int MyddasInt32;
|
||||
/* */ typedef unsigned int MyddasUInt32;
|
||||
# elif SIZEOF_LONG_INT==4
|
||||
/* */ typedef long int MyddasInt;
|
||||
/* */ typedef unsigned long int MyddasUInt;
|
||||
/* */ typedef unsigned long int MyddasPointer;
|
||||
/* */ typedef long int MyddasInt32;
|
||||
/* */ typedef unsigned long int MyddasUInt32;
|
||||
# else
|
||||
# error MYDDAS require integer types of the same size as a pointer
|
||||
# endif
|
||||
|
||||
# if SIZEOF_SHORT_INT==2
|
||||
/* */ typedef short int MyddasSInt;
|
||||
/* */ typedef unsigned short int MyddasUSInt;
|
||||
# else
|
||||
# error MYDDAS requires integer types half the size of a pointer
|
||||
# endif
|
||||
|
||||
# if SIZEOF_LONG_INT==8
|
||||
/* */ typedef long int MyddasLInt;
|
||||
/* */ typedef unsigned long int MyddasULInt;
|
||||
# elif SIZEOF_LONG_LONG_INT==8
|
||||
/* */ typedef long long int MyddasLInt;
|
||||
/* */ typedef unsigned long long int MyddasULInt;
|
||||
# else
|
||||
# error MYDDAS requires integer types double the size of a pointer
|
||||
# endif
|
||||
|
||||
#elif SIZEOF_INT_P==8
|
||||
|
||||
# if SIZEOF_INT==8
|
||||
/* */ typedef int MyddasInt;
|
||||
/* */ typedef unsigned int MyddasUInt;
|
||||
/* */ typedef int MyddasLInt;
|
||||
/* */ typedef unsigned int MyddasULInt;
|
||||
/* */ typedef unsigned int MyddasPointer;
|
||||
# elif SIZEOF_LONG_INT==8
|
||||
/* */ typedef long int MyddasInt;
|
||||
/* */ typedef unsigned long int MyddasUInt;
|
||||
/* */ typedef int MyddasLInt;
|
||||
/* */ typedef unsigned int MyddasULInt;
|
||||
/* */ typedef unsigned long int MyddasPointer;
|
||||
# elif SIZEOF_LONG_LONG_INT==8
|
||||
/* */ typedef long long int MyddasInt;
|
||||
/* */ typedef unsigned long long int MyddasUInt;
|
||||
/* */ typedef int MyddasLInt;
|
||||
/* */ typedef unsigned int MyddasULInt;
|
||||
/* */ typedef unsigned long long int MyddasPointer;
|
||||
# else
|
||||
# error MYDDAS requires integer types of the same size as a pointer
|
||||
# endif
|
||||
|
||||
# if SIZEOF_SHORT_INT==4
|
||||
/* */ typedef short int MyddasSInt;
|
||||
/* */ typedef unsigned short int MyddasUSInt;
|
||||
/* */ typedef short int MyddasInt32;
|
||||
/* */ typedef unsigned short int MyddasUInt32;
|
||||
# elif SIZEOF_INT==4
|
||||
/* */ typedef int MyddasSInt;
|
||||
/* */ typedef unsigned short int MyddasUSInt;
|
||||
/* */ typedef int MyddasInt32;
|
||||
/* */ typedef unsigned short int MyddasUInt32;
|
||||
# else
|
||||
# error MYDDAS requires integer types half the size of a pointer
|
||||
# endif
|
||||
|
||||
#else
|
||||
# error MYDDAS requires pointers of size 4 or 8
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
/* Passar para o myddas_statictics.h ???????? */
|
||||
#ifdef MYDDAS_STATS
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
typedef struct myddas_global *MYDDAS_GLOBAL;
|
||||
typedef struct myddas_util_query *MYDDAS_UTIL_QUERY;
|
||||
typedef struct myddas_list_connection *MYDDAS_UTIL_CONNECTION;
|
||||
typedef struct myddas_list_preds *MYDDAS_UTIL_PREDICATE;
|
||||
|
||||
#ifdef MYDDAS_STATS
|
||||
typedef struct myddas_stats_time_struct *MYDDAS_STATS_TIME;
|
||||
typedef struct myddas_global_stats *MYDDAS_GLOBAL_STATS;
|
||||
typedef struct myddas_stats_struct *MYDDAS_STATS_STRUCT;
|
||||
#endif
|
||||
|
||||
#endif /*__MYDDAS_H__*/
|
@ -20,8 +20,11 @@ myddas_util_initialize_myddas(void){
|
||||
#endif
|
||||
#ifdef MYDDAS_STATS
|
||||
global->myddas_statistics = (MYDDAS_GLOBAL_STATS) malloc (sizeof(struct myddas_global_stats));
|
||||
MYDDAS_STATS_INITIALIZE_TIME_STRUCT(global->myddas_statistics->total_db_row,time_final);
|
||||
MYDDAS_STATS_INITIALIZE_TIME_STRUCT(global->myddas_statistics->total_translate,time_final);
|
||||
global->myddas_statistics->stats = NULL;
|
||||
MYDDAS_STATS_INITIALIZE_GLOBAL_STATS(global->myddas_statistics->stats);
|
||||
//MYDDAS_STATS_INITIALIZE_TIME_STRUCT(global->myddas_statistics->total_db_row,time_final);
|
||||
//MYDDAS_STATS_INITIALIZE_TIME_STRUCT(global->myddas_statistics->total_translate,time_final);
|
||||
|
||||
#endif
|
||||
return global;
|
||||
}
|
||||
@ -56,17 +59,10 @@ myddas_util_initialize_connection(void *conn,void *enviromment,
|
||||
next->previous=new;
|
||||
|
||||
#ifdef MYDDAS_STATS
|
||||
new->totalNumberOfRows=0;
|
||||
|
||||
MYDDAS_STATS_INITIALIZE_TIME_STRUCT(new->totalTimeofDBServer,time_final);
|
||||
MYDDAS_STATS_INITIALIZE_TIME_STRUCT(new->lastTimeofDBServer,time_final);
|
||||
MYDDAS_STATS_INITIALIZE_TIME_STRUCT(new->totalFromDBServer,time_final);
|
||||
MYDDAS_STATS_INITIALIZE_TIME_STRUCT(new->lastFromDBServer,time_final);
|
||||
|
||||
new->lastBytesTransfered=0;
|
||||
new->totalBytesTransfered=0;
|
||||
new->total_querys_made=0;
|
||||
new->stats = NULL;
|
||||
MYDDAS_STATS_INITIALIZE_CONNECTION_STATS(new->stats);
|
||||
#endif
|
||||
|
||||
return new;
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include "Yap.h"
|
||||
#include "Yatom.h"
|
||||
#include "cut_c.h"
|
||||
#include "myddas_util.h"
|
||||
#include "myddas.h"
|
||||
#ifdef MYDDAS_STATS
|
||||
#include "myddas_structs.h"
|
||||
#include "myddas_statistics.h"
|
||||
@ -148,6 +148,7 @@ c_db_my_connect(void) {
|
||||
{
|
||||
/* Criar um novo no na lista de ligacoes*/
|
||||
new = myddas_util_add_connection(conn,NULL);
|
||||
|
||||
if (new == NULL){
|
||||
#ifdef DEBUG
|
||||
printf("ERROR: ** c_db_my_connect ** Error allocating memory\n");
|
||||
@ -173,15 +174,18 @@ c_db_my_query(void) {
|
||||
|
||||
MYSQL_RES *res_set;
|
||||
|
||||
Int length=strlen(sql);
|
||||
MyddasInt length=strlen(sql);
|
||||
|
||||
#ifdef MYDDAS_STATS
|
||||
MYDDAS_UTIL_CONNECTION node = myddas_util_search_connection(conn);
|
||||
|
||||
MyddasULInt count = 0;
|
||||
|
||||
/* Count the number of querys made to the server */
|
||||
UInt number_querys;
|
||||
MyddasULInt number_querys;
|
||||
MYDDAS_STATS_CON_GET_NUMBER_QUERIES_MADE(node,number_querys);
|
||||
MYDDAS_STATS_CON_SET_NUMBER_QUERIES_MADE(node,++number_querys);
|
||||
MYDDAS_STATS_CON_GET_NUMBER_QUERIES_MADE_COUNT(node,count);
|
||||
MYDDAS_STATS_CON_SET_NUMBER_QUERIES_MADE_COUNT(node,++count);
|
||||
|
||||
/* Measure time spent by the MySQL Server
|
||||
processing the SQL Query */
|
||||
@ -211,11 +215,16 @@ c_db_my_query(void) {
|
||||
free(start);
|
||||
|
||||
MYDDAS_STATS_CON_GET_TOTAL_TIME_DBSERVER(node,total_time);
|
||||
|
||||
/* Automacally updates the MYDDAS_STRUCTURE */
|
||||
/* Automacally updates the MYDDAS_STRUCTURE */
|
||||
myddas_stats_add_time(total_time,diff,total_time);
|
||||
MYDDAS_STATS_CON_GET_TOTAL_TIME_DBSERVER_COUNT(node,count);
|
||||
MYDDAS_STATS_CON_SET_TOTAL_TIME_DBSERVER_COUNT(node,++count);
|
||||
|
||||
myddas_stats_move_time(diff,node->lastTimeofDBServer);
|
||||
MYDDAS_STATS_TIME time = NULL;
|
||||
MYDDAS_STATS_CON_GET_LAST_TIME_DBSERVER(node,time);
|
||||
myddas_stats_move_time(diff,time);
|
||||
MYDDAS_STATS_CON_GET_LAST_TIME_DBSERVER_COUNT(node,count);
|
||||
MYDDAS_STATS_CON_SET_LAST_TIME_DBSERVER_COUNT(node,++count);
|
||||
#endif
|
||||
|
||||
/* guardar os tuplos do lado do cliente */
|
||||
@ -244,11 +253,16 @@ c_db_my_query(void) {
|
||||
free(start);
|
||||
|
||||
MYDDAS_STATS_CON_GET_TOTAL_TIME_TRANSFERING(node,total_time);
|
||||
|
||||
/* Automacally updates the MYDDAS_STRUCTURE */
|
||||
myddas_stats_add_time(total_time,diff,total_time);
|
||||
MYDDAS_STATS_CON_GET_TOTAL_TIME_TRANSFERING_COUNT(node,count);
|
||||
MYDDAS_STATS_CON_SET_TOTAL_TIME_TRANSFERING_COUNT(node,++count);
|
||||
|
||||
myddas_stats_move_time(diff,node->lastFromDBServer);
|
||||
time = NULL;
|
||||
MYDDAS_STATS_CON_GET_LAST_TIME_TRANSFERING(node,time);
|
||||
MYDDAS_STATS_CON_GET_LAST_TIME_TRANSFERING_COUNT(node,count);
|
||||
MYDDAS_STATS_CON_SET_LAST_TIME_TRANSFERING_COUNT(node,++count);
|
||||
myddas_stats_move_time(diff,time);
|
||||
|
||||
/* Measure the number of Rows returned from the server */
|
||||
if (res_set != NULL)
|
||||
@ -257,17 +271,19 @@ c_db_my_query(void) {
|
||||
returns a NULL pointer*/
|
||||
|
||||
/* This is only works if we use mysql_store_result */
|
||||
UInt numberRows = mysql_num_rows(res_set);
|
||||
UInt rows;
|
||||
MyddasUInt numberRows = mysql_num_rows(res_set);
|
||||
MyddasUInt rows;
|
||||
|
||||
MYDDAS_STATS_CON_GET_TOTAL_ROWS(node,rows);
|
||||
numberRows = numberRows + rows;
|
||||
MYDDAS_STATS_CON_SET_TOTAL_ROWS(node,numberRows);
|
||||
|
||||
MYDDAS_STATS_CON_GET_TOTAL_ROWS_COUNT(node,count);
|
||||
MYDDAS_STATS_CON_SET_TOTAL_ROWS_COUNT(node,++count);
|
||||
|
||||
/* Calculate the ammount of data sent by the server */
|
||||
UInt total,number_fields = mysql_num_fields(res_set);
|
||||
MyddasUInt total,number_fields = mysql_num_fields(res_set);
|
||||
MYSQL_ROW row;
|
||||
UInt i;
|
||||
MyddasULInt i;
|
||||
total=0;
|
||||
while ((row = mysql_fetch_row(res_set)) != NULL){
|
||||
mysql_field_seek(res_set,0);
|
||||
@ -278,11 +294,15 @@ c_db_my_query(void) {
|
||||
}
|
||||
}
|
||||
MYDDAS_STATS_CON_SET_LAST_BYTES_TRANSFERING_FROM_DBSERVER(node,total);
|
||||
UInt bytes;
|
||||
MYDDAS_STATS_CON_GET_LAST_BYTES_TRANSFERING_FROM_DBSERVER_COUNT(node,count);
|
||||
MYDDAS_STATS_CON_SET_LAST_BYTES_TRANSFERING_FROM_DBSERVER_COUNT(node,++count);
|
||||
|
||||
MyddasUInt bytes = 0;
|
||||
MYDDAS_STATS_CON_GET_TOTAL_BYTES_TRANSFERING_FROM_DBSERVER(node,bytes);
|
||||
total = total + bytes;
|
||||
MYDDAS_STATS_CON_SET_TOTAL_BYTES_TRANSFERING_FROM_DBSERVER(node,total);
|
||||
MYDDAS_STATS_CON_GET_TOTAL_BYTES_TRANSFERING_FROM_DBSERVER_COUNT(node,count);
|
||||
MYDDAS_STATS_CON_SET_TOTAL_BYTES_TRANSFERING_FROM_DBSERVER_COUNT(node,++count);
|
||||
mysql_data_seek(res_set,0);
|
||||
}
|
||||
#endif
|
||||
@ -466,6 +486,7 @@ c_db_my_row(void) {
|
||||
/* Measure time used by the
|
||||
c_db_my_row function */
|
||||
MYDDAS_STATS_TIME start,end,total_time,diff;
|
||||
MyddasULInt count = 0;
|
||||
start = myddas_stats_walltime();
|
||||
#endif
|
||||
Term arg_result_set = Deref(ARG1);
|
||||
@ -535,7 +556,9 @@ c_db_my_row(void) {
|
||||
|
||||
MYDDAS_STATS_GET_DB_ROW_FUNCTION(total_time);
|
||||
myddas_stats_add_time(total_time,diff,total_time);
|
||||
|
||||
MYDDAS_STATS_GET_DB_ROW_FUNCTION_COUNT(count);
|
||||
MYDDAS_STATS_SET_DB_ROW_FUNCTION_COUNT(++count);
|
||||
|
||||
free(diff);
|
||||
#endif /* MYDDAS_STATS */
|
||||
return TRUE;
|
||||
@ -554,8 +577,10 @@ c_db_my_row(void) {
|
||||
free(end);
|
||||
free(start);
|
||||
|
||||
MYDDAS_STATS_GET_TRANSLATE(total_time);
|
||||
MYDDAS_STATS_GET_DB_ROW_FUNCTION(total_time);
|
||||
myddas_stats_add_time(total_time,diff,total_time);
|
||||
MYDDAS_STATS_GET_DB_ROW_FUNCTION_COUNT(count);
|
||||
MYDDAS_STATS_SET_DB_ROW_FUNCTION_COUNT(++count);
|
||||
|
||||
free(diff);
|
||||
#endif /* MYDDAS_STATS */
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include <string.h>
|
||||
#include "Yap.h"
|
||||
#include "Yatom.h"
|
||||
#include "myddas_util.h"
|
||||
#include "myddas.h"
|
||||
#include "cut_c.h"
|
||||
#include <sql.h>
|
||||
#include <sqlucode.h>
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include "Yap.h"
|
||||
#include "Yatom.h"
|
||||
#include "cut_c.h"
|
||||
#include "myddas_util.h"
|
||||
#include "myddas.h"
|
||||
#include <stdlib.h>
|
||||
#include "myddas_structs.h"
|
||||
#ifdef MYDDAS_STATS
|
||||
@ -329,7 +329,7 @@ c_db_stats_walltime(void){
|
||||
#endif
|
||||
}
|
||||
|
||||
static int
|
||||
static Int
|
||||
c_db_stats_translate(void){
|
||||
Term arg_start = Deref(ARG1);
|
||||
Term arg_end = Deref(ARG2);
|
||||
@ -353,6 +353,9 @@ c_db_stats_translate(void){
|
||||
|
||||
diff = myddas_stats_time_copy_to_final(diff);
|
||||
myddas_stats_add_time(total_time,diff,total_time);
|
||||
MyddasULInt count;
|
||||
MYDDAS_STATS_GET_TRANSLATE_COUNT(count);
|
||||
MYDDAS_STATS_SET_TRANSLATE_COUNT(++count);
|
||||
|
||||
free(diff);
|
||||
|
||||
@ -370,27 +373,82 @@ static Int
|
||||
c_db_stats_time(void){
|
||||
Term arg_reference = Deref(ARG1);
|
||||
Term arg_time = Deref(ARG2);
|
||||
|
||||
MYDDAS_STATS_TIME time = (MYDDAS_STATS_TIME )IntegerOfTerm(arg_reference);
|
||||
|
||||
Functor functor = Yap_MkFunctor(Yap_LookupAtom("myddas_time"),5);
|
||||
Term time_numbers[5];
|
||||
Term final_term;
|
||||
|
||||
int time_number;
|
||||
MYDDAS_STATS_STRUCT struc = (MYDDAS_STATS_STRUCT)IntegerOfTerm(arg_reference);
|
||||
Functor functor_count = Yap_MkFunctor(Yap_LookupAtom("count"),1);
|
||||
Term count_number[1];
|
||||
Functor unit;
|
||||
Term number[1];
|
||||
|
||||
time_number = MYDDAS_STATS_TIME_HOURS(time);
|
||||
time_numbers[0] = MkIntegerTerm(time_number);
|
||||
time_number = MYDDAS_STATS_TIME_MINUTES(time);
|
||||
time_numbers[1] = MkIntegerTerm(time_number);
|
||||
time_number = MYDDAS_STATS_TIME_SECONDS(time);
|
||||
time_numbers[2] = MkIntegerTerm(time_number);
|
||||
time_number = MYDDAS_STATS_TIME_MILISECONDS(time);
|
||||
time_numbers[3] = MkIntegerTerm(time_number);
|
||||
time_number = MYDDAS_STATS_TIME_MICROSECONDS(time);
|
||||
time_numbers[4] = MkIntegerTerm(time_number);
|
||||
switch(struc->type){
|
||||
|
||||
case integer:
|
||||
{
|
||||
Functor functor = Yap_MkFunctor(Yap_LookupAtom("myddas_integer"),2);
|
||||
Term integer_number[1];
|
||||
MyddasULInt integer;
|
||||
|
||||
if (!Yap_unify(arg_time, Yap_MkApplTerm(functor,5,time_numbers))){
|
||||
unit = Yap_MkFunctor(Yap_LookupAtom("number"),1);
|
||||
integer = struc->u.integer.integer;
|
||||
number[0] = MkIntegerTerm(integer);
|
||||
integer_number[0] = Yap_MkApplTerm(unit,1,number);;
|
||||
|
||||
count_number[0] = MkIntegerTerm(struc->count);
|
||||
integer_number[1] = Yap_MkApplTerm(functor_count,1,count_number);
|
||||
final_term = Yap_MkApplTerm(functor,2,integer_number);
|
||||
break;
|
||||
}
|
||||
|
||||
case time_str:
|
||||
{
|
||||
MYDDAS_STATS_TIME time = struc->u.time_str.time_str;
|
||||
|
||||
Functor functor = Yap_MkFunctor(Yap_LookupAtom("myddas_time"),6);
|
||||
Term time_numbers[6];
|
||||
MyddasUInt time_number;
|
||||
|
||||
unit = Yap_MkFunctor(Yap_LookupAtom("hours"),1);
|
||||
time_number = MYDDAS_STATS_TIME_HOURS(time);
|
||||
number[0] = MkIntegerTerm(time_number);
|
||||
time_numbers[0] = Yap_MkApplTerm(unit,1,number);;
|
||||
|
||||
unit = Yap_MkFunctor(Yap_LookupAtom("minutes"),1);
|
||||
time_number = MYDDAS_STATS_TIME_MINUTES(time);
|
||||
number[0] = MkIntegerTerm(time_number);
|
||||
time_numbers[1] = Yap_MkApplTerm(unit,1,number);;
|
||||
|
||||
unit = Yap_MkFunctor(Yap_LookupAtom("seconds"),1);
|
||||
time_number = MYDDAS_STATS_TIME_SECONDS(time);
|
||||
number[0] = MkIntegerTerm(time_number);
|
||||
time_numbers[2] = Yap_MkApplTerm(unit,1,number);;
|
||||
|
||||
unit = Yap_MkFunctor(Yap_LookupAtom("miliseconds"),1);
|
||||
time_number = MYDDAS_STATS_TIME_MILISECONDS(time);
|
||||
number[0] = MkIntegerTerm(time_number);
|
||||
time_numbers[3] = Yap_MkApplTerm(unit,1,number);;
|
||||
|
||||
unit = Yap_MkFunctor(Yap_LookupAtom("microseconds"),1);
|
||||
time_number = MYDDAS_STATS_TIME_MICROSECONDS(time);
|
||||
number[0] = MkIntegerTerm(time_number);
|
||||
time_numbers[4] = Yap_MkApplTerm(unit,1,number);;
|
||||
|
||||
count_number[0] = MkIntegerTerm(struc->count);
|
||||
time_numbers[5] = Yap_MkApplTerm(functor_count,1,count_number);
|
||||
final_term = Yap_MkApplTerm(functor,6,time_numbers);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
#ifdef DEBUG
|
||||
printf ("ERROR: c_db_stats_time unknow option\n");
|
||||
#endif
|
||||
return FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!Yap_unify(arg_time,final_term )){
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -403,30 +461,33 @@ c_db_stats(void) {
|
||||
Term arg_conn = Deref(ARG1);
|
||||
Term arg_list = Deref(ARG2);
|
||||
|
||||
Int *conn = (Int *) (IntegerOfTerm(arg_conn));
|
||||
MyddasPointer *conn = (MyddasPointer *) (IntegerOfTerm(arg_conn));
|
||||
|
||||
// TODO
|
||||
if (get_myddas_top() == 0 ){ /* We want all the statistics */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
MYDDAS_STATS_STRUCT str;
|
||||
MYDDAS_UTIL_CONNECTION
|
||||
node = myddas_util_search_connection(conn);
|
||||
node = myddas_util_search_connection(conn);
|
||||
Term head, list;
|
||||
list = arg_list;
|
||||
|
||||
MYDDAS_STATS_TIME time;
|
||||
UInt number;
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
MYDDAS_STATS_TIME time = NULL;
|
||||
#endif
|
||||
//[Index 1] -> Total Number of Rows by connection
|
||||
//Total number of Rows returned by the server
|
||||
//WARNING: only works with store_result
|
||||
head = HeadOfTerm(list);
|
||||
list = TailOfTerm(list);
|
||||
MYDDAS_STATS_CON_GET_TOTAL_ROWS(node,number);
|
||||
Yap_unify(head, MkIntegerTerm(number));
|
||||
str = myddas_stats_get_stat(node->stats,5);
|
||||
Yap_unify(head, MkIntegerTerm((MyddasInt)str));
|
||||
#ifdef DEBUG
|
||||
MyddasUInt number = 0;
|
||||
|
||||
MYDDAS_STATS_CON_GET_TOTAL_ROWS(node,number);
|
||||
printf ("Total Number of Rows returned from the Server\n");
|
||||
printf ("%lu\n\n",(unsigned long)number);
|
||||
#endif
|
||||
@ -435,9 +496,11 @@ c_db_stats(void) {
|
||||
// processing all the SQL Querys
|
||||
head = HeadOfTerm(list);
|
||||
list = TailOfTerm(list);
|
||||
MYDDAS_STATS_CON_GET_TOTAL_TIME_DBSERVER(node,time);
|
||||
Yap_unify(head, MkIntegerTerm((Int)time));
|
||||
|
||||
str = myddas_stats_get_stat(node->stats,1);
|
||||
Yap_unify(head, MkIntegerTerm((MyddasInt)str));
|
||||
#ifdef DEBUG
|
||||
MYDDAS_STATS_CON_GET_TOTAL_TIME_DBSERVER(node,time);
|
||||
printf ("Reference to time Spent by the Server, on all the SQL Querys\n");
|
||||
MYDDAS_STATS_PRINT_TIME_STRUCT(time);
|
||||
printf ("\n\n");
|
||||
@ -447,9 +510,11 @@ c_db_stats(void) {
|
||||
// processing a the last SQL Query
|
||||
head = HeadOfTerm(list);
|
||||
list = TailOfTerm(list);
|
||||
MYDDAS_STATS_CON_GET_LAST_TIME_DBSERVER(node,time);
|
||||
Yap_unify(head, MkIntegerTerm((Int)time));
|
||||
|
||||
str = myddas_stats_get_stat(node->stats,2);
|
||||
Yap_unify(head, MkIntegerTerm((MyddasInt)str));
|
||||
#ifdef DEBUG
|
||||
MYDDAS_STATS_CON_GET_LAST_TIME_DBSERVER(node,time);
|
||||
printf ("Reference to time Spent by the Server, on the last SQL Query\n");
|
||||
MYDDAS_STATS_PRINT_TIME_STRUCT(time);
|
||||
printf ("\n\n");
|
||||
@ -459,9 +524,11 @@ c_db_stats(void) {
|
||||
// transfering all the results of the SQL Querys
|
||||
head = HeadOfTerm(list);
|
||||
list = TailOfTerm(list);
|
||||
MYDDAS_STATS_CON_GET_TOTAL_TIME_TRANSFERING(node,time);
|
||||
Yap_unify(head, MkIntegerTerm((Int)time));
|
||||
|
||||
str = myddas_stats_get_stat(node->stats,3);
|
||||
Yap_unify(head, MkIntegerTerm((MyddasInt)str));
|
||||
#ifdef DEBUG
|
||||
MYDDAS_STATS_CON_GET_TOTAL_TIME_TRANSFERING(node,time);
|
||||
printf ("Refence to time Spent by the Server, transfering all the results SQL Query\n");
|
||||
MYDDAS_STATS_PRINT_TIME_STRUCT(time);
|
||||
printf ("\n\n");
|
||||
@ -471,9 +538,11 @@ c_db_stats(void) {
|
||||
// transfering the result of the last SQL Query
|
||||
head = HeadOfTerm(list);
|
||||
list = TailOfTerm(list);
|
||||
MYDDAS_STATS_CON_GET_LAST_TIME_TRANSFERING(node,time);
|
||||
Yap_unify(head, MkIntegerTerm((Int)time));
|
||||
|
||||
str = myddas_stats_get_stat(node->stats,4);
|
||||
Yap_unify(head, MkIntegerTerm((MyddasInt)str));
|
||||
#ifdef DEBUG
|
||||
MYDDAS_STATS_CON_GET_LAST_TIME_TRANSFERING(node,time);
|
||||
printf ("Reference to time Spent by the Server, transfering the result of the last SQL Query\n");
|
||||
MYDDAS_STATS_PRINT_TIME_STRUCT(time);
|
||||
printf ("\n\n");
|
||||
@ -483,9 +552,12 @@ c_db_stats(void) {
|
||||
// db_row_function
|
||||
head = HeadOfTerm(list);
|
||||
list = TailOfTerm(list);
|
||||
MYDDAS_STATS_GET_DB_ROW_FUNCTION(time);
|
||||
Yap_unify(head, MkIntegerTerm((Int)time));
|
||||
|
||||
str = myddas_stats_get_stat(Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_statistics->stats,1);
|
||||
|
||||
Yap_unify(head, MkIntegerTerm((MyddasInt)str));
|
||||
#ifdef DEBUG
|
||||
MYDDAS_STATS_GET_DB_ROW_FUNCTION(time);
|
||||
printf ("Reference to time Spent by the db_row_function\n");
|
||||
MYDDAS_STATS_PRINT_TIME_STRUCT(time);
|
||||
printf ("\n\n");
|
||||
@ -495,41 +567,49 @@ c_db_stats(void) {
|
||||
// DB Server on all SQL Querys
|
||||
head = HeadOfTerm(list);
|
||||
list = TailOfTerm(list);
|
||||
MYDDAS_STATS_CON_GET_TOTAL_BYTES_TRANSFERING_FROM_DBSERVER(node,number);
|
||||
Yap_unify(head, MkIntegerTerm(number));
|
||||
|
||||
str = myddas_stats_get_stat(node->stats,6);
|
||||
Yap_unify(head, MkIntegerTerm((MyddasPointer)str));
|
||||
#ifdef DEBUG
|
||||
MYDDAS_STATS_CON_GET_TOTAL_BYTES_TRANSFERING_FROM_DBSERVER(node,number);
|
||||
printf ("Bytes Transfered by the DB Server from all querys\n");
|
||||
printf ("%lu\n\n",(unsigned long)number);
|
||||
printf ("%llu\n\n",(MyddasULInt)number);
|
||||
#endif
|
||||
|
||||
//[Index 8] -> Total of Bytes Transfered by the
|
||||
// DB Server on the last SQL Query
|
||||
head = HeadOfTerm(list);
|
||||
list = TailOfTerm(list);
|
||||
MYDDAS_STATS_CON_GET_LAST_BYTES_TRANSFERING_FROM_DBSERVER(node,number);
|
||||
Yap_unify(head, MkIntegerTerm(number));
|
||||
#ifdef DEBUG
|
||||
printf ("Bytes Transfered by the DB Server on the last query\n");
|
||||
printf ("%lu\n\n",(unsigned long)number);
|
||||
#endif
|
||||
|
||||
str = myddas_stats_get_stat(node->stats,7);
|
||||
Yap_unify(head, MkIntegerTerm((MyddasPointer)str));
|
||||
#ifdef DEBUG
|
||||
MYDDAS_STATS_CON_GET_LAST_BYTES_TRANSFERING_FROM_DBSERVER(node,number);
|
||||
printf ("Bytes Transfered by the DB Server on the last query\n");
|
||||
printf ("%llu\n\n",(MyddasULInt)number);
|
||||
#endif
|
||||
//[Index 9] -> Number of querys made to the DBserver
|
||||
head = HeadOfTerm(list);
|
||||
list = TailOfTerm(list);
|
||||
MYDDAS_STATS_CON_GET_NUMBER_QUERIES_MADE(node,number);
|
||||
Yap_unify(head, MkIntegerTerm(number));
|
||||
|
||||
str = myddas_stats_get_stat(node->stats,8);
|
||||
Yap_unify(head, MkIntegerTerm((MyddasPointer)str));
|
||||
#ifdef DEBUG
|
||||
MYDDAS_STATS_CON_GET_NUMBER_QUERIES_MADE(node,number);
|
||||
printf ("Number of Querys made to the server\n");
|
||||
printf ("%lu\n\n",(unsigned long)number);
|
||||
printf ("%llu\n\n",(MyddasULInt)number);
|
||||
#endif
|
||||
|
||||
//[Index 10] -> Total of Time Spent by the
|
||||
// translate predicate
|
||||
head = HeadOfTerm(list);
|
||||
list = TailOfTerm(list);
|
||||
MYDDAS_STATS_GET_TRANSLATE(time);
|
||||
Yap_unify(head, MkIntegerTerm((Int)time));
|
||||
|
||||
str = myddas_stats_get_stat(Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_statistics->stats,2);
|
||||
Yap_unify(head, MkIntegerTerm((Int)str));
|
||||
|
||||
#ifdef DEBUG
|
||||
MYDDAS_STATS_GET_TRANSLATE(time);
|
||||
printf ("Reference to time Spent by the translate predicate\n");
|
||||
MYDDAS_STATS_PRINT_TIME_STRUCT(time);
|
||||
printf ("\n\n");
|
||||
|
@ -4,16 +4,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#if defined MYDDAS_ODBC || defined MYDDAS_MYSQL
|
||||
#if defined MYDDAS_STATS
|
||||
|
||||
#if defined MYDDAS_STATS || defined MYDDAS_TOP_LEVEL
|
||||
static void
|
||||
myddas_stats_time_subtract (unsigned long *, unsigned long *, MYDDAS_STATS_TIME, MYDDAS_STATS_TIME);
|
||||
static void
|
||||
myddas_stats_add_seconds_time(MYDDAS_STATS_TIME,unsigned long, unsigned long);
|
||||
static void
|
||||
myddas_stats_integrity_of_time(MYDDAS_STATS_TIME);
|
||||
#endif
|
||||
|
||||
|
||||
/* Documentation: Time Units
|
||||
@ -62,8 +54,12 @@ long int tv_nsec -> This is the rest of the elapsed time (a fraction
|
||||
|
||||
*/
|
||||
|
||||
#if defined MYDDAS_STATS || defined MYDDAS_TOP_LEVEL
|
||||
|
||||
static void
|
||||
myddas_stats_time_subtract (unsigned long *, unsigned long *, MYDDAS_STATS_TIME, MYDDAS_STATS_TIME);
|
||||
static void
|
||||
myddas_stats_add_seconds_time(MYDDAS_STATS_TIME,unsigned long, unsigned long);
|
||||
static void
|
||||
myddas_stats_integrity_of_time(MYDDAS_STATS_TIME);
|
||||
|
||||
/* Be shore to delete MYDDAS_STATS_TIME structure */
|
||||
MYDDAS_STATS_TIME
|
||||
@ -168,8 +164,8 @@ myddas_stats_time_copy_to_final(MYDDAS_STATS_TIME t_copy){
|
||||
|
||||
static void
|
||||
myddas_stats_add_seconds_time(MYDDAS_STATS_TIME myddas_time,
|
||||
unsigned long sec,
|
||||
unsigned long usec){
|
||||
unsigned long sec,
|
||||
unsigned long usec){
|
||||
|
||||
short hours = sec / 3600;
|
||||
sec %= 3600;
|
||||
@ -238,7 +234,40 @@ myddas_stats_integrity_of_time(MYDDAS_STATS_TIME myddas_time){
|
||||
}
|
||||
|
||||
|
||||
MYDDAS_STATS_STRUCT
|
||||
myddas_stats_initialize_stat(MYDDAS_STATS_STRUCT stat,int type){
|
||||
|
||||
MYDDAS_STATS_STRUCT temp_str = stat;
|
||||
|
||||
if (stat == NULL){
|
||||
stat = (MYDDAS_STATS_STRUCT) malloc (sizeof(struct myddas_stats_struct));
|
||||
temp_str = stat;
|
||||
} else {
|
||||
for (;temp_str->next != NULL;temp_str = temp_str->next);
|
||||
temp_str->next = (MYDDAS_STATS_STRUCT) malloc (sizeof(struct myddas_stats_struct));
|
||||
temp_str = temp_str->next;
|
||||
}
|
||||
|
||||
if (type == time_str){
|
||||
MYDDAS_STATS_INITIALIZE_TIME_STRUCT(temp_str->u.time_str.time_str,time_final);
|
||||
} else {
|
||||
temp_str->u.integer.integer = 0;
|
||||
}
|
||||
temp_str->type = type;
|
||||
temp_str->count = 0;
|
||||
temp_str->next = NULL;
|
||||
return temp_str;
|
||||
}
|
||||
|
||||
MYDDAS_STATS_STRUCT
|
||||
myddas_stats_get_stat(MYDDAS_STATS_STRUCT stat,int index){
|
||||
|
||||
MYDDAS_STATS_STRUCT temp = stat;
|
||||
|
||||
for (;index>1;index--){
|
||||
temp = temp->next;
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
#endif /* MYDDAS_STATS || MYDDAS_TOP_LEVEL */
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1,8 +1,7 @@
|
||||
#ifndef __MYDDAS_STATISTICS_H__
|
||||
#define __MYDDAS_STATISTICS_H__
|
||||
|
||||
|
||||
#if defined MYDDAS_STATS || defined MYDDAS_TOP_LEVEL
|
||||
#ifdef MYDDAS_STATS
|
||||
|
||||
#define MYDDAS_STATS_TIME_HOURS(TIME) TIME->u.time_final.hours;
|
||||
#define MYDDAS_STATS_TIME_MINUTES(TIME) TIME->u.time_final.minutes;
|
||||
@ -10,6 +9,7 @@
|
||||
#define MYDDAS_STATS_TIME_MILISECONDS(TIME) TIME->u.time_final.miliseconds;
|
||||
#define MYDDAS_STATS_TIME_MICROSECONDS(TIME) TIME->u.time_final.microseconds;
|
||||
|
||||
#ifdef DEBUG
|
||||
#define MYDDAS_STATS_PRINT_TIME_STRUCT(TIME) \
|
||||
if (TIME->type == time_final) { \
|
||||
printf ("%d Hours, %d Minutes, %d Seconds, %d Miliseconds, %d Microseconds", \
|
||||
@ -23,7 +23,7 @@
|
||||
TIME->u.time_copy.tv_sec, \
|
||||
TIME->u.time_copy.tv_usec); \
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#define MYDDAS_STATS_INITIALIZE_TIME_STRUCT(TIME,TYPE) \
|
||||
TIME = (MYDDAS_STATS_TIME) malloc (sizeof(struct myddas_stats_time_struct)); \
|
||||
@ -41,62 +41,138 @@
|
||||
TIME->u.time_final.microseconds = 0; \
|
||||
}
|
||||
|
||||
|
||||
MYDDAS_STATS_TIME
|
||||
myddas_stats_walltime(void);
|
||||
void
|
||||
myddas_stats_add_time(MYDDAS_STATS_TIME, MYDDAS_STATS_TIME,MYDDAS_STATS_TIME);
|
||||
void
|
||||
myddas_stats_subtract_time(MYDDAS_STATS_TIME, MYDDAS_STATS_TIME,MYDDAS_STATS_TIME);
|
||||
void
|
||||
myddas_stats_move_time(MYDDAS_STATS_TIME,MYDDAS_STATS_TIME);
|
||||
MYDDAS_STATS_TIME
|
||||
myddas_stats_time_copy_to_final(MYDDAS_STATS_TIME);
|
||||
|
||||
#endif
|
||||
/*
|
||||
Stats [1] - Total Time spent on the db_row function
|
||||
Stats [2] - Total Time spent on the translate/3 predicate
|
||||
*/
|
||||
#define MYDDAS_STATS_INITIALIZE_GLOBAL_STATS(STATS) \
|
||||
short i; \
|
||||
\
|
||||
/* For the time statistics */ \
|
||||
\
|
||||
/* First */ \
|
||||
STATS = myddas_stats_initialize_stat(STATS,time_str); \
|
||||
for(i=0;i<1;i++){ \
|
||||
myddas_stats_initialize_stat(STATS,time_str); \
|
||||
}
|
||||
|
||||
|
||||
#ifdef MYDDAS_STATS
|
||||
|
||||
#define MYDDAS_STATS_CON_GET_TOTAL_ROWS(NODE,NUMBER) \
|
||||
NUMBER = NODE->totalNumberOfRows;
|
||||
#define MYDDAS_STATS_CON_SET_TOTAL_ROWS(NODE,NUMBER) \
|
||||
NODE->totalNumberOfRows = NUMBER;
|
||||
/*
|
||||
Stats [1] - Total of Time Spent by the DB Server processing all the SQL Querys
|
||||
Stats [2] - Total of Time Spent by the DB Server processing the last SQL Query
|
||||
Stats [3] - Total of Time Spent by the DB Server transfering all the results of the SQL Querys
|
||||
Stats [4] - Total of Time Spent by the DB Server transfering the result of the last SQL Query
|
||||
|
||||
Stats [5] - Total number of Rows returned by the server
|
||||
Stats [6] - Total of Bytes Transfered by the DB Server on all SQL Querys
|
||||
Stats [7] - Total of Bytes Transfered by the DB Server on the last SQL Query
|
||||
Stats [8] - Number of querys made to the DBserver
|
||||
*/
|
||||
#define MYDDAS_STATS_INITIALIZE_CONNECTION_STATS(STATS) \
|
||||
short i; \
|
||||
\
|
||||
/* For the time statistics */ \
|
||||
\
|
||||
/* First */ \
|
||||
STATS = myddas_stats_initialize_stat(STATS,time_str); \
|
||||
for(i=0;i<3;i++){ \
|
||||
myddas_stats_initialize_stat(STATS,time_str); \
|
||||
} \
|
||||
\
|
||||
/* For number statistics*/ \
|
||||
for (i=0;i<4;i++){ \
|
||||
myddas_stats_initialize_stat(STATS,integer); \
|
||||
} \
|
||||
|
||||
#define MYDDAS_STATS_CON_GET_TOTAL_TIME_DBSERVER(NODE,TIME) \
|
||||
TIME = NODE->totalTimeofDBServer;
|
||||
TIME = myddas_stats_get_stat(NODE->stats,1)->u.time_str.time_str;
|
||||
#define MYDDAS_STATS_CON_GET_TOTAL_TIME_DBSERVER_COUNT(NODE,COUNT) \
|
||||
COUNT = myddas_stats_get_stat(NODE->stats,1)->count;
|
||||
#define MYDDAS_STATS_CON_SET_TOTAL_TIME_DBSERVER_COUNT(NODE,COUNT) \
|
||||
myddas_stats_get_stat(NODE->stats,1)->count = COUNT;
|
||||
|
||||
#define MYDDAS_STATS_CON_GET_LAST_TIME_DBSERVER(NODE,TIME) \
|
||||
TIME = NODE->lastTimeofDBServer;
|
||||
TIME = myddas_stats_get_stat(NODE->stats,2)->u.time_str.time_str;
|
||||
#define MYDDAS_STATS_CON_GET_LAST_TIME_DBSERVER_COUNT(NODE,COUNT) \
|
||||
COUNT = myddas_stats_get_stat(NODE->stats,2)->count;
|
||||
#define MYDDAS_STATS_CON_SET_LAST_TIME_DBSERVER_COUNT(NODE,COUNT) \
|
||||
myddas_stats_get_stat(NODE->stats,2)->count = COUNT;
|
||||
|
||||
#define MYDDAS_STATS_CON_GET_TOTAL_TIME_TRANSFERING(NODE,TIME) \
|
||||
TIME = NODE->totalFromDBServer;
|
||||
TIME = myddas_stats_get_stat(NODE->stats,3)->u.time_str.time_str;
|
||||
#define MYDDAS_STATS_CON_GET_TOTAL_TIME_TRANSFERING_COUNT(NODE,COUNT) \
|
||||
COUNT = myddas_stats_get_stat(NODE->stats,3)->count;
|
||||
#define MYDDAS_STATS_CON_SET_TOTAL_TIME_TRANSFERING_COUNT(NODE,COUNT) \
|
||||
myddas_stats_get_stat(NODE->stats,3)->count = COUNT;
|
||||
|
||||
#define MYDDAS_STATS_CON_GET_LAST_TIME_TRANSFERING(NODE,TIME) \
|
||||
TIME = NODE->lastFromDBServer;
|
||||
TIME = myddas_stats_get_stat(NODE->stats,4)->u.time_str.time_str;
|
||||
#define MYDDAS_STATS_CON_GET_LAST_TIME_TRANSFERING_COUNT(NODE,COUNT) \
|
||||
COUNT = myddas_stats_get_stat(NODE->stats,4)->count;
|
||||
#define MYDDAS_STATS_CON_SET_LAST_TIME_TRANSFERING_COUNT(NODE,COUNT) \
|
||||
myddas_stats_get_stat(NODE->stats,4)->count = COUNT;
|
||||
|
||||
|
||||
#define MYDDAS_STATS_CON_GET_TOTAL_ROWS(NODE,NUMBER) \
|
||||
NUMBER = myddas_stats_get_stat(NODE->stats,5)->u.integer.integer;
|
||||
#define MYDDAS_STATS_CON_SET_TOTAL_ROWS(NODE,NUMBER) \
|
||||
myddas_stats_get_stat(NODE->stats,5)->u.integer.integer = NUMBER;
|
||||
#define MYDDAS_STATS_CON_GET_TOTAL_ROWS_COUNT(NODE,COUNT) \
|
||||
COUNT = myddas_stats_get_stat(NODE->stats,5)->count;
|
||||
#define MYDDAS_STATS_CON_SET_TOTAL_ROWS_COUNT(NODE,COUNT) \
|
||||
myddas_stats_get_stat(NODE->stats,5)->count = COUNT;
|
||||
|
||||
#define MYDDAS_STATS_CON_GET_LAST_BYTES_TRANSFERING_FROM_DBSERVER(NODE,NUMBER) \
|
||||
NUMBER = NODE->lastBytesTransfered;
|
||||
#define MYDDAS_STATS_CON_SET_LAST_BYTES_TRANSFERING_FROM_DBSERVER(NODE,NUMBER) \
|
||||
NODE->lastBytesTransfered = NUMBER;
|
||||
|
||||
#define MYDDAS_STATS_CON_GET_TOTAL_BYTES_TRANSFERING_FROM_DBSERVER(NODE,NUMBER) \
|
||||
NUMBER = NODE->totalBytesTransfered;
|
||||
NUMBER = myddas_stats_get_stat(NODE->stats,6)->u.integer.integer;
|
||||
#define MYDDAS_STATS_CON_SET_TOTAL_BYTES_TRANSFERING_FROM_DBSERVER(NODE,NUMBER) \
|
||||
NODE->totalBytesTransfered = NUMBER;
|
||||
myddas_stats_get_stat(NODE->stats,6)->u.integer.integer = NUMBER;
|
||||
#define MYDDAS_STATS_CON_GET_TOTAL_BYTES_TRANSFERING_FROM_DBSERVER_COUNT(NODE,COUNT) \
|
||||
COUNT = myddas_stats_get_stat(NODE->stats,6)->count;
|
||||
#define MYDDAS_STATS_CON_SET_TOTAL_BYTES_TRANSFERING_FROM_DBSERVER_COUNT(NODE,COUNT) \
|
||||
myddas_stats_get_stat(NODE->stats,6)->count = COUNT;
|
||||
|
||||
#define MYDDAS_STATS_CON_GET_LAST_BYTES_TRANSFERING_FROM_DBSERVER(NODE,NUMBER) \
|
||||
NUMBER = myddas_stats_get_stat(NODE->stats,7)->u.integer.integer;
|
||||
#define MYDDAS_STATS_CON_SET_LAST_BYTES_TRANSFERING_FROM_DBSERVER(NODE,NUMBER) \
|
||||
myddas_stats_get_stat(NODE->stats,7)->u.integer.integer = NUMBER;
|
||||
#define MYDDAS_STATS_CON_GET_LAST_BYTES_TRANSFERING_FROM_DBSERVER_COUNT(NODE,COUNT) \
|
||||
COUNT = myddas_stats_get_stat(NODE->stats,7)->count;
|
||||
#define MYDDAS_STATS_CON_SET_LAST_BYTES_TRANSFERING_FROM_DBSERVER_COUNT(NODE,COUNT) \
|
||||
myddas_stats_get_stat(NODE->stats,7)->count = COUNT;
|
||||
|
||||
#define MYDDAS_STATS_CON_GET_NUMBER_QUERIES_MADE(NODE,NUMBER) \
|
||||
NUMBER = NODE->total_querys_made;
|
||||
NUMBER = myddas_stats_get_stat(NODE->stats,8)->u.integer.integer;
|
||||
#define MYDDAS_STATS_CON_SET_NUMBER_QUERIES_MADE(NODE,NUMBER) \
|
||||
NODE->total_querys_made = NUMBER;
|
||||
myddas_stats_get_stat(NODE->stats,8)->u.integer.integer = NUMBER;
|
||||
#define MYDDAS_STATS_CON_GET_NUMBER_QUERIES_MADE_COUNT(NODE,COUNT) \
|
||||
COUNT = myddas_stats_get_stat(NODE->stats,8)->count;
|
||||
#define MYDDAS_STATS_CON_SET_NUMBER_QUERIES_MADE_COUNT(NODE,COUNT) \
|
||||
myddas_stats_get_stat(NODE->stats,8)->count = COUNT;
|
||||
|
||||
#define MYDDAS_STATS_GET_DB_ROW_FUNCTION(TIME) \
|
||||
TIME = Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_statistics->total_db_row;
|
||||
TIME = myddas_stats_get_stat(Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_statistics->stats,1)->u.time_str.time_str;
|
||||
#define MYDDAS_STATS_GET_DB_ROW_FUNCTION_COUNT(COUNT) \
|
||||
COUNT = myddas_stats_get_stat(Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_statistics->stats,1)->count;
|
||||
#define MYDDAS_STATS_SET_DB_ROW_FUNCTION_COUNT(COUNT) \
|
||||
myddas_stats_get_stat(Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_statistics->stats,1)->count = COUNT;
|
||||
|
||||
#define MYDDAS_STATS_GET_TRANSLATE(TIME) \
|
||||
TIME = Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_statistics->total_translate;
|
||||
TIME = myddas_stats_get_stat(Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_statistics->stats,2)->u.time_str.time_str;
|
||||
#define MYDDAS_STATS_GET_TRANSLATE_COUNT(COUNT) \
|
||||
COUNT = myddas_stats_get_stat(Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_statistics->stats,2)->count;
|
||||
#define MYDDAS_STATS_SET_TRANSLATE_COUNT(COUNT) \
|
||||
myddas_stats_get_stat(Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_statistics->stats,2)->count = COUNT;
|
||||
|
||||
MYDDAS_STATS_TIME myddas_stats_walltime(void);
|
||||
void myddas_stats_add_time(MYDDAS_STATS_TIME, MYDDAS_STATS_TIME,MYDDAS_STATS_TIME);
|
||||
void myddas_stats_subtract_time(MYDDAS_STATS_TIME, MYDDAS_STATS_TIME,MYDDAS_STATS_TIME);
|
||||
void myddas_stats_move_time(MYDDAS_STATS_TIME,MYDDAS_STATS_TIME);
|
||||
MYDDAS_STATS_TIME myddas_stats_time_copy_to_final(MYDDAS_STATS_TIME);
|
||||
|
||||
/* Related to the statistics linked list */
|
||||
MYDDAS_STATS_STRUCT myddas_stats_initialize_stat(MYDDAS_STATS_STRUCT,int);
|
||||
MYDDAS_STATS_STRUCT myddas_stats_get_stat(MYDDAS_STATS_STRUCT,int);
|
||||
#endif /* MYDDAS_STATS */
|
||||
|
||||
#endif
|
||||
|
50
MYDDAS/myddas_statistics_structs.h
Normal file
50
MYDDAS/myddas_statistics_structs.h
Normal file
@ -0,0 +1,50 @@
|
||||
#ifndef __MYDDAS_STATISTICS_STRUCTS_H__
|
||||
#define __MYDDAS_STATISTICS_STRUCTS_H__
|
||||
|
||||
#ifdef MYDDAS_STATS
|
||||
|
||||
/* This strucuture holds some global statistics*/
|
||||
struct myddas_global_stats {
|
||||
MYDDAS_STATS_STRUCT stats;
|
||||
};
|
||||
|
||||
/* Structure to hold any kind of statistics */
|
||||
struct myddas_stats_struct{
|
||||
enum {time_str,
|
||||
integer} type;
|
||||
union {
|
||||
struct {
|
||||
MYDDAS_STATS_TIME time_str;
|
||||
} time_str;
|
||||
struct {
|
||||
MyddasULInt integer;
|
||||
} integer;
|
||||
} u;
|
||||
MyddasULInt count;
|
||||
MYDDAS_STATS_STRUCT next;
|
||||
};
|
||||
|
||||
/* Time structure for the MYDDAS Interface */
|
||||
struct myddas_stats_time_struct{
|
||||
enum {time_copy,
|
||||
time_final} type;
|
||||
|
||||
union {
|
||||
struct {
|
||||
unsigned long tv_sec;
|
||||
unsigned long tv_usec;
|
||||
} time_copy;
|
||||
struct {
|
||||
MyddasUSInt hours;
|
||||
MyddasUSInt minutes; //Max 59
|
||||
MyddasUSInt seconds; //Max 59
|
||||
MyddasUSInt miliseconds; //Max 999
|
||||
MyddasUSInt microseconds; //Max 999
|
||||
} time_final;
|
||||
} u;
|
||||
};
|
||||
|
||||
|
||||
#endif /* MYDDAS_STATS */
|
||||
|
||||
#endif
|
@ -1,7 +1,10 @@
|
||||
#ifndef __MYDDAS_STRUCTS_H__
|
||||
#define __MYDDAS_STRUCTS_H__
|
||||
|
||||
#include "myddas_util.h"
|
||||
#include "myddas.h"
|
||||
#ifdef MYDDAS_STATS
|
||||
#include "myddas_statistics_structs.h"
|
||||
#endif
|
||||
|
||||
struct myddas_global {
|
||||
MYDDAS_UTIL_CONNECTION myddas_top_connections;
|
||||
@ -13,17 +16,6 @@ struct myddas_global {
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef MYDDAS_STATS
|
||||
/* This strucuture holds some global statistics*/
|
||||
struct myddas_global_stats {
|
||||
/* Total Time spent on the db_row function */
|
||||
MYDDAS_STATS_TIME total_db_row;
|
||||
|
||||
/* Total Time spent on the translate/3 predicate*/
|
||||
MYDDAS_STATS_TIME total_translate;
|
||||
};
|
||||
#endif /* MYDDAS_STATS */
|
||||
|
||||
struct myddas_list_preds {
|
||||
char *pred_module;
|
||||
char *pred_name;
|
||||
@ -40,33 +32,37 @@ struct myddas_list_connection {
|
||||
MySQL connection, if not then it as the pointer
|
||||
to the ODBC enviromment variable */
|
||||
void *odbc_enviromment;
|
||||
|
||||
#ifdef MYDDAS_STATS
|
||||
/* Total number of Rows returnes from the DataBase Server */
|
||||
unsigned long totalNumberOfRows;
|
||||
|
||||
/* Total Time spent by the DataBase Server
|
||||
processing all querys */
|
||||
MYDDAS_STATS_TIME totalTimeofDBServer;
|
||||
/* Time spent by the DataBase Server, processing
|
||||
the last query */
|
||||
MYDDAS_STATS_TIME lastTimeofDBServer;
|
||||
|
||||
/* Total Time spent by the DataBase Server,
|
||||
transfering all the data to the client */
|
||||
MYDDAS_STATS_TIME totalFromDBServer;
|
||||
/* Time spent by the DataBase Server,
|
||||
transfering the data of the last query */
|
||||
MYDDAS_STATS_TIME lastFromDBServer;
|
||||
|
||||
/* Last bytes transfered from the server */
|
||||
unsigned long totalBytesTransfered;
|
||||
/* Total bytes transfered from the server */
|
||||
unsigned long lastBytesTransfered;
|
||||
|
||||
/* Number of querys made to the Server*/
|
||||
unsigned long total_querys_made;
|
||||
|
||||
MYDDAS_STATS_STRUCT stats;
|
||||
#endif
|
||||
/* #ifdef MYDDAS_STATS */
|
||||
/* /\* Total number of Rows returnes from the DataBase Server *\/ */
|
||||
/* unsigned long totalNumberOfRows; */
|
||||
|
||||
/* /\* Total Time spent by the DataBase Server */
|
||||
/* processing all querys *\/ */
|
||||
/* MYDDAS_STATS_TIME totalTimeofDBServer; */
|
||||
/* /\* Time spent by the DataBase Server, processing */
|
||||
/* the last query *\/ */
|
||||
/* MYDDAS_STATS_TIME lastTimeofDBServer; */
|
||||
|
||||
/* /\* Total Time spent by the DataBase Server, */
|
||||
/* transfering all the data to the client *\/ */
|
||||
/* MYDDAS_STATS_TIME totalFromDBServer; */
|
||||
/* /\* Time spent by the DataBase Server, */
|
||||
/* transfering the data of the last query *\/ */
|
||||
/* MYDDAS_STATS_TIME lastFromDBServer; */
|
||||
|
||||
/* /\* Last bytes transfered from the server *\/ */
|
||||
/* unsigned long totalBytesTransfered; */
|
||||
/* /\* Total bytes transfered from the server *\/ */
|
||||
/* unsigned long lastBytesTransfered; */
|
||||
|
||||
/* /\* Number of querys made to the Server*\/ */
|
||||
/* unsigned long total_querys_made; */
|
||||
|
||||
/* #endif */
|
||||
MYDDAS_UTIL_PREDICATE predicates;
|
||||
|
||||
/* Multi Queries Section */
|
||||
@ -84,26 +80,4 @@ struct myddas_util_query{
|
||||
MYDDAS_UTIL_QUERY next;
|
||||
};
|
||||
|
||||
|
||||
#if defined MYDDAS_STATS || defined MYDDAS_TOP_LEVEL
|
||||
struct myddas_stats_time_struct{
|
||||
enum {time_copy,
|
||||
time_final} type;
|
||||
|
||||
union {
|
||||
struct {
|
||||
unsigned long tv_sec;
|
||||
unsigned long tv_usec;
|
||||
} time_copy;
|
||||
struct {
|
||||
unsigned short hours;
|
||||
unsigned short minutes; //Max 59
|
||||
unsigned short seconds; //Max 59
|
||||
unsigned short miliseconds; //Max 999
|
||||
unsigned short microseconds; //Max 999
|
||||
} time_final;
|
||||
} u;
|
||||
};
|
||||
#endif /* MYDDAS_STATS || MYDDAS_TOP_LEVEL */
|
||||
|
||||
#endif
|
||||
|
@ -19,15 +19,18 @@
|
||||
|
||||
#include "Yap.h"
|
||||
#include "Yatom.h"
|
||||
#include "myddas_util.h"
|
||||
#include "myddas.h"
|
||||
#include "myddas_structs.h"
|
||||
#include "myddas_statistics.h"
|
||||
#include <mysql/mysql.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#if defined HAVE_LIBREADLINE
|
||||
#include <readline/readline.h>
|
||||
#include <readline/history.h>
|
||||
#endif
|
||||
#include <sys/times.h>
|
||||
|
||||
|
||||
|
@ -1,11 +1,10 @@
|
||||
#ifdef CUT_C
|
||||
#if defined MYDDAS_ODBC || defined MYDDAS_MYSQL
|
||||
|
||||
#include "Yap.h"
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "cut_c.h"
|
||||
#include "myddas_util.h"
|
||||
#include "myddas.h"
|
||||
#include "myddas_structs.h"
|
||||
#ifdef MYDDAS_STATS
|
||||
#include "myddas_statistics.h"
|
||||
@ -395,5 +394,5 @@ void check_int(){
|
||||
|
||||
|
||||
#endif /*defined MYDDAS_ODBC || defined MYDDAS_MYSQL*/
|
||||
#endif /*CUT_C*/
|
||||
|
||||
|
||||
|
@ -1,32 +0,0 @@
|
||||
#ifndef __MYDDAS_UTIL_H__
|
||||
#define __MYDDAS_UTIL_H__
|
||||
|
||||
//#include "Yap.h"
|
||||
#include <stdio.h>
|
||||
#ifdef MYDDAS_ODBC
|
||||
#include <sql.h>
|
||||
#endif
|
||||
|
||||
#ifdef MYDDAS_MYSQL
|
||||
#include <mysql/mysql.h>
|
||||
#endif
|
||||
|
||||
#ifdef MYDDAS_STATS
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
typedef struct myddas_global *MYDDAS_GLOBAL;
|
||||
typedef struct myddas_util_query *MYDDAS_UTIL_QUERY;
|
||||
typedef struct myddas_list_connection *MYDDAS_UTIL_CONNECTION;
|
||||
typedef struct myddas_list_preds *MYDDAS_UTIL_PREDICATE;
|
||||
|
||||
#if defined MYDDAS_STATS || defined MYDDAS_TOP_LEVEL
|
||||
typedef struct myddas_stats_time_struct *MYDDAS_STATS_TIME;
|
||||
#endif
|
||||
|
||||
#ifdef MYDDAS_STATS
|
||||
typedef struct myddas_global_stats *MYDDAS_GLOBAL_STATS;
|
||||
#endif
|
||||
|
||||
#endif /*__MYDDAS_UTIL_H__*/
|
Reference in New Issue
Block a user