Skip to content

Instantly share code, notes, and snippets.

View nfd's full-sized avatar

Nicholas FitzRoy-Dale nfd

View GitHub Profile
#include <math.h>
/* Random float between 0 and 1 in a uniform distribution */
float random_float(uint32_t uniform)
{
return ldexpf(uniform, -32);
}
/* Random float in a Gaussian distribution with mean of 0 */
float random_gaussian(uint32_t u, uint32_t v)
@nfd
nfd / benchmark.c
Last active August 29, 2015 14:20
Linux benchmark for CI20-os demonstration
#include <sys/time.h>
#include <inttypes.h>
#include <stdio.h>
uint32_t ms(struct timeval *from, struct timeval *to)
{
uint32_t from_ms, to_ms;
from_ms = (from->tv_sec * 1000) + (from->tv_usec / 1000);
to_ms = (to->tv_sec * 1000) + (to->tv_usec / 1000);