3 /* A crash few tests for the maxmin library */
5 /* Copyright (c) 2004 Arnaud Legrand. All rights reserved. */
7 /* This program is free software; you can redistribute it and/or modify it
8 * under the terms of the license (GNU LGPL) which comes with this package. */
12 #include "surf/maxmin.h"
22 gettimeofday(&start, NULL);
24 return (start.tv_sec * 1000000 + start.tv_usec);
28 xbt_maxmin_float_t float_random(xbt_maxmin_float_t max);
29 xbt_maxmin_float_t float_random(xbt_maxmin_float_t max)
31 return ((max * rand()) / (RAND_MAX + 1.0));
34 int int_random(int max);
35 int int_random(int max)
37 return (int) (((max * 1.0) * rand()) / (RAND_MAX + 1.0));
40 void test(int nb_cnst, int nb_var, int nb_elem);
41 void test(int nb_cnst, int nb_var, int nb_elem)
43 lmm_system_t Sys = NULL;
44 lmm_constraint_t *cnst = calloc(nb_cnst, sizeof(lmm_constraint_t));
45 lmm_variable_t *var = calloc(nb_var, sizeof(lmm_variable_t));
46 int *used = calloc(nb_cnst, sizeof(int));
49 Sys = lmm_system_new();
51 for (i = 0; i < nb_cnst; i++) {
52 cnst[i] = lmm_constraint_new(Sys, NULL, float_random(10.0));
55 for (i = 0; i < nb_var; i++) {
56 var[i] = lmm_variable_new(Sys, NULL, 1.0, -1.0, nb_elem);
57 for (j = 0; j < nb_cnst; j++)
59 for (j = 0; j < nb_elem; j++) {
60 k = int_random(nb_cnst);
65 lmm_expand(Sys, cnst[k], var[i], float_random(1.0));
72 date = us_time() - date;
81 int main(int argc, char **argv)
87 test(nb_cnst, nb_var, nb_elem);
88 printf("One shot execution time for a total of %d constraints, "
89 "%d variables with %d active constraint each : %ld microsecondes \n",
90 nb_cnst, nb_var, nb_elem, date);