From 8a27889d505b07d91ecd03ad1cfeb818b9b440f7 Mon Sep 17 00:00:00 2001 From: Bobby Bingham Date: Wed, 29 Oct 2014 20:32:33 -0500 Subject: Add instrumentation Track the number of comparisons, swaps, and rotations performed in each part of the sorting algorithm. --- distribute.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'distribute.c') diff --git a/distribute.c b/distribute.c index d2d1eff..7c2b49f 100644 --- a/distribute.c +++ b/distribute.c @@ -1,9 +1,12 @@ #include #include "common.h" +#include "counts.h" void distribute_buffer(char *base, size_t bufnmel, size_t sortnmel, size_t width, cmpfun cmp) { + struct counts snapshot = counts[CURRENT]; + while (bufnmel && sortnmel) { char *sorted = base + bufnmel * width; size_t insertpos = binary_search(base, sorted, sortnmel, width, cmp); @@ -15,4 +18,6 @@ void distribute_buffer(char *base, size_t bufnmel, size_t sortnmel, size_t width bufnmel -= 1; sortnmel -= insertpos; } + + add_counts(counts + DISTRIBUTE, &snapshot); } -- cgit v1.2.3