Ejemplo n.º 1
0
void ia_test_all(void) {
	ia_create_test();
	ia_range_test();
	ia_of_string_test();
	ia_fn_test();
	ia_of_da_test();
	ia_contains_test();
	ia_fill_test();
	ia_fill_from_to_test();
	ia_index_test();
	ia_index_from_test();
	ia_index_fn_test();
	ia_last_index_test();
	ia_last_index_from_test();
	ia_last_index_fn_test();
	ia_sort_test();
	ia_sort_dec_test();
	ia_insert_test();
	ia_remove_test();
	ia_each_test();
	ia_each_state_test();
	ia_foldl_test();
	ia_foldr_test();
	ia_filter_test();
	// ia_filter_state_test();
	ia_choose_test();
	ia_exists_test();
	ia_forall_test();
	
#if 0
	Array a = ia_fn(20, ia_rnd, 5);
	ia_println(a);

	// get number of different numbers in array
	ia_sort(a);
	ia_println(a);
	int n = a_length(a);
	int k = (n > 0) ? 1 : 0;
	for (int i = 1; i < n; i++) {
		if (ia_get(a, i-1) != ia_get(a, i)) {
			k++;
		}
	}
	printiln(k);
	a_free(a);
#endif

#if 0
	// timing
	int n = 2000000000;
	Array a = ia_create(n, 0);
	time_function(   ia_fill_fn(a, fn_id)   );
	a_free(a);
	a = ia_create(n, 0);
	time_function(   ia_id(a)   );
	a_free(a);
#endif
	
}
Ejemplo n.º 2
0
Archivo: main.c Proyecto: mjftw/CubeSat
int main(int argc, char** argv)
{
  //purpose of main function- parse arguments and run max argv[1] tests or max errors argv[2] with BER of argv[3].
  //prints the message pass rate for these tests- to be interpreted by python.
  //many tests designed to run in parallel with different arguments
  srand(time(NULL));

  time_t start_time = time(NULL);

  if(argc >= 2)
  {
    if(!strcmp(argv[1],"packeting"))
    {
      //tries, length, BER, rs_t conv_constraint
      if(argc != 7)
        printf("Incorrect argument count for packeting.\n");
      else
        test_packeting(atoi(argv[2]), atoi(argv[3]), atof(argv[4]), atoi(argv[5]), atoi(argv[6]));
    }
    else if(!strcmp(argv[1], "memory"))
      test_memory();
    else if(!strcmp(argv[1], "matrices"))
      test_matrices();
    else if(!strcmp(argv[1], "bitstream"))
      test_bitstream();
    else if(!strcmp(argv[1], "convolution"))
      test_convolution();
    else if(!strcmp(argv[1], "reed_solomon"))
      test_reed_solomon();
    else if(!strcmp(argv[1], "interleaving"))
      test_interleaving();
    else if(!strcmp(argv[1], "time"))
      printf("%f\n", time_function());
    else if(!strcmp(argv[1], "sim"))
    {
      if(argc != 6)
        printf("Incorrect argument count for sim.\n");
      else
      {
        printf("%f", message_pass_rate_sim(atoi(argv[3]), atoi(argv[2]), atof(argv[4]), atoi(argv[5])));
        return 0;  //return 0 here so as not to print anything else which will prevent interpretation of piped output to float
      }
    }
    else if(!strcmp(argv[1], "interleave_with_conv"))
    {
      //test_interleave_with_conv();
    }
    else if(!strcmp(argv[1], "segmentation"))
      test_segmentation();
  }
  else
    printf("no arguments\n");

  print_memory_usage_stats();
  if(allocated() > 0)
    named_allocation_dump();
  printf("Time taken was %is\n", (int)(time(NULL) - start_time));
  return 0;

}
Ejemplo n.º 3
0
static void
bench_curve25519 (void)
{
  double mul_g;
  double mul;
  struct knuth_lfib_ctx lfib;
  struct curve25519_ctx ctx;
  knuth_lfib_init (&lfib, 2);

  knuth_lfib_random (&lfib, sizeof(ctx.s), ctx.s);
  curve25519_mul_g (ctx.x, ctx.s);

  mul_g = time_function (bench_curve25519_mul_g, &ctx);
  mul = time_function (bench_curve25519_mul, &ctx);

  printf("%16s %4d %9.4f %9.4f\n",
	 "curve25519", 255, 1e-3/mul_g, 1e-3/mul);
}
Ejemplo n.º 4
0
static void 
bench_alg (const struct alg *alg)
{
  double sign;
  double verify;
  void *ctx;

  ctx = alg->init(alg->size);
  if (ctx == NULL)
    {
      printf("%16s %4d N/A\n", alg->name, alg->size);
      return;
    }

  sign = time_function (alg->sign, ctx);
  verify = time_function (alg->verify, ctx);

  alg->clear (ctx);

  printf("%16s %4d %9.4f %9.4f\n",
	 alg->name, alg->size, 1e-3/sign, 1e-3/verify);
}
Ejemplo n.º 5
0
Archivo: timing.c Proyecto: AtnNn/ciao
/* New time medition functions */
static CBOOL__PROTO(generic_tick,
		    inttime_t (*time_function)(void),
		    inttime_t starttick,
		    inttime_t *lasttick)
{
  /*int st,lt; */
  inttime_t st,lt;
  inttime_t t;
  tagged_t x;
  
  t = time_function();
  st = t - starttick;
  lt = t - *lasttick;
  *lasttick = t;
  /* while ciao does not support inttime_t, lt and st must be cast to
    flt64_t */
  MakeLST(x,MakeFloat(Arg,(flt64_t)lt),atom_nil);
  MakeLST(x,MakeFloat(Arg,(flt64_t)st),x);
  return cunify(Arg,x,X(0));  
}
Ejemplo n.º 6
0
int main( int argc, char *argv[])
{
double (* f)();
void *MsgCtx = 0; /* This is the context of the message-passing operation */
void *outctx;
int  reps,len,error_flag;
double t;
int  first,last,incr, svals[3];
char     units[32];         /* Name of units of length */

MPI_Init( &argc, &argv );
MPI_Comm_size( MPI_COMM_WORLD, &__NUMNODES );
MPI_Comm_rank( MPI_COMM_WORLD, &__MYPROCID );
;
strcpy( units, "" );

if (SYArgHasName( &argc, argv, 1, "-help" )) {
  return PrintHelp( argv );
  }

if (__NUMNODES < 2) {
    fprintf( stderr, "Must run goptest with at least 2 nodes\n" );
    return 1;
    }

/* Get the output context */
outctx = SetupGraph( &argc, argv );
if (SYArgHasName( &argc, argv, 1, "-noinfo" ))    doinfo    = 0;
if (SYArgHasName( &argc, argv, 1, "-nohead" ))    doheader  = 0;
if (SYArgHasName( &argc, argv, 1, "-notail" ))    dotail    = 0;

reps          = DEFAULT_REPS;
error_flag    = 0;
if (SYArgHasName( &argc, argv, 0, "-sync") ) {
    svals[0] = svals[1] = svals[2] = 0;
    }
else {
    /* We use fewer values because we are generating them on the same line. */
    svals[0]      = 0;
    svals[1]      = 1024;
    svals[2]      = 256;
    }

SYArgGetIntVec( &argc, argv, 1, "-size", 3, svals );
nsizes = SYArgGetIntList( &argc, argv, 1, "-sizelist", MAX_SIZE_LIST, 
                          sizelist );
/* We ALWAYS use sizelist */
if (nsizes == 0) {
    /* Generate the size list from the svals list */
    sizelist[0] = svals[0];
    for (nsizes=1; sizelist[nsizes-1] < svals[1] && nsizes<MAX_SIZE_LIST; 
	 nsizes++) {
	sizelist[nsizes] = sizelist[nsizes-1] + svals[2];
	}
    if (sizelist[nsizes] > svals[1]) nsizes--;
    }

SYArgGetInt(    &argc, argv, 1, "-reps", &reps );
if (SYArgHasName( &argc, argv, 1, "-autoreps" ))  AutoReps  = 1;
if (SYArgGetDouble( &argc, argv, 1, "-tgoal", &Tgoal )) {
    AutoReps = 1;
    if (TgoalMin > 0.1 * Tgoal) TgoalMin = 0.1 * Tgoal;
    }
SYArgGetDouble( &argc, argv, 1, "-rthresh", &repsThresh );

f      = GetGOPFunction( &argc, argv, test_name, units );
MsgCtx = GOPInit( &argc, argv );
first = svals[0];
last  = svals[1];
incr  = svals[2];
if (incr == 0) incr = 1;

/*
   Finally, we are ready to run the tests.  We want to report times as
   the times for a single link, and rates as the aggregate rate.
   To do this, we need to know how to scale both the times and the rates.

   Times: scaled by the number of one-way trips measured by the base testing
   code.  This is often 2 trips, or a scaling of 1/2.

   Rates: scaled by the number of simultaneous participants (as well as
   the scaling in times).  Compute the rates based on the updated time, 
   then multiply by the number of participants.  Note that, for a single
   sender, time and rate are inversely proportional (that is, if TimeScale 
   is 0.5, RateScale is 2.0).

 */

if (doinfo && doheader &&__MYPROCID == 0) {
    HeaderForGopGraph( outctx, test_name, (char *)0, units );
    }
time_function(reps,first,last,incr,f,outctx,MsgCtx);

/* 
   Generate the "end of page".  This allows multiple graphs on the
   same plot 
 */
if (doinfo && dotail && __MYPROCID == 0) 
    EndPageGraph( outctx );

MPI_Finalize();
return 0;
}
Ejemplo n.º 7
0
static void
bench_curve (const struct ecc_curve *ecc)
{
  struct ecc_ctx ctx;  
  double modp, reduce, modq, modinv, modinv_gcd, modinv_powm,
    dup_jj, add_jja, add_hhh,
    mul_g, mul_a;

  mp_limb_t mask;
  mp_size_t itch;

  ctx.ecc = ecc;
  ctx.rp = xalloc_limbs (3*ecc->p.size);
  ctx.ap = xalloc_limbs (3*ecc->p.size);
  ctx.bp = xalloc_limbs (3*ecc->p.size);
  itch = ecc->mul_itch;
#ifdef mpn_sec_powm
  {
    mp_size_t powm_itch
      = mpn_sec_powm_itch (ecc->p.size, ecc->p.bit_size, ecc->p.size);
    if (powm_itch > itch)
      itch = powm_itch;
  }
#endif
  ctx.tp = xalloc_limbs (itch);

  mpn_random (ctx.ap, 3*ecc->p.size);
  mpn_random (ctx.bp, 3*ecc->p.size);

  mask = (~(mp_limb_t) 0) >> (ecc->p.size * GMP_NUMB_BITS - ecc->p.bit_size);
  ctx.ap[ecc->p.size - 1] &= mask;
  ctx.ap[2*ecc->p.size - 1] &= mask;
  ctx.ap[3*ecc->p.size - 1] &= mask;
  ctx.bp[ecc->p.size - 1] &= mask;
  ctx.bp[2*ecc->p.size - 1] &= mask;
  ctx.bp[3*ecc->p.size - 1] &= mask;

  modp = time_function (bench_modp, &ctx);
  reduce = time_function (bench_reduce, &ctx);

  modq = time_function (bench_modq, &ctx);

  modinv = time_function (bench_modinv, &ctx);
#if !NETTLE_USE_MINI_GMP
  modinv_gcd = time_function (bench_modinv_gcd, &ctx);
#else
  modinv_gcd = 0;
#endif
#ifdef mpn_sec_powm
  modinv_powm = time_function (bench_modinv_powm, &ctx);
#else
  modinv_powm = 0;
#endif
  if (ecc->p.bit_size == 255)
    {
      /* For now, curve25519 is a special case */
      dup_jj = time_function (bench_dup_eh, &ctx);
      add_jja = time_function (bench_add_eh, &ctx);
    }
  else
    {
      dup_jj = time_function (bench_dup_jj, &ctx);
      add_jja = time_function (bench_add_jja, &ctx);
    }
  add_hhh = time_function (bench_add_hhh, &ctx);
  mul_g = time_function (bench_mul_g, &ctx);
  mul_a = time_function (bench_mul_a, &ctx);

  free (ctx.rp);
  free (ctx.ap);
  free (ctx.bp);
  free (ctx.tp);

  printf ("%4d %6.4f %6.4f %6.4f %6.2f %6.3f %6.2f %6.3f %6.3f %6.3f %6.1f %6.1f\n",
	  ecc->p.bit_size, 1e6 * modp, 1e6 * reduce, 1e6 * modq,
	  1e6 * modinv, 1e6 * modinv_gcd, 1e6 * modinv_powm,
	  1e6 * dup_jj, 1e6 * add_jja, 1e6 * add_hhh,
	  1e6 * mul_g, 1e6 * mul_a);
}