toys

toys.git
git clone git://git.lenczewski.org/toys.git
Log | Files | Refs | README | LICENSE

commit 3547cf09725482a7c3b820fa1f4e3e5d06771a4d
parent df9b3ae7e4b1a93812ef46d86cf6d23e825a34d5
Author: MikoĊ‚aj Lenczewski <mblenczewski@gmail.com>
Date:   Thu, 23 Oct 2025 15:44:28 +0100

Tweak queue benchmark

Diffstat:
Mqueue.c | 20++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/queue.c b/queue.c @@ -8,9 +8,10 @@ #include <time.h> static const size_t limit = 1000000000; +static const size_t qsize = PAGESZ_2M; static void * -bench_writer(void *data) +writer(void *data) { struct spsc_queue *queue = data; @@ -29,7 +30,7 @@ bench_writer(void *data) } static void * -bench_reader(void *data) +reader(void *data) { struct spsc_queue *queue = data; @@ -51,17 +52,14 @@ static void benchmark(void) { struct spsc_queue queue; - int res = spsc_queue_init(&queue, PAGESZ_4K, PAGESZ_4K); + int res = spsc_queue_init(&queue, qsize, qsize); assert(res == 0); struct timespec start, end; pthread_t writer_thread, reader_thread; - int reader = pthread_create(&reader_thread, NULL, bench_reader, &queue); - assert(reader == 0); - - int writer = pthread_create(&writer_thread, NULL, bench_writer, &queue); - assert(writer == 0); + pthread_create(&reader_thread, NULL, reader, &queue); + pthread_create(&writer_thread, NULL, writer, &queue); clock_gettime(CLOCK_MONOTONIC_RAW, &start); @@ -80,6 +78,10 @@ benchmark(void) int main(void) { + benchmark(); + + return 0; + int *foo = mirrormap(NULL, PAGESZ_4K, PAGESZ_4K, 2, PROT_READ | PROT_WRITE); int *bar = (void *) ((uintptr_t) foo + PAGESZ_4K); @@ -117,7 +119,5 @@ main(void) queue_free(&queue); - benchmark(); - return 0; }