forked from enlightenment/efl
parent
d87d5d949a
commit
b99c0cfea2
|
@ -11,17 +11,17 @@ if EINA_ENABLE_TESTS
|
|||
|
||||
check_PROGRAMS = eina_suite
|
||||
|
||||
eina_suite_SOURCES = \
|
||||
eina_suite.c \
|
||||
eina_suite_SOURCES = \
|
||||
eina_suite.c \
|
||||
eina_test_stringshare.c \
|
||||
eina_test_array.c \
|
||||
eina_test_error.c \
|
||||
eina_test_magic.c \
|
||||
eina_test_inlist.c \
|
||||
eina_test_main.c \
|
||||
eina_test_counter.c \
|
||||
eina_test_lalloc.c \
|
||||
eina_test_hash.c \
|
||||
eina_test_array.c \
|
||||
eina_test_error.c \
|
||||
eina_test_magic.c \
|
||||
eina_test_inlist.c \
|
||||
eina_test_main.c \
|
||||
eina_test_counter.c \
|
||||
eina_test_lalloc.c \
|
||||
eina_test_hash.c \
|
||||
eina_test_list.c
|
||||
|
||||
eina_suite_LDADD = @CHECK_LIBS@ $(top_builddir)/src/lib/libeina.la
|
||||
|
@ -32,9 +32,10 @@ if EINA_ENABLE_BENCH
|
|||
|
||||
bench_PROGRAMS = eina_bench
|
||||
|
||||
eina_bench_SOURCES = \
|
||||
eina_bench.c \
|
||||
eina_bench_hash.c \
|
||||
eina_bench_SOURCES = \
|
||||
eina_bench.c \
|
||||
eina_bench_hash.c \
|
||||
eina_bench_stringshare.c \
|
||||
eina_bench_array.c
|
||||
|
||||
eina_bench_LDADD = $(top_builddir)/src/lib/libeina.la
|
||||
|
|
|
@ -179,6 +179,7 @@ struct _Eina_Bench_Case
|
|||
static const Eina_Bench_Case etc[] = {
|
||||
{ "Hash", eina_bench_hash },
|
||||
{ "Array vs List vs Inlist", eina_bench_array },
|
||||
{ "Stringshare", eina_bench_stringshare },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
|
|
|
@ -28,5 +28,6 @@ void eina_bench_register(Eina_Bench *bench, const char *name, Eina_Bench_Specime
|
|||
|
||||
void eina_bench_hash(Eina_Bench *bench);
|
||||
void eina_bench_array(Eina_Bench *bench);
|
||||
void eina_bench_stringshare(Eina_Bench *bench);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
/* 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 <time.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "eina_stringshare.h"
|
||||
#include "eina_bench.h"
|
||||
#include "eina_array.h"
|
||||
|
||||
static void
|
||||
eina_bench_stringshare_job(int request)
|
||||
{
|
||||
const char *tmp;
|
||||
Eina_Array *ea;
|
||||
unsigned int j;
|
||||
int i;
|
||||
|
||||
eina_stringshare_init();
|
||||
eina_array_init();
|
||||
|
||||
ea = eina_array_new(request);
|
||||
|
||||
for (i = 0; i < request; ++i)
|
||||
{
|
||||
char build[64];
|
||||
|
||||
snprintf(build, 64, "string_%i", i);
|
||||
tmp = eina_stringshare_add(build);
|
||||
|
||||
eina_array_append(ea, tmp);
|
||||
}
|
||||
|
||||
srand(time(NULL));
|
||||
|
||||
for (j = 0; j < 200; ++j)
|
||||
for (i = 0; i < request; ++i)
|
||||
{
|
||||
char build[64];
|
||||
|
||||
snprintf(build, 64, "string_%i", rand() % request);
|
||||
tmp = eina_stringshare_add(build);
|
||||
|
||||
eina_array_append(ea, tmp);
|
||||
}
|
||||
|
||||
EINA_ARRAY_ITER_NEXT(ea, j, tmp)
|
||||
eina_stringshare_del(tmp);
|
||||
EINA_ARRAY_ITER_END;
|
||||
|
||||
eina_array_shutdown();
|
||||
eina_stringshare_shutdown();
|
||||
}
|
||||
|
||||
void eina_bench_stringshare(Eina_Bench *bench)
|
||||
{
|
||||
eina_bench_register(bench, "stringshare", EINA_BENCH(eina_bench_stringshare_job), 100, 20100, 500);
|
||||
}
|
Loading…
Reference in New Issue