1 /* A crash few tests for the maxmin library */
3 /* Authors: Arnaud Legrand */
5 /* This program is free software; you can redistribute it and/or modify it
6 under the terms of the license (GNU LGPL) which comes with this package. */
10 #include "surf/maxmin.h"
20 gettimeofday(&start, NULL);
22 return (start.tv_sec * 1000000 + start.tv_usec);
26 xbt_maxmin_float_t float_random(xbt_maxmin_float_t max);
27 xbt_maxmin_float_t float_random(xbt_maxmin_float_t max)
29 return ((max * rand()) / (RAND_MAX + 1.0));
32 int int_random(int max);
33 int int_random(int max)
35 return (int) (((max * 1.0) * rand()) / (RAND_MAX + 1.0));
38 void test(int nb_cnst, int nb_var, int nb_elem);
39 void test(int nb_cnst, int nb_var, int nb_elem)
41 lmm_system_t Sys = NULL;
42 lmm_constraint_t *cnst = calloc(nb_cnst, sizeof(lmm_constraint_t));
43 lmm_variable_t *var = calloc(nb_var, sizeof(lmm_variable_t));
44 int *used = calloc(nb_cnst, sizeof(int));
47 Sys = lmm_system_new();
49 for (i = 0; i < nb_cnst; i++) {
50 cnst[i] = lmm_constraint_new(Sys, NULL, float_random(10.0));
53 for (i = 0; i < nb_var; i++) {
54 var[i] = lmm_variable_new(Sys, NULL, 1.0, -1.0, nb_elem);
55 for (j = 0; j < nb_cnst; j++)
57 for (j = 0; j < nb_elem; j++) {
58 k = int_random(nb_cnst);
63 lmm_expand(Sys, cnst[k], var[i], float_random(1.0));
70 date = us_time() - date;
79 int main(int argc, char **argv)
85 test(nb_cnst, nb_var, nb_elem);
86 printf("One shot execution time for a total of %d constraints, "
87 "%d variables with %d active constraint each : %ld microsecondes \n",
88 nb_cnst, nb_var, nb_elem, date);