diff options
author | Bobby Bingham <koorogi@koorogi.info> | 2014-10-29 20:32:33 -0500 |
---|---|---|
committer | Bobby Bingham <koorogi@koorogi.info> | 2014-10-29 20:32:33 -0500 |
commit | 8a27889d505b07d91ecd03ad1cfeb818b9b440f7 (patch) | |
tree | 733e342e932f67aa56b9554b6d901fea129ad578 /distribute.c | |
parent | 40a6ba5c0a5f544bed9c11dc30b751e05a435b1e (diff) |
Add instrumentation
Track the number of comparisons, swaps, and rotations performed in each
part of the sorting algorithm.
Diffstat (limited to 'distribute.c')
-rw-r--r-- | distribute.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/distribute.c b/distribute.c index d2d1eff..7c2b49f 100644 --- a/distribute.c +++ b/distribute.c @@ -1,9 +1,12 @@ #include <stddef.h> #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); } |