From dfb7963b4da4a0908c18dda0c83e717dbb097ecd Mon Sep 17 00:00:00 2001 From: Dmitry Simonenko Date: Mon, 5 Feb 2018 15:49:23 +0300 Subject: [PATCH] machinarium: update benchmarks --- .gitignore | 2 +- benchmark/benchmark_channel.c | 2 +- ...mark_queue.c => benchmark_channel_shared.c} | 18 +++++++++--------- benchmark/makefile | 6 +++--- 4 files changed, 14 insertions(+), 14 deletions(-) rename benchmark/{benchmark_queue.c => benchmark_channel_shared.c} (71%) diff --git a/.gitignore b/.gitignore index f406469c..59a36b27 100644 --- a/.gitignore +++ b/.gitignore @@ -4,5 +4,5 @@ sources/build.h benchmark/benchmark_csw benchmark/benchmark_channel -benchmark/benchmark_queue +benchmark/benchmark_channel_shared tests/machinarium_test diff --git a/benchmark/benchmark_channel.c b/benchmark/benchmark_channel.c index cf62d254..67cde908 100644 --- a/benchmark/benchmark_channel.c +++ b/benchmark/benchmark_channel.c @@ -41,7 +41,7 @@ benchmark_runner(void *arg) printf("benchmark started.\n"); machine_channel_t *channel; - channel = machine_channel_create(); + channel = machine_channel_create(0); int r = machine_coroutine_create(benchmark_reader, channel); int w = machine_coroutine_create(benchmark_writer, channel); diff --git a/benchmark/benchmark_queue.c b/benchmark/benchmark_channel_shared.c similarity index 71% rename from benchmark/benchmark_queue.c rename to benchmark/benchmark_channel_shared.c index c672ab0a..e1bf5f0b 100644 --- a/benchmark/benchmark_queue.c +++ b/benchmark/benchmark_channel_shared.c @@ -12,10 +12,10 @@ static int ops = 0; static void benchmark_reader(void *arg) { - machine_queue_t *q = arg; + machine_channel_t *q = arg; while (machine_active()) { machine_msg_t *msg; - msg = machine_queue_get(q, UINT32_MAX); + msg = machine_channel_read(q, UINT32_MAX); if (msg) machine_msg_free(msg); ops++; @@ -25,11 +25,11 @@ benchmark_reader(void *arg) static void benchmark_writer(void *arg) { - machine_queue_t *q = arg; + machine_channel_t *q = arg; while (machine_active()) { machine_msg_t *msg; msg = machine_msg_create(0, 0); - machine_queue_put(q, msg); + machine_channel_write(q, msg); ops++; machine_sleep(0); } @@ -40,8 +40,8 @@ benchmark_runner(void *arg) { printf("benchmark started.\n"); - machine_queue_t *q; - q = machine_queue_create(); + machine_channel_t *q; + q = machine_channel_create(1); int r = machine_coroutine_create(benchmark_reader, q); int w = machine_coroutine_create(benchmark_writer, q); @@ -52,17 +52,17 @@ benchmark_runner(void *arg) machine_join(r); machine_join(w); - machine_queue_free(q); + machine_channel_free(q); printf("done.\n"); - printf("queue operations %d in 1 sec.\n", ops); + printf("channel operations %d in 1 sec.\n", ops); } int main(int argc, char *argv[]) { machinarium_init(); - int id = machine_create("benchmark_queue", benchmark_runner, NULL); + int id = machine_create("benchmark_channel", benchmark_runner, NULL); machine_wait(id); machinarium_free(); return 0; diff --git a/benchmark/makefile b/benchmark/makefile index c52108b2..3d88b89e 100644 --- a/benchmark/makefile +++ b/benchmark/makefile @@ -3,13 +3,13 @@ RM = rm CFLAGS = -I. -Wall -g -O3 -I../sources LFLAGS_LIB = ../sources/libmachinarium.a -pthread -lssl -lcrypto LFLAGS = $(LFLAGS_LIB) -EXAMPLES = benchmark_csw benchmark_channel benchmark_queue +EXAMPLES = benchmark_csw benchmark_channel benchmark_channel_shared all: clean $(EXAMPLES) benchmark_csw: $(CC) $(CFLAGS) benchmark_csw.c $(LFLAGS) -o benchmark_csw benchmark_channel: $(CC) $(CFLAGS) benchmark_channel.c $(LFLAGS) -o benchmark_channel -benchmark_queue: - $(CC) $(CFLAGS) benchmark_queue.c $(LFLAGS) -o benchmark_queue +benchmark_channel_shared: + $(CC) $(CFLAGS) benchmark_channel_shared.c $(LFLAGS) -o benchmark_channel_shared clean: $(RM) -f $(EXAMPLES)