Skip to content

Instantly share code, notes, and snippets.

View umbs's full-sized avatar

Bhaskar Sarma Upadhyayula umbs

View GitHub Profile
@umbs
umbs / latency.txt
Created February 22, 2014 00:13 — forked from jboner/latency.txt
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms
Read 4K randomly from SSD* 150,000 ns 0.15 ms
/* Very rudimentary test of randomness */
void testRandom(randFunc rF, int a, int b)
{
if (rF == NULL) return;
float *dist;
dist = malloc(sizeof(float) * (b-a+1));
int num = b-a+1;
for (int i=0; i<num; i++) dist[i] = 0.0;
typedef struct node_ {
int key;
struct node_ *left, *right, *parent;
} node;
// A utility function to create a new node
node *newNode(int item) {
node *temp = (node *)malloc(sizeof(node));
temp->key = item;
temp->left = temp->right = temp->parent = NULL;