Move benchmarks from tests to their own files in bench/
The tests only contain tests, and the benchmarks are more visible. Signed-off-by: Ran Benita <ran234@gmail.com>master
parent
fd126551ed
commit
bc3b4c084a
22
Makefile.am
22
Makefile.am
|
@ -180,8 +180,7 @@ TESTS = \
|
|||
test/rulescomp
|
||||
check_PROGRAMS = \
|
||||
test/rmlvo-to-kccgst \
|
||||
test/print-compiled-keymap \
|
||||
test/bench-key-proc
|
||||
test/print-compiled-keymap
|
||||
|
||||
TESTS_LDADD = libtest.la
|
||||
|
||||
|
@ -189,7 +188,7 @@ test_keysym_LDADD = $(TESTS_LDADD)
|
|||
test_filecomp_LDADD = $(TESTS_LDADD)
|
||||
test_context_LDADD = $(TESTS_LDADD)
|
||||
test_rules_file_CFLAGS = $(AM_CFLAGS) -Wno-declaration-after-statement
|
||||
test_rules_file_LDADD = $(TESTS_LDADD) -lrt
|
||||
test_rules_file_LDADD = $(TESTS_LDADD)
|
||||
test_stringcomp_LDADD = $(TESTS_LDADD)
|
||||
test_buffercomp_LDADD = $(TESTS_LDADD)
|
||||
test_log_LDADD = $(TESTS_LDADD)
|
||||
|
@ -197,10 +196,9 @@ test_atom_LDADD = $(TESTS_LDADD)
|
|||
test_utf8_LDADD = $(TESTS_LDADD)
|
||||
test_state_LDADD = $(TESTS_LDADD)
|
||||
test_keyseq_LDADD = $(TESTS_LDADD)
|
||||
test_rulescomp_LDADD = $(TESTS_LDADD) -lrt
|
||||
test_rulescomp_LDADD = $(TESTS_LDADD)
|
||||
test_rmlvo_to_kccgst_LDADD = $(TESTS_LDADD)
|
||||
test_print_compiled_keymap_LDADD = $(TESTS_LDADD)
|
||||
test_bench_key_proc_LDADD = $(TESTS_LDADD) -lrt
|
||||
|
||||
if BUILD_LINUX_TESTS
|
||||
check_PROGRAMS += \
|
||||
|
@ -229,6 +227,20 @@ endif ENABLE_X11
|
|||
|
||||
check_PROGRAMS += $(TESTS)
|
||||
|
||||
##
|
||||
# Benchmarks
|
||||
##
|
||||
|
||||
BENCH_LDADD = $(TESTS_LDADD) -lrt
|
||||
|
||||
check_PROGRAMS += \
|
||||
bench/key-proc \
|
||||
bench/rules \
|
||||
bench/rulescomp
|
||||
bench_key_proc_LDADD = $(BENCH_LDADD)
|
||||
bench_rules_LDADD = $(BENCH_LDADD)
|
||||
bench_rulescomp_LDADD = $(BENCH_LDADD)
|
||||
|
||||
##
|
||||
# Custom targets
|
||||
##
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
key-proc
|
||||
rules
|
||||
rulescomp
|
|
@ -24,7 +24,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "test.h"
|
||||
#include "../test/test.h"
|
||||
|
||||
#define BENCHMARK_ITERATIONS 20000000
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* Copyright © 2012 Ran Benita <ran234@gmail.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#include "../test/test.h"
|
||||
#include "xkbcomp-priv.h"
|
||||
#include "rules.h"
|
||||
|
||||
#define BENCHMARK_ITERATIONS 20000
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
struct xkb_context *ctx;
|
||||
struct timespec start, stop, elapsed;
|
||||
int i;
|
||||
struct xkb_rule_names rmlvo = {
|
||||
"evdev", "pc105", "us,il", ",", "ctrl:nocaps,grp:menu_toggle",
|
||||
};
|
||||
struct xkb_component_names kccgst;
|
||||
|
||||
ctx = test_get_context(0);
|
||||
assert(ctx);
|
||||
|
||||
xkb_context_set_log_level(ctx, XKB_LOG_LEVEL_CRITICAL);
|
||||
xkb_context_set_log_verbosity(ctx, 0);
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &start);
|
||||
for (i = 0; i < BENCHMARK_ITERATIONS; i++) {
|
||||
assert(xkb_components_from_rules(ctx, &rmlvo, &kccgst));
|
||||
free(kccgst.keycodes);
|
||||
free(kccgst.types);
|
||||
free(kccgst.compat);
|
||||
free(kccgst.symbols);
|
||||
}
|
||||
clock_gettime(CLOCK_MONOTONIC, &stop);
|
||||
|
||||
elapsed.tv_sec = stop.tv_sec - start.tv_sec;
|
||||
elapsed.tv_nsec = stop.tv_nsec - start.tv_nsec;
|
||||
if (elapsed.tv_nsec < 0) {
|
||||
elapsed.tv_nsec += 1000000000;
|
||||
elapsed.tv_sec--;
|
||||
}
|
||||
|
||||
fprintf(stderr, "processed %d rule files in %ld.%09lds\n",
|
||||
BENCHMARK_ITERATIONS, elapsed.tv_sec, elapsed.tv_nsec);
|
||||
|
||||
xkb_context_unref(ctx);
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* Copyright © 2009 Dan Nicholson
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#include "../test/test.h"
|
||||
|
||||
#define BENCHMARK_ITERATIONS 2500
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
struct xkb_context *ctx;
|
||||
struct xkb_keymap *keymap;
|
||||
struct timespec start, stop, elapsed;
|
||||
int i;
|
||||
|
||||
ctx = test_get_context(0);
|
||||
assert(ctx);
|
||||
|
||||
xkb_context_set_log_level(ctx, XKB_LOG_LEVEL_CRITICAL);
|
||||
xkb_context_set_log_verbosity(ctx, 0);
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &start);
|
||||
for (i = 0; i < BENCHMARK_ITERATIONS; i++) {
|
||||
keymap = test_compile_rules(ctx, "evdev", "evdev", "us", "", "");
|
||||
assert(keymap);
|
||||
xkb_keymap_unref(keymap);
|
||||
}
|
||||
clock_gettime(CLOCK_MONOTONIC, &stop);
|
||||
|
||||
elapsed.tv_sec = stop.tv_sec - start.tv_sec;
|
||||
elapsed.tv_nsec = stop.tv_nsec - start.tv_nsec;
|
||||
if (elapsed.tv_nsec < 0) {
|
||||
elapsed.tv_nsec += 1000000000;
|
||||
elapsed.tv_sec--;
|
||||
}
|
||||
|
||||
fprintf(stderr, "compiled %d keymaps in %ld.%09lds\n",
|
||||
BENCHMARK_ITERATIONS, elapsed.tv_sec, elapsed.tv_nsec);
|
||||
|
||||
xkb_context_unref(ctx);
|
||||
return 0;
|
||||
}
|
|
@ -13,7 +13,6 @@ log
|
|||
interactive-evdev
|
||||
rmlvo-to-kccgst
|
||||
print-compiled-keymap
|
||||
bench-key-proc
|
||||
atom
|
||||
x11
|
||||
interactive-x11
|
||||
|
|
|
@ -21,14 +21,10 @@
|
|||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#include "test.h"
|
||||
#include "xkbcomp-priv.h"
|
||||
#include "rules.h"
|
||||
|
||||
#define BENCHMARK_ITERATIONS 20000
|
||||
|
||||
struct test_data {
|
||||
/* Rules file */
|
||||
const char *rules;
|
||||
|
@ -88,45 +84,6 @@ test_rules(struct xkb_context *ctx, struct test_data *data)
|
|||
return passed;
|
||||
}
|
||||
|
||||
static void
|
||||
benchmark(struct xkb_context *ctx)
|
||||
{
|
||||
struct timespec start, stop, elapsed;
|
||||
enum xkb_log_level old_level = xkb_context_get_log_level(ctx);
|
||||
int old_verb = xkb_context_get_log_verbosity(ctx);
|
||||
int i;
|
||||
struct xkb_rule_names rmlvo = {
|
||||
"evdev", "pc105", "us,il", ",", "ctrl:nocaps,grp:menu_toggle",
|
||||
};
|
||||
struct xkb_component_names kccgst;
|
||||
|
||||
xkb_context_set_log_level(ctx, XKB_LOG_LEVEL_CRITICAL);
|
||||
xkb_context_set_log_verbosity(ctx, 0);
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &start);
|
||||
for (i = 0; i < BENCHMARK_ITERATIONS; i++) {
|
||||
assert(xkb_components_from_rules(ctx, &rmlvo, &kccgst));
|
||||
free(kccgst.keycodes);
|
||||
free(kccgst.types);
|
||||
free(kccgst.compat);
|
||||
free(kccgst.symbols);
|
||||
}
|
||||
clock_gettime(CLOCK_MONOTONIC, &stop);
|
||||
|
||||
xkb_context_set_log_level(ctx, old_level);
|
||||
xkb_context_set_log_verbosity(ctx, old_verb);
|
||||
|
||||
elapsed.tv_sec = stop.tv_sec - start.tv_sec;
|
||||
elapsed.tv_nsec = stop.tv_nsec - start.tv_nsec;
|
||||
if (elapsed.tv_nsec < 0) {
|
||||
elapsed.tv_nsec += 1000000000;
|
||||
elapsed.tv_sec--;
|
||||
}
|
||||
|
||||
fprintf(stderr, "processed %d times in %ld.%09lds\n",
|
||||
BENCHMARK_ITERATIONS, elapsed.tv_sec, elapsed.tv_nsec);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
|
@ -135,11 +92,6 @@ main(int argc, char *argv[])
|
|||
ctx = test_get_context(0);
|
||||
assert(ctx);
|
||||
|
||||
if (argc > 1 && streq(argv[1], "bench")) {
|
||||
benchmark(ctx);
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct test_data test1 = {
|
||||
.rules = "simple",
|
||||
|
||||
|
|
|
@ -21,13 +21,9 @@
|
|||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#include "evdev-scancodes.h"
|
||||
#include "test.h"
|
||||
|
||||
#define BENCHMARK_ITERATIONS 2500
|
||||
|
||||
static int
|
||||
test_rmlvo_va(struct xkb_context *context, const char *rules,
|
||||
const char *model, const char *layout,
|
||||
|
@ -67,21 +63,6 @@ test_rmlvo(struct xkb_context *context, const char *rules,
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
test_rmlvo_silent(struct xkb_context *context, const char *rules,
|
||||
const char *model, const char *layout,
|
||||
const char *variant, const char *options)
|
||||
{
|
||||
struct xkb_keymap *keymap;
|
||||
|
||||
keymap = test_compile_rules(context, rules, model, layout, variant,
|
||||
options);
|
||||
if (keymap)
|
||||
xkb_keymap_unref(keymap);
|
||||
|
||||
return keymap != NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
test_rmlvo_env(struct xkb_context *ctx, const char *rules, const char *model,
|
||||
const char *layout, const char *variant, const char *options,
|
||||
|
@ -124,36 +105,6 @@ test_rmlvo_env(struct xkb_context *ctx, const char *rules, const char *model,
|
|||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
benchmark(struct xkb_context *context)
|
||||
{
|
||||
struct timespec start, stop, elapsed;
|
||||
enum xkb_log_level old_level = xkb_context_get_log_level(context);
|
||||
int old_verb = xkb_context_get_log_verbosity(context);
|
||||
int i;
|
||||
|
||||
xkb_context_set_log_level(context, XKB_LOG_LEVEL_CRITICAL);
|
||||
xkb_context_set_log_verbosity(context, 0);
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &start);
|
||||
for (i = 0; i < BENCHMARK_ITERATIONS; i++)
|
||||
assert(test_rmlvo_silent(context, "evdev", "evdev", "us", "", ""));
|
||||
clock_gettime(CLOCK_MONOTONIC, &stop);
|
||||
|
||||
xkb_context_set_log_level(context, old_level);
|
||||
xkb_context_set_log_verbosity(context, old_verb);
|
||||
|
||||
elapsed.tv_sec = stop.tv_sec - start.tv_sec;
|
||||
elapsed.tv_nsec = stop.tv_nsec - start.tv_nsec;
|
||||
if (elapsed.tv_nsec < 0) {
|
||||
elapsed.tv_nsec += 1000000000;
|
||||
elapsed.tv_sec--;
|
||||
}
|
||||
|
||||
fprintf(stderr, "compiled %d keymaps in %ld.%09lds\n",
|
||||
BENCHMARK_ITERATIONS, elapsed.tv_sec, elapsed.tv_nsec);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
|
@ -161,11 +112,6 @@ main(int argc, char *argv[])
|
|||
|
||||
assert(ctx);
|
||||
|
||||
if (argc > 1 && streq(argv[1], "bench")) {
|
||||
benchmark(ctx);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define KS(name) xkb_keysym_from_name(name, 0)
|
||||
|
||||
assert(test_rmlvo(ctx, "evdev", "pc105", "us,il,ru,ca", ",,,multix", "grp:alts_toggle,ctrl:nocaps,compose:rwin",
|
||||
|
@ -253,4 +199,5 @@ main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
xkb_context_unref(ctx);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue