add in some very simple bitfield tests, and add a #define option to turn it into a speed test
This commit is contained in:
parent
ff5e97a6db
commit
53a426c738
|
@ -3,7 +3,16 @@
|
||||||
#include "transmission.h"
|
#include "transmission.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
|
#define VERBOSE 1
|
||||||
|
#define NUM_LOOPS 1
|
||||||
|
#define SPEED_TEST 0
|
||||||
|
|
||||||
|
#if SPEED_TEST
|
||||||
|
#undef VERBOSE
|
||||||
#define VERBOSE 0
|
#define VERBOSE 0
|
||||||
|
#undef NUM_LOOPS
|
||||||
|
#define NUM_LOOPS 200
|
||||||
|
#endif
|
||||||
|
|
||||||
int test = 0;
|
int test = 0;
|
||||||
|
|
||||||
|
@ -19,12 +28,35 @@ int test = 0;
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
test_bitfields( void )
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int bitcount = 5000000;
|
||||||
|
tr_bitfield * field = tr_bitfieldNew( bitcount );
|
||||||
|
|
||||||
|
/* make every seventh one true */
|
||||||
|
for( i=0; i<bitcount; ++i )
|
||||||
|
if( !( i % 7 ) )
|
||||||
|
tr_bitfieldAdd( field, i );
|
||||||
|
|
||||||
|
/* check to see if `has' has the right bits */
|
||||||
|
for( i=0; i<bitcount; ++i )
|
||||||
|
check( tr_bitfieldHas( field, i ) == (!(i%7)) );
|
||||||
|
|
||||||
|
tr_bitfieldFree( field );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main( void )
|
main( void )
|
||||||
{
|
{
|
||||||
char *in, *out;
|
char *in, *out;
|
||||||
int len;
|
int len;
|
||||||
|
int i;
|
||||||
|
int l;
|
||||||
|
|
||||||
/* base64 */
|
/* base64 */
|
||||||
in = "YOYO!";
|
in = "YOYO!";
|
||||||
|
@ -39,5 +71,10 @@ main( void )
|
||||||
tr_free( in );
|
tr_free( in );
|
||||||
tr_free( out );
|
tr_free( out );
|
||||||
|
|
||||||
|
/* simple bitfield tests */
|
||||||
|
for( l=0; l<NUM_LOOPS; ++l )
|
||||||
|
if(( i = test_bitfields( )))
|
||||||
|
return i;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue