test-bus-kernel-benchmark.c revision 8f155917bf5c11c8f156d7f25f242257d6086cb9
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2013 Lennart Poettering
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.
systemd 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 systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <ctype.h>
#include "util.h"
#include "log.h"
#include "sd-bus.h"
#include "bus-message.h"
#include "bus-error.h"
#include "bus-kernel.h"
#include "bus-internal.h"
#define N_TRIES 500
usec_t x = 0;
int r;
for (;;) {
r = sd_bus_process(b, &m);
assert_se(r >= 0);
if (r == 0)
if (!m)
continue;
/* log_error("huhu %s from %s", sd_bus_message_get_member(m), sd_bus_message_get_sender(m)); */
char *q;
const char *p;
x = now(CLOCK_MONOTONIC);
for (i = 0; i < sz; i++)
q[i] = toupper(p[i]);
x = now(CLOCK_MONOTONIC) - x;
usec_t t;
assert_se(t >= x);
*result = t - x;
return;
} else
assert_not_reached("Unknown method");
}
}
char *p;
const char *q;
usec_t t;
size_t l, i;
for (i = 0; i < sz; i++)
p[i] = 'a' + (char) (i % 26);
t = now(CLOCK_MONOTONIC);
t = now(CLOCK_MONOTONIC) - t;
for (i = 0; i < sz; i++) {
}
}
sd_bus *b;
int r;
r = sd_bus_new(&b);
assert_se(r >= 0);
r = sd_bus_set_address(b, address);
assert_se(r >= 0);
r = sd_bus_start(b);
assert_se(r >= 0);
if (pid == 0) {
sd_bus_unref(b);
r = sd_bus_new(&b);
assert_se(r >= 0);
r = sd_bus_set_address(b, address);
assert_se(r >= 0);
r = sd_bus_start(b);
assert_se(r >= 0);
_exit(0);
}
sd_bus_unref(b);
}
lsize = 1;
for (;;) {
unsigned i;
break;
for (i = 0; i < N_TRIES; i++) {
usec_t t;
run_benchmark(csize, true, &t);
copy += t;
}
for (i = 0; i < N_TRIES; i++) {
usec_t t;
run_benchmark(csize, false, &t);
memfd += t;
}
break;
else
}
return 0;
}