efl
1/* EINA - EFL data type library
2* Copyright (C) 2008 Cedric Bail
3*
4* This library is free software; you can redistribute it and/or
5* modify it under the terms of the GNU Lesser General Public
6* License as published by the Free Software Foundation; either
7* version 2.1 of the License, or (at your option) any later version.
8*
9* This library is distributed in the hope that it will be useful,
10* but WITHOUT ANY WARRANTY; without even the implied warranty of
11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12* Lesser General Public License for more details.
13*
14* You should have received a copy of the GNU Lesser General Public
15* License along with this library;
16* if not, see <http://www.gnu.org/licenses/>.
17*/
18
19#ifdef HAVE_CONFIG_H20# include "config.h"21#endif22
23#include <unistd.h>24
25#include "eina_suite.h"26#include "eina_benchmark.h"27
28static int global_test = 0;29
30static void31_eina_benchmark_specimens(int request)32{
33int i;34int a = 0;35
36for (i = 0; i < request; ++i)37a += i;38
39global_test = a;40}
41
42EFL_START_TEST(eina_benchmark_simple)43{
44Eina_Benchmark *eb;45Eina_Array_Iterator it;46Eina_Array *ea;47char *tmp;48unsigned int i;49
50eb = eina_benchmark_new("benchmark", "test");51fail_if(!eb);52
53eina_benchmark_register(eb, "specimens_check",54EINA_BENCHMARK(_eina_benchmark_specimens),551000, 1100, 100);56
57ea = eina_benchmark_run(eb);58fail_if(!ea);59
60EINA_ARRAY_ITER_NEXT(ea, i, tmp, it)61{62fail_if(!tmp);63fail_if(unlink(tmp));64}65
66fail_if(global_test != 499500);67
68eina_benchmark_free(eb);69}
70EFL_END_TEST
71
72void
73eina_test_benchmark(TCase *tc)74{
75tcase_add_test(tc, eina_benchmark_simple);76}
77