forked from enlightenment/efl
parent
d87d5d949a
commit
b99c0cfea2
|
@ -35,6 +35,7 @@ bench_PROGRAMS = eina_bench
|
||||||
eina_bench_SOURCES = \
|
eina_bench_SOURCES = \
|
||||||
eina_bench.c \
|
eina_bench.c \
|
||||||
eina_bench_hash.c \
|
eina_bench_hash.c \
|
||||||
|
eina_bench_stringshare.c \
|
||||||
eina_bench_array.c
|
eina_bench_array.c
|
||||||
|
|
||||||
eina_bench_LDADD = $(top_builddir)/src/lib/libeina.la
|
eina_bench_LDADD = $(top_builddir)/src/lib/libeina.la
|
||||||
|
|
|
@ -179,6 +179,7 @@ struct _Eina_Bench_Case
|
||||||
static const Eina_Bench_Case etc[] = {
|
static const Eina_Bench_Case etc[] = {
|
||||||
{ "Hash", eina_bench_hash },
|
{ "Hash", eina_bench_hash },
|
||||||
{ "Array vs List vs Inlist", eina_bench_array },
|
{ "Array vs List vs Inlist", eina_bench_array },
|
||||||
|
{ "Stringshare", eina_bench_stringshare },
|
||||||
{ NULL, NULL }
|
{ 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_hash(Eina_Bench *bench);
|
||||||
void eina_bench_array(Eina_Bench *bench);
|
void eina_bench_array(Eina_Bench *bench);
|
||||||
|
void eina_bench_stringshare(Eina_Bench *bench);
|
||||||
|
|
||||||
#endif
|
#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