Skip to content

Commit a673553

Browse files
committed
small changes
1 parent c0a8d70 commit a673553

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

cauldron/bench.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* arg.h -- A POSIX compliant argument parser based on plan9's arg(3)
1+
/* bench.h -- A minimal benchmarking library
22
* Olaf Bernstein <[email protected]>
33
* Distributed under the MIT license, see license at the end of the file.
44
* New versions available at https://github.com/camel-cdr/cauldron
@@ -57,17 +57,17 @@ typedef struct {
5757
BenchRecord *records;
5858
/* temporaries */
5959
size_t i;
60-
double ns;
60+
double secs;
6161
} Bench;
6262

6363
static Bench benchInternal;
6464

6565
#define BENCH(title, warmup, samples) \
6666
for (bench_append(title), \
6767
benchInternal.i = (warmup) + (samples); \
68-
(benchInternal.ns = bench_gettime()), benchInternal.i--; \
68+
(benchInternal.secs = bench_gettime()), benchInternal.i--; \
6969
benchInternal.i < (samples) ? \
70-
bench_update(bench_gettime()-benchInternal.ns),0 : 0)
70+
bench_update(bench_gettime()-benchInternal.secs),0 : 0)
7171

7272
static inline double
7373
bench_gettime(void)
@@ -143,8 +143,13 @@ bench_done(void)
143143
putchar(' ');
144144

145145
printf("mean: %.9e, stddev: %.2e, min: %.9e \n",
146+
#ifdef BENCH_DONT_NORMALIZE
147+
b->records[i].mean,
148+
sqrt(b->records[i].M2 / b->records[i].count),
149+
#else
146150
b->records[i].mean / minmean,
147151
sqrt(b->records[i].M2 / b->records[i].count) / minmean,
152+
#endif
148153
b->records[i].min);
149154
}
150155
b->count = 0;

cauldron/random.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
* 6. Shuffling
2828
* References
2929
* Licensing
30-
* Alternative A - MIT License
30+
* MIT License
3131
*
3232
* 1. Introduction =============================================================
3333
*
@@ -68,6 +68,7 @@
6868
# endif
6969
#endif
7070

71+
#include <limits.h>
7172
#include <float.h>
7273
#include <stddef.h>
7374
#include <stdint.h>
@@ -1453,6 +1454,13 @@ dist_uniform(uint64_t x)
14531454
}
14541455

14551456
/*
1457+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1458+
* WARNING: this code does currently not work correctly for subnormals.
1459+
* The probability of subnormals isn't quite correct, and there needs to be
1460+
* a new special case for subnormals when both a and b are subnormals.
1461+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1462+
*
1463+
*
14561464
* Another solution is to generate every representable floating-point number
14571465
* with a probability proportional to the covered real number range. <15>
14581466
* So obtaining a number in a floating-point subrange [s1,s2] of the output

cauldron/stretchy-buffer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ sb__realloc(void *ptr, size_t num_bytes)
4040
/* can be zero initialized */
4141
#define Sb(T) struct { T *at; size_t _len, _cap; }
4242

43-
#define sb_len(a) ((size_t const)(a)._len)
44-
#define sb_cap(a) ((size_t const)(a)._cap)
43+
#define sb_len(a) (+(a)._len)
44+
#define sb_cap(a) (+(a)._cap)
4545

4646
#define sb_begin(a) ((a).at)
4747
#define sb_last(a) ((a).at + (a)._len - 1)

0 commit comments

Comments
 (0)