Simplify the use of eina_benchmark:

* Free the inlined list returned by one (or several) calls of
   eina_benchmark_run() automatically in eina_benchmark_free()
   instead of letting the user doing it.

 * Update tutorial and benchmark binary accordingly


SVN revision: 44830
This commit is contained in:
Vincent Torri 2009-12-31 09:17:28 +00:00
parent 42753d6141
commit 8e85a71f03
2 changed files with 24 additions and 36 deletions

View File

@ -75,18 +75,6 @@
*
* ea = eina_benchmark_run(test);
*
* if(ea)
* {
* Eina_Array_Iterator it;
* char *tmp;
* unsigned int i;
*
* EINA_ARRAY_ITER_NEXT(ea, i, tmp, it)
* free(tmp);
*
* eina_array_free(ea);
* }
*
* eina_benchmark_free(test);
* eina_shutdown();
*
@ -276,20 +264,8 @@
* benchmarks[i].build(test);
*
* ea = eina_benchmark_run(test);
* if(ea)
* {
* Eina_Array_Iterator it;
* char *tmp;
* unsigned int i;
*
* EINA_ARRAY_ITER_NEXT(ea, i, tmp, it)
* free(tmp);
*
* eina_array_free(ea);
* }
*
* if (test)
* eina_benchmark_free(test);
* eina_benchmark_free(test);
* }
*
* eina_shutdown();
@ -345,6 +321,7 @@ void *alloca (size_t);
#include "eina_log.h"
#include "eina_benchmark.h"
#include "eina_inlist.h"
#include "eina_list.h"
#include "eina_counter.h"
/*============================================================================*
@ -376,6 +353,7 @@ struct _Eina_Benchmark
const char *run;
Eina_Inlist *runs;
Eina_List *names;
};
static int _eina_benchmark_log_dom = -1;
@ -530,6 +508,25 @@ eina_benchmark_free(Eina_Benchmark *bench)
free(run);
}
while (bench->names)
{
Eina_Array *names;
names = eina_list_data_get(bench->names);
if (names)
{
Eina_Array_Iterator it;
char *tmp;
unsigned int i;
EINA_ARRAY_ITER_NEXT(names, i, tmp, it)
free(tmp);
eina_array_free(names);
}
bench->names = eina_list_remove_list(bench->names, bench->names);
}
free(bench);
}
@ -709,6 +706,8 @@ eina_benchmark_run(Eina_Benchmark *bench)
fclose(main_script);
bench->names = eina_list_append(bench->names, ea);
return ea;
}

View File

@ -85,17 +85,6 @@ main(int argc, char **argv)
etc[i].build(test);
ea = eina_benchmark_run(test);
if (ea)
{
Eina_Array_Iterator it;
char *tmp;
unsigned int i;
EINA_ARRAY_ITER_NEXT(ea, i, tmp, it)
free(tmp);
eina_array_free(ea);
}
eina_benchmark_free(test);
}