forked from enlightenment/efl
Share eina_benchmark to other libs also.
SVN revision: 35832
This commit is contained in:
parent
593569c78e
commit
991867bd7b
|
@ -22,6 +22,7 @@ eina_inline_list.x \
|
|||
eina_accessor.h \
|
||||
eina_convert.h \
|
||||
eina_rbtree.h \
|
||||
eina_benchmark.h \
|
||||
eina_inline_rbtree.x \
|
||||
eina_iterator.h
|
||||
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
/* EINA - EFL data type library
|
||||
* Copyright (C) 2008 Cedric Bail
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library;
|
||||
* if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef EINA_BENCHMARK_H_
|
||||
#define EINA_BENCHMARK_H_
|
||||
|
||||
#include "eina_array.h"
|
||||
|
||||
typedef struct _Eina_Benchmark Eina_Benchmark;
|
||||
typedef void (*Eina_Benchmark_Specimens)(int request);
|
||||
#define EINA_BENCHMARK(Function) ((Eina_Benchmark_Specimens)Function)
|
||||
|
||||
EAPI Eina_Benchmark *eina_benchmark_new(const char *name, const char *run);
|
||||
EAPI void eina_benchmark_free(Eina_Benchmark *bench);
|
||||
|
||||
EAPI void eina_benchmark_register(Eina_Benchmark *bench, const char *name, Eina_Benchmark_Specimens bench_cb,
|
||||
int count_start, int count_end, int count_set);
|
||||
|
||||
EAPI Eina_Array *eina_benchmark_run(Eina_Benchmark *bench);
|
||||
|
||||
#endif
|
|
@ -27,6 +27,7 @@ eina_iterator.c \
|
|||
eina_accessor.c \
|
||||
eina_convert.c \
|
||||
eina_rbtree.c \
|
||||
eina_benchmark.c \
|
||||
eina_stringshare.c
|
||||
|
||||
libeina_la_LIBADD = @EINA_LIBS@
|
||||
|
|
|
@ -0,0 +1,185 @@
|
|||
/* EINA - EFL data type library
|
||||
* Copyright (C) 2008 Cedric Bail
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library;
|
||||
* if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "eina_benchmark.h"
|
||||
#include "eina_inlist.h"
|
||||
#include "eina_counter.h"
|
||||
|
||||
typedef struct _Eina_Run Eina_Run;
|
||||
struct _Eina_Run
|
||||
{
|
||||
Eina_Inlist __list;
|
||||
|
||||
Eina_Benchmark_Specimens cb;
|
||||
const char *name;
|
||||
int start;
|
||||
int end;
|
||||
int step;
|
||||
};
|
||||
|
||||
struct _Eina_Benchmark
|
||||
{
|
||||
const char *name;
|
||||
const char *run;
|
||||
|
||||
Eina_Inlist *runs;
|
||||
};
|
||||
|
||||
EAPI Eina_Benchmark *
|
||||
eina_benchmark_new(const char *name, const char *run)
|
||||
{
|
||||
Eina_Benchmark *new;
|
||||
|
||||
new = calloc(1, sizeof (Eina_Benchmark));
|
||||
if (!new) return NULL;
|
||||
|
||||
new->name = name;
|
||||
new->run = run;
|
||||
|
||||
return new;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
eina_benchmark_free(Eina_Benchmark *bench)
|
||||
{
|
||||
if (!bench) return ;
|
||||
|
||||
while (bench->runs)
|
||||
{
|
||||
Eina_Run *run = (Eina_Run *) bench->runs;
|
||||
|
||||
bench->runs = eina_inlist_remove(bench->runs, bench->runs);
|
||||
free(run);
|
||||
}
|
||||
|
||||
free(bench);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
eina_benchmark_register(Eina_Benchmark *bench, const char *name, Eina_Benchmark_Specimens bench_cb,
|
||||
int count_start, int count_end, int count_step)
|
||||
{
|
||||
Eina_Run *run;
|
||||
|
||||
if (!bench) return ;
|
||||
|
||||
run = calloc(1, sizeof (Eina_Run));
|
||||
if (!run) return ;
|
||||
|
||||
run->cb = bench_cb;
|
||||
run->name = name;
|
||||
run->start = count_start;
|
||||
run->end = count_end;
|
||||
run->step = count_step;
|
||||
|
||||
bench->runs = eina_inlist_append(bench->runs, run);
|
||||
}
|
||||
|
||||
EAPI Eina_Array *
|
||||
eina_benchmark_run(Eina_Benchmark *bench)
|
||||
{
|
||||
FILE *main_script;
|
||||
FILE *current_data;
|
||||
Eina_Array *ea;
|
||||
Eina_Run *run;
|
||||
char buffer[PATH_MAX];
|
||||
Eina_Bool first = EINA_FALSE;
|
||||
|
||||
if (!bench) return NULL;
|
||||
|
||||
snprintf(buffer, PATH_MAX, "bench_%s_%s.gnuplot", bench->name, bench->run);
|
||||
|
||||
main_script = fopen(buffer, "w");
|
||||
if (!main_script) return NULL;
|
||||
|
||||
ea = eina_array_new(16);
|
||||
if (!ea)
|
||||
{
|
||||
fclose(main_script);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
eina_array_push(ea, strdup(buffer));
|
||||
|
||||
fprintf(main_script,
|
||||
"set autoscale # scale axes automatically\n"
|
||||
"unset log # remove any log-scaling\n"
|
||||
"unset label # remove any previous labels\n"
|
||||
"set xtic auto # set xtics automatically\n"
|
||||
"set ytic auto # set ytics automatically\n"
|
||||
/* "set logscale y\n" */
|
||||
"set terminal png size 1024,768\n"
|
||||
"set output \"output_%s_%s.png\"\n"
|
||||
"set title \"%s %s\n"
|
||||
"set xlabel \"tests\"\n"
|
||||
"set ylabel \"time\"\n"
|
||||
"plot ", bench->name, bench->run, bench->name, bench->run);
|
||||
|
||||
eina_counter_init();
|
||||
|
||||
EINA_INLIST_ITER_NEXT(bench->runs, run)
|
||||
{
|
||||
Eina_Counter *counter;
|
||||
int i;
|
||||
|
||||
snprintf(buffer, PATH_MAX, "bench_%s_%s.%s.data", bench->name, bench->run, run->name);
|
||||
|
||||
current_data = fopen(buffer, "w");
|
||||
if (!current_data) continue ;
|
||||
|
||||
eina_array_push(ea, strdup(buffer));
|
||||
|
||||
counter = eina_counter_add(run->name);
|
||||
|
||||
for (i = run->start; i < run->end; i += run->step)
|
||||
{
|
||||
fprintf(stderr, "Run %s: %i\n", run->name, i);
|
||||
eina_counter_start(counter);
|
||||
|
||||
run->cb(i);
|
||||
|
||||
eina_counter_stop(counter, i);
|
||||
}
|
||||
|
||||
eina_counter_dump(counter, current_data);
|
||||
|
||||
eina_counter_delete(counter);
|
||||
|
||||
fclose(current_data);
|
||||
|
||||
if (first == EINA_FALSE) first = EINA_TRUE;
|
||||
else fprintf(main_script, ", \\\n");
|
||||
|
||||
fprintf(main_script,
|
||||
"\"%s\" using 1:2 title \'%s\' with line",
|
||||
buffer, run->name);
|
||||
}
|
||||
|
||||
fprintf(main_script, "\n");
|
||||
|
||||
eina_counter_shutdown();
|
||||
|
||||
fclose(main_script);
|
||||
|
||||
return ea;
|
||||
}
|
|
@ -39,6 +39,7 @@ eina_test_module.c \
|
|||
eina_test_convert.c \
|
||||
eina_test_rbtree.c \
|
||||
eina_test_file.c \
|
||||
eina_test_benchmark.c \
|
||||
eina_test_list.c
|
||||
|
||||
eina_suite_LDADD = @CHECK_LIBS@ $(top_builddir)/src/lib/libeina.la
|
||||
|
|
|
@ -21,162 +21,15 @@
|
|||
#include <limits.h>
|
||||
|
||||
#include "eina_bench.h"
|
||||
#include "eina_inlist.h"
|
||||
#include "eina_counter.h"
|
||||
|
||||
typedef struct _Eina_Run Eina_Run;
|
||||
struct _Eina_Run
|
||||
{
|
||||
Eina_Inlist __list;
|
||||
|
||||
Eina_Bench_Specimens cb;
|
||||
const char *name;
|
||||
int start;
|
||||
int end;
|
||||
int step;
|
||||
};
|
||||
|
||||
struct _Eina_Bench
|
||||
{
|
||||
const char *name;
|
||||
const char *run;
|
||||
|
||||
Eina_Inlist *runs;
|
||||
};
|
||||
|
||||
Eina_Bench *
|
||||
eina_bench_new(const char *name, const char *run)
|
||||
{
|
||||
Eina_Bench *new;
|
||||
|
||||
new = calloc(1, sizeof (Eina_Bench));
|
||||
if (!new) return NULL;
|
||||
|
||||
new->name = name;
|
||||
new->run = run;
|
||||
|
||||
return new;
|
||||
}
|
||||
|
||||
void
|
||||
eina_bench_delete(Eina_Bench *bench)
|
||||
{
|
||||
if (!bench) return ;
|
||||
|
||||
while (bench->runs)
|
||||
{
|
||||
Eina_Run *run = (Eina_Run *) bench->runs;
|
||||
|
||||
bench->runs = eina_inlist_remove(bench->runs, bench->runs);
|
||||
free(run);
|
||||
}
|
||||
|
||||
free(bench);
|
||||
}
|
||||
|
||||
void
|
||||
eina_bench_register(Eina_Bench *bench, const char *name, Eina_Bench_Specimens bench_cb,
|
||||
int count_start, int count_end, int count_step)
|
||||
{
|
||||
Eina_Run *run;
|
||||
|
||||
if (!bench) return ;
|
||||
|
||||
run = calloc(1, sizeof (Eina_Run));
|
||||
if (!run) return ;
|
||||
|
||||
run->cb = bench_cb;
|
||||
run->name = name;
|
||||
run->start = count_start;
|
||||
run->end = count_end;
|
||||
run->step = count_step;
|
||||
|
||||
bench->runs = eina_inlist_append(bench->runs, run);
|
||||
}
|
||||
|
||||
void
|
||||
eina_bench_run(Eina_Bench *bench)
|
||||
{
|
||||
FILE *main_script;
|
||||
FILE *current_data;
|
||||
Eina_Run *run;
|
||||
char buffer[PATH_MAX];
|
||||
Eina_Bool first = EINA_FALSE;
|
||||
|
||||
if (!bench) return ;
|
||||
|
||||
snprintf(buffer, PATH_MAX, "bench_%s_%s.gnuplot", bench->name, bench->run);
|
||||
|
||||
main_script = fopen(buffer, "w");
|
||||
if (!main_script) return ;
|
||||
|
||||
fprintf(main_script,
|
||||
"set autoscale # scale axes automatically\n"
|
||||
"unset log # remove any log-scaling\n"
|
||||
"unset label # remove any previous labels\n"
|
||||
"set xtic auto # set xtics automatically\n"
|
||||
"set ytic auto # set ytics automatically\n"
|
||||
/* "set logscale y\n" */
|
||||
"set terminal png size 1024,768\n"
|
||||
"set output \"output_%s_%s.png\"\n"
|
||||
"set title \"%s %s\n"
|
||||
"set xlabel \"tests\"\n"
|
||||
"set ylabel \"time\"\n"
|
||||
"plot ", bench->name, bench->run, bench->name, bench->run);
|
||||
|
||||
eina_counter_init();
|
||||
|
||||
EINA_INLIST_ITER_NEXT(bench->runs, run)
|
||||
{
|
||||
Eina_Counter *counter;
|
||||
int i;
|
||||
|
||||
snprintf(buffer, PATH_MAX, "bench_%s_%s.%s.data", bench->name, bench->run, run->name);
|
||||
|
||||
current_data = fopen(buffer, "w");
|
||||
if (!current_data) continue ;
|
||||
|
||||
counter = eina_counter_add(run->name);
|
||||
|
||||
for (i = run->start; i < run->end; i += run->step)
|
||||
{
|
||||
fprintf(stderr, "Run %s: %i\n", run->name, i);
|
||||
eina_counter_start(counter);
|
||||
|
||||
run->cb(i);
|
||||
|
||||
eina_counter_stop(counter, i);
|
||||
}
|
||||
|
||||
eina_counter_dump(counter, current_data);
|
||||
|
||||
eina_counter_delete(counter);
|
||||
|
||||
fclose(current_data);
|
||||
|
||||
if (first == EINA_FALSE) first = EINA_TRUE;
|
||||
else fprintf(main_script, ", \\\n");
|
||||
|
||||
fprintf(main_script,
|
||||
"\"%s\" using 1:2 title \'%s\' with line",
|
||||
buffer, run->name);
|
||||
}
|
||||
|
||||
fprintf(main_script, "\n");
|
||||
|
||||
eina_counter_shutdown();
|
||||
|
||||
fclose(main_script);
|
||||
}
|
||||
|
||||
typedef struct _Eina_Bench_Case Eina_Bench_Case;
|
||||
struct _Eina_Bench_Case
|
||||
typedef struct _Eina_Benchmark_Case Eina_Benchmark_Case;
|
||||
struct _Eina_Benchmark_Case
|
||||
{
|
||||
const char *bench_case;
|
||||
void (*build)(Eina_Bench *bench);
|
||||
void (*build)(Eina_Benchmark *bench);
|
||||
};
|
||||
|
||||
static const Eina_Bench_Case etc[] = {
|
||||
static const Eina_Benchmark_Case etc[] = {
|
||||
{ "Hash", eina_bench_hash },
|
||||
{ "Array vs List vs Inlist", eina_bench_array },
|
||||
{ "Stringshare", eina_bench_stringshare },
|
||||
|
@ -187,21 +40,33 @@ static const Eina_Bench_Case etc[] = {
|
|||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
Eina_Bench *test;
|
||||
int i;
|
||||
Eina_Benchmark *test;
|
||||
Eina_Array *ea;
|
||||
unsigned int i;
|
||||
|
||||
if (argc != 2) return -1;
|
||||
|
||||
for (i = 0; etc[i].bench_case != NULL; ++i)
|
||||
{
|
||||
test = eina_bench_new(etc[i].bench_case, argv[1]);
|
||||
test = eina_benchmark_new(etc[i].bench_case, argv[1]);
|
||||
if (!test) continue ;
|
||||
|
||||
etc[i].build(test);
|
||||
|
||||
eina_bench_run(test);
|
||||
ea = eina_benchmark_run(test);
|
||||
if (ea)
|
||||
{
|
||||
Eina_Array_Iterator it;
|
||||
char *tmp;
|
||||
unsigned int i;
|
||||
|
||||
eina_bench_delete(test);
|
||||
EINA_ARRAY_ITER_NEXT(ea, i, tmp, it)
|
||||
free(tmp);
|
||||
|
||||
eina_array_free(ea);
|
||||
}
|
||||
|
||||
eina_benchmark_free(test);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -19,16 +19,11 @@
|
|||
#ifndef EINA_BENCH_H_
|
||||
#define EINA_BENCH_H_
|
||||
|
||||
typedef struct _Eina_Bench Eina_Bench;
|
||||
typedef void (*Eina_Bench_Specimens)(int request);
|
||||
#define EINA_BENCH(Function) ((Eina_Bench_Specimens)Function)
|
||||
#include "eina_benchmark.h"
|
||||
|
||||
void eina_bench_register(Eina_Bench *bench, const char *name, Eina_Bench_Specimens bench_cb,
|
||||
int count_start, int count_end, int count_set);
|
||||
|
||||
void eina_bench_hash(Eina_Bench *bench);
|
||||
void eina_bench_array(Eina_Bench *bench);
|
||||
void eina_bench_stringshare(Eina_Bench *bench);
|
||||
void eina_bench_convert(Eina_Bench *bench);
|
||||
void eina_bench_hash(Eina_Benchmark *bench);
|
||||
void eina_bench_array(Eina_Benchmark *bench);
|
||||
void eina_bench_stringshare(Eina_Benchmark *bench);
|
||||
void eina_bench_convert(Eina_Benchmark *bench);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -552,17 +552,17 @@ eina_bench_gptrarray_4evas_render(int request)
|
|||
}
|
||||
#endif
|
||||
|
||||
void eina_bench_array(Eina_Bench *bench)
|
||||
void eina_bench_array(Eina_Benchmark *bench)
|
||||
{
|
||||
eina_bench_register(bench, "array-inline", EINA_BENCH(eina_bench_array_4evas_render_inline), 200, 4000, 100);
|
||||
eina_bench_register(bench, "array-iterator", EINA_BENCH(eina_bench_array_4evas_render_iterator), 200, 4000, 100);
|
||||
eina_bench_register(bench, "list", EINA_BENCH(eina_bench_list_4evas_render), 200, 4000, 100);
|
||||
eina_bench_register(bench, "list-iterator", EINA_BENCH(eina_bench_list_4evas_render_iterator), 200, 4000, 100);
|
||||
eina_bench_register(bench, "inlist", EINA_BENCH(eina_bench_inlist_4evas_render), 200, 4000, 100);
|
||||
eina_bench_register(bench, "inlist-iterator", EINA_BENCH(eina_bench_inlist_4evas_render_iterator), 200, 4000, 100);
|
||||
eina_benchmark_register(bench, "array-inline", EINA_BENCHMARK(eina_bench_array_4evas_render_inline), 200, 4000, 100);
|
||||
eina_benchmark_register(bench, "array-iterator", EINA_BENCHMARK(eina_bench_array_4evas_render_iterator), 200, 4000, 100);
|
||||
eina_benchmark_register(bench, "list", EINA_BENCHMARK(eina_bench_list_4evas_render), 200, 4000, 100);
|
||||
eina_benchmark_register(bench, "list-iterator", EINA_BENCHMARK(eina_bench_list_4evas_render_iterator), 200, 4000, 100);
|
||||
eina_benchmark_register(bench, "inlist", EINA_BENCHMARK(eina_bench_inlist_4evas_render), 200, 4000, 100);
|
||||
eina_benchmark_register(bench, "inlist-iterator", EINA_BENCHMARK(eina_bench_inlist_4evas_render_iterator), 200, 4000, 100);
|
||||
#ifdef EINA_BENCH_HAVE_GLIB
|
||||
eina_bench_register(bench, "glist", EINA_BENCH(eina_bench_glist_4evas_render), 200, 4000, 100);
|
||||
eina_bench_register(bench, "gptrarray", EINA_BENCH(eina_bench_gptrarray_4evas_render), 200, 4000, 100);
|
||||
eina_benchmark_register(bench, "glist", EINA_BENCHMARK(eina_bench_glist_4evas_render), 200, 4000, 100);
|
||||
eina_benchmark_register(bench, "gptrarray", EINA_BENCHMARK(eina_bench_gptrarray_4evas_render), 200, 4000, 100);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -144,16 +144,16 @@ eina_bench_convert_gstrtod(int request)
|
|||
}
|
||||
#endif
|
||||
|
||||
void eina_bench_convert(Eina_Bench *bench)
|
||||
void eina_bench_convert(Eina_Benchmark *bench)
|
||||
{
|
||||
eina_bench_register(bench, "itoa 10", EINA_BENCH(eina_bench_convert_itoa_10), 1000, 200000, 500);
|
||||
eina_bench_register(bench, "itoa 16", EINA_BENCH(eina_bench_convert_itoa_16), 1000, 200000, 500);
|
||||
eina_bench_register(bench, "snprintf 10", EINA_BENCH(eina_bench_convert_snprintf_10), 1000, 200000, 500);
|
||||
eina_bench_register(bench, "snprintf 16", EINA_BENCH(eina_bench_convert_snprintf_x), 1000, 200000, 500);
|
||||
eina_bench_register(bench, "snprintf a", EINA_BENCH(eina_bench_convert_snprintf_a), 1000, 200000, 500);
|
||||
eina_bench_register(bench, "dtoa", EINA_BENCH(eina_bench_convert_dtoa), 1000, 200000, 500);
|
||||
eina_benchmark_register(bench, "itoa 10", EINA_BENCHMARK(eina_bench_convert_itoa_10), 1000, 200000, 500);
|
||||
eina_benchmark_register(bench, "itoa 16", EINA_BENCHMARK(eina_bench_convert_itoa_16), 1000, 200000, 500);
|
||||
eina_benchmark_register(bench, "snprintf 10", EINA_BENCHMARK(eina_bench_convert_snprintf_10), 1000, 200000, 500);
|
||||
eina_benchmark_register(bench, "snprintf 16", EINA_BENCHMARK(eina_bench_convert_snprintf_x), 1000, 200000, 500);
|
||||
eina_benchmark_register(bench, "snprintf a", EINA_BENCHMARK(eina_bench_convert_snprintf_a), 1000, 200000, 500);
|
||||
eina_benchmark_register(bench, "dtoa", EINA_BENCHMARK(eina_bench_convert_dtoa), 1000, 200000, 500);
|
||||
#ifdef EINA_BENCH_HAVE_GLIB
|
||||
eina_bench_register(bench, "gstrtod", EINA_BENCH(eina_bench_convert_gstrtod), 1000, 200000, 500);
|
||||
eina_benchmark_register(bench, "gstrtod", EINA_BENCHMARK(eina_bench_convert_gstrtod), 1000, 200000, 500);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -288,13 +288,13 @@ eina_bench_lookup_ghash(int request)
|
|||
}
|
||||
#endif
|
||||
|
||||
void eina_bench_hash(Eina_Bench *bench)
|
||||
void eina_bench_hash(Eina_Benchmark *bench)
|
||||
{
|
||||
eina_bench_register(bench, "superfast-lookup", EINA_BENCH(eina_bench_lookup_superfast), 1000, 180000, 2500);
|
||||
eina_bench_register(bench, "djb2-lookup", EINA_BENCH(eina_bench_lookup_djb2), 1000, 180000, 2500);
|
||||
eina_bench_register(bench, "djb2-lookup-inline", EINA_BENCH(eina_bench_lookup_djb2_inline), 1000, 180000, 2500);
|
||||
eina_bench_register(bench, "rbtree", EINA_BENCH(eina_bench_lookup_rbtree), 1000, 180000, 2500);
|
||||
eina_benchmark_register(bench, "superfast-lookup", EINA_BENCHMARK(eina_bench_lookup_superfast), 1000, 180000, 2500);
|
||||
eina_benchmark_register(bench, "djb2-lookup", EINA_BENCHMARK(eina_bench_lookup_djb2), 1000, 180000, 2500);
|
||||
eina_benchmark_register(bench, "djb2-lookup-inline", EINA_BENCHMARK(eina_bench_lookup_djb2_inline), 1000, 180000, 2500);
|
||||
eina_benchmark_register(bench, "rbtree", EINA_BENCHMARK(eina_bench_lookup_rbtree), 1000, 180000, 2500);
|
||||
#ifdef EINA_BENCH_HAVE_GLIB
|
||||
eina_bench_register(bench, "ghash-lookup", EINA_BENCH(eina_bench_lookup_ghash), 1000, 180000, 2500);
|
||||
eina_benchmark_register(bench, "ghash-lookup", EINA_BENCHMARK(eina_bench_lookup_ghash), 1000, 180000, 2500);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -96,10 +96,10 @@ eina_bench_stringchunk_job(int request)
|
|||
}
|
||||
#endif
|
||||
|
||||
void eina_bench_stringshare(Eina_Bench *bench)
|
||||
void eina_bench_stringshare(Eina_Benchmark *bench)
|
||||
{
|
||||
eina_bench_register(bench, "stringshare", EINA_BENCH(eina_bench_stringshare_job), 100, 20100, 500);
|
||||
eina_benchmark_register(bench, "stringshare", EINA_BENCHMARK(eina_bench_stringshare_job), 100, 20100, 500);
|
||||
#ifdef EINA_BENCH_HAVE_GLIB
|
||||
eina_bench_register(bench, "stringchunk (glib)", EINA_BENCH(eina_bench_stringchunk_job), 100, 20100, 500);
|
||||
eina_benchmark_register(bench, "stringchunk (glib)", EINA_BENCHMARK(eina_bench_stringchunk_job), 100, 20100, 500);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ static const Eina_Test_Case etc[] = {
|
|||
{ "Convert", eina_test_convert },
|
||||
{ "Rbtree", eina_test_rbtree },
|
||||
{ "File", eina_test_file },
|
||||
{ "Benchmark", eina_test_benchmark },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
|
|
|
@ -41,5 +41,6 @@ void eina_test_module(TCase *tc);
|
|||
void eina_test_convert(TCase *tc);
|
||||
void eina_test_rbtree(TCase *tc);
|
||||
void eina_test_file(TCase *tc);
|
||||
void eina_test_benchmark(TCase *tc);
|
||||
|
||||
#endif /* EINA_SUITE_H_ */
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
/* EINA - EFL data type library
|
||||
* Copyright (C) 2008 Cedric Bail
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library;
|
||||
* if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "eina_suite.h"
|
||||
#include "eina_benchmark.h"
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
static int global_test = 0;
|
||||
|
||||
static void
|
||||
_eina_benchmark_specimens(int request)
|
||||
{
|
||||
int i;
|
||||
int a;
|
||||
|
||||
for (i = 0; i < request; ++i)
|
||||
a += i;
|
||||
|
||||
global_test = a;
|
||||
}
|
||||
|
||||
START_TEST(eina_benchmark_simple)
|
||||
{
|
||||
Eina_Benchmark *eb;
|
||||
Eina_Array_Iterator it;
|
||||
Eina_Array *ea;
|
||||
char *tmp;
|
||||
unsigned int i;
|
||||
|
||||
eb = eina_benchmark_new("benchmark", "test");
|
||||
fail_if(!eb);
|
||||
|
||||
eina_benchmark_register(eb, "specimens_check", EINA_BENCHMARK(_eina_benchmark_specimens), 1000, 1100, 100);
|
||||
|
||||
ea = eina_benchmark_run(eb);
|
||||
fail_if(!ea);
|
||||
|
||||
EINA_ARRAY_ITER_NEXT(ea, i, tmp, it)
|
||||
{
|
||||
fail_if(!tmp);
|
||||
fail_if(unlink(tmp));
|
||||
}
|
||||
|
||||
fail_if(global_test != 499500);
|
||||
|
||||
eina_array_free(ea);
|
||||
|
||||
eina_benchmark_free(eb);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
void
|
||||
eina_test_benchmark(TCase *tc)
|
||||
{
|
||||
tcase_add_test(tc, eina_benchmark_simple);
|
||||
}
|
Loading…
Reference in New Issue