Add Index_Value_Break and Index_Node_Break commands,
Improve random number generation.
This commit is contained in:
parent
75cfc21e01
commit
51482fb475
134
util/ndbench.c
134
util/ndbench.c
@ -1,9 +1,9 @@
|
|||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
/* $RCSfile: ndbench.c,v $ */
|
/* $RCSfile: ndbench.c,v $ */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
/* $Revision: 2.7 $ */
|
/* $Revision: 2.8 $ */
|
||||||
/* $Name: $ */
|
/* $Name: $ */
|
||||||
/* $Date: 2004/08/01 23:38:52 $ */
|
/* $Date: 2004/08/24 20:31:28 $ */
|
||||||
/* $Author: agibert $ */
|
/* $Author: agibert $ */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
@ -59,7 +59,7 @@
|
|||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifdef _LIBVER_SUPPORT
|
#ifdef _LIBVER_SUPPORT
|
||||||
VER_INFO_EXPORT( ndbench, "$Revision: 2.7 $", "$Name: $", __FILE__, "$Author: agibert $");
|
VER_INFO_EXPORT( ndbench, "$Revision: 2.8 $", "$Name: $", __FILE__, "$Author: agibert $");
|
||||||
# define USAGE "Usage : %s [ --help | --version [-v] | --batch_run <batch_file_name>]\n"
|
# define USAGE "Usage : %s [ --help | --version [-v] | --batch_run <batch_file_name>]\n"
|
||||||
#else
|
#else
|
||||||
# define USAGE "Usage : %s [ --help | --batch_run <batch_file_name>]\n"
|
# define USAGE "Usage : %s [ --help | --batch_run <batch_file_name>]\n"
|
||||||
@ -94,9 +94,11 @@ VER_INFO_EXPORT( ndbench, "$Revision: 2.7 $", "$Name: $", __FILE__, "$Author: a
|
|||||||
#define INDEX_REORG 22
|
#define INDEX_REORG 22
|
||||||
#define INDEX_INFO_PRINT 23
|
#define INDEX_INFO_PRINT 23
|
||||||
#define INDEX_VALUE_PRINT 24
|
#define INDEX_VALUE_PRINT 24
|
||||||
#define BATCH_RUN 25
|
#define INDEX_VALUE_BREAK 25
|
||||||
|
#define INDEX_NODE_BREAK 26
|
||||||
|
#define BATCH_RUN 27
|
||||||
|
|
||||||
#define COMMAND_NB 26
|
#define COMMAND_NB 28
|
||||||
|
|
||||||
#define INDEX_NB 32
|
#define INDEX_NB 32
|
||||||
|
|
||||||
@ -151,6 +153,7 @@ typedef struct
|
|||||||
|
|
||||||
# define t_start(x) { _ftime( &(x.start));}
|
# define t_start(x) { _ftime( &(x.start));}
|
||||||
# define t_stop(x) { _ftime( &(x.stop)); x.sec = (double)(x.stop.time) - (double)(x.start.time) + ((double)(x.stop.millitm) - (double)(x.start.millitm)) / 1000;}
|
# define t_stop(x) { _ftime( &(x.stop)); x.sec = (double)(x.stop.time) - (double)(x.start.time) + ((double)(x.stop.millitm) - (double)(x.start.millitm)) / 1000;}
|
||||||
|
# define seed_get(x) (int)( (x).start.time)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
@ -161,8 +164,9 @@ typedef struct
|
|||||||
struct timeval stop;
|
struct timeval stop;
|
||||||
} cpt;
|
} cpt;
|
||||||
|
|
||||||
# define t_start(x) { gettimeofday( &(x.start), NULL);}
|
# define t_start(x) { gettimeofday( &((x).start), NULL);}
|
||||||
# define t_stop(x) { gettimeofday( &(x.stop), NULL); x.sec = (double)(x.stop.tv_sec) - (double)(x.start.tv_sec) + ((double)(x.stop.tv_usec) - (double)(x.start.tv_usec)) / 1000000;}
|
# define t_stop(x) { gettimeofday( &((x).stop), NULL); (x).sec = (double)((x).stop.tv_sec) - (double)((x).start.tv_sec) + ((double)((x).stop.tv_usec) - (double)((x).start.tv_usec)) / 1000000;}
|
||||||
|
# define seed_get(x) (int)( (x).start.tv_sec)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -241,6 +245,8 @@ Command Command_Tab[] =
|
|||||||
{ INDEX_REORG, "Index_Reorg", "Reorg Index", ( DS_STATE_OPENED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)},
|
{ INDEX_REORG, "Index_Reorg", "Reorg Index", ( DS_STATE_OPENED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)},
|
||||||
{ INDEX_INFO_PRINT, "Index_Info_Print", "Print Index Informations", ( DS_STATE_OPENED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)},
|
{ INDEX_INFO_PRINT, "Index_Info_Print", "Print Index Informations", ( DS_STATE_OPENED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)},
|
||||||
{ INDEX_VALUE_PRINT, "Index_Value_Print", "Print Index Values", ( DS_STATE_OPENED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)},
|
{ INDEX_VALUE_PRINT, "Index_Value_Print", "Print Index Values", ( DS_STATE_OPENED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)},
|
||||||
|
{ INDEX_VALUE_BREAK, "Index_Value_Break", "Break Index Value", ( DS_STATE_OPENED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)},
|
||||||
|
{ INDEX_NODE_BREAK, "Index_Node_Break", "Break Index Node", ( DS_STATE_OPENED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)},
|
||||||
{ BATCH_RUN, "Batch_Run", "Run NDBench Bach", ( DS_STATE_OPENED | DS_STATE_CLOSED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)}
|
{ BATCH_RUN, "Batch_Run", "Run NDBench Bach", ( DS_STATE_OPENED | DS_STATE_CLOSED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -265,7 +271,7 @@ NDT_Status Module_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Nod
|
|||||||
|
|
||||||
Command_Name = "NDD_CMD_MANAGER_VERSION";
|
Command_Name = "NDD_CMD_MANAGER_VERSION";
|
||||||
|
|
||||||
*Version_Name_Ptr = "$Revision: 2.7 $ $Name: $ $Date: 2004/08/01 23:38:52 $ $Author: agibert $";
|
*Version_Name_Ptr = "$Revision: 2.8 $ $Name: $ $Date: 2004/08/24 20:31:28 $ $Author: agibert $";
|
||||||
|
|
||||||
return( NDS_OK);
|
return( NDS_OK);
|
||||||
}
|
}
|
||||||
@ -1001,7 +1007,7 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
|
|||||||
|
|
||||||
while( i < j)
|
while( i < j)
|
||||||
{
|
{
|
||||||
Ref_Module.Id = low +( rand( ) % ( high - low));
|
Ref_Module.Id = low + (int)( (double)( high - low) * rand() / ( RAND_MAX + 1.0));
|
||||||
ND_DataStruct_Value_Find( (void *)&Module_Ptr, *DS_Ptr_Ptr, &Ref_Module);
|
ND_DataStruct_Value_Find( (void *)&Module_Ptr, *DS_Ptr_Ptr, &Ref_Module);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
@ -1090,6 +1096,9 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
|
|||||||
|
|
||||||
case INDEX_LIST_SUBTYPE_SET:
|
case INDEX_LIST_SUBTYPE_SET:
|
||||||
{
|
{
|
||||||
|
int subtype;
|
||||||
|
|
||||||
|
|
||||||
Command_Index_Range_Get( File_Output, &low, &high, Arg1, File_Input, Choice, "Index");
|
Command_Index_Range_Get( File_Output, &low, &high, Arg1, File_Input, Choice, "Index");
|
||||||
|
|
||||||
if( low != -1)
|
if( low != -1)
|
||||||
@ -1102,9 +1111,9 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
|
|||||||
Arg2 = buf;
|
Arg2 = buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
Choice = atoi( Arg2);
|
subtype = atoi( Arg2);
|
||||||
|
|
||||||
switch( Choice)
|
switch( subtype)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
{
|
{
|
||||||
@ -1127,7 +1136,7 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
|
|||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
index_subtype = NDD_INDEX_SUBTYPE_UNKNOWN;
|
index_subtype = NDD_INDEX_SUBTYPE_UNKNOWN;
|
||||||
printf ("Index_List_SubType_Set: Invalid selection (%d) !\n", Choice);
|
printf ("Index_List_SubType_Set: Invalid selection (%d) !\n", subtype);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1161,6 +1170,9 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
|
|||||||
|
|
||||||
case INDEX_TREE_SUBTYPE_SET:
|
case INDEX_TREE_SUBTYPE_SET:
|
||||||
{
|
{
|
||||||
|
int subtype;
|
||||||
|
|
||||||
|
|
||||||
Command_Index_Range_Get( File_Output, &low, &high, Arg1, File_Input, Choice, "Index");
|
Command_Index_Range_Get( File_Output, &low, &high, Arg1, File_Input, Choice, "Index");
|
||||||
|
|
||||||
if( low != -1)
|
if( low != -1)
|
||||||
@ -1173,9 +1185,9 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
|
|||||||
Arg2 = buf;
|
Arg2 = buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
Choice = atoi( Arg2);
|
subtype = atoi( Arg2);
|
||||||
|
|
||||||
switch( Choice)
|
switch( subtype)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
{
|
{
|
||||||
@ -1192,7 +1204,7 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
|
|||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
index_subtype = NDD_INDEX_SUBTYPE_UNKNOWN;
|
index_subtype = NDD_INDEX_SUBTYPE_UNKNOWN;
|
||||||
printf ("Index_Tree_SubType_Set: Invalid selection (%d)!\n", Choice);
|
printf ("Index_Tree_SubType_Set: Invalid selection (%d)!\n", subtype);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1301,7 +1313,7 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
|
|||||||
|
|
||||||
if( low != -1)
|
if( low != -1)
|
||||||
{
|
{
|
||||||
fprintf( File_Output, "DS_Info_Print: Printing index from: (%d) to: (%d)...\n", low, high);
|
fprintf( File_Output, "Index_Info_Print: Printing index from: (%d) to: (%d)...\n", low, high);
|
||||||
fflush( File_Output);
|
fflush( File_Output);
|
||||||
|
|
||||||
for( i = low; i <= high; i++)
|
for( i = low; i <= high; i++)
|
||||||
@ -1322,6 +1334,88 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case INDEX_VALUE_BREAK:
|
||||||
|
{
|
||||||
|
int position;
|
||||||
|
NDT_Node *node_ptr;
|
||||||
|
|
||||||
|
|
||||||
|
Command_Index_Range_Get( File_Output, &low, &high, Arg1, File_Input, Choice, "Index");
|
||||||
|
|
||||||
|
if( low != -1)
|
||||||
|
{
|
||||||
|
if( Arg2 == NULL)
|
||||||
|
{
|
||||||
|
fprintf( File_Output, "Index_Value_Break: Value position (0:Head | 1:Tail | 2:Random) ? ");
|
||||||
|
fgets( buf, BUF_LEN, stdin);
|
||||||
|
|
||||||
|
Arg2 = buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
position = atoi( Arg2);
|
||||||
|
|
||||||
|
fprintf( File_Output, "Index_Value_Break: Breaking %s values from index : (%d) to: (%d)...\n",
|
||||||
|
( position == 0 ) ? "Head" : ( ( position == 1) ? "Tail" : "Random"),
|
||||||
|
low, high);
|
||||||
|
fflush( File_Output);
|
||||||
|
|
||||||
|
t_start( t_exec);
|
||||||
|
|
||||||
|
fprintf( File_Output, "Index_Value_Break: Breaking value of nodes: ");
|
||||||
|
fflush( File_Output);
|
||||||
|
|
||||||
|
for( i = low; i <= high; i++)
|
||||||
|
{
|
||||||
|
switch( position)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
node_ptr =(*DS_Ptr_Ptr)->Index_Tab[i].Head;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
node_ptr=(*DS_Ptr_Ptr)->Index_Tab[i].Tail;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
{
|
||||||
|
j = (int)( (double)( (*DS_Ptr_Ptr)->Index_Tab[i].Node_Number) * rand() / ( RAND_MAX + 1.0));
|
||||||
|
|
||||||
|
for( node_ptr = (*DS_Ptr_Ptr)->Index_Tab[i].Head; j > 0; j--)
|
||||||
|
{
|
||||||
|
node_ptr = node_ptr->Right;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf( File_Output, "0x(%x)", node_ptr);
|
||||||
|
fflush( File_Output);
|
||||||
|
|
||||||
|
node_ptr->Value = (void *)-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
t_stop (t_exec);
|
||||||
|
|
||||||
|
fprintf( File_Output, "\n");
|
||||||
|
fflush( File_Output);
|
||||||
|
|
||||||
|
Command_Exec_End_Print( File_Output, Choice, t_exec, high - low);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case INDEX_NODE_BREAK:
|
||||||
|
{
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case INDEX_CHECK:
|
case INDEX_CHECK:
|
||||||
{
|
{
|
||||||
Command_Index_Range_Get( File_Output, &low, &high, Arg1, File_Input, Choice, "Index");
|
Command_Index_Range_Get( File_Output, &low, &high, Arg1, File_Input, Choice, "Index");
|
||||||
@ -1436,6 +1530,14 @@ int main( int argc, char ** argv)
|
|||||||
NDT_Root *ds_ptr = NULL;
|
NDT_Root *ds_ptr = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
/* Init Random numbers... */
|
||||||
|
|
||||||
|
t_start( t_exec);
|
||||||
|
t_stop( t_exec);
|
||||||
|
srand( seed_get(t_exec));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Args Parsing */
|
/* Args Parsing */
|
||||||
|
|
||||||
if( argc >= 2)
|
if( argc >= 2)
|
||||||
|
Loading…
Reference in New Issue
Block a user