Skip to content

Commit

Permalink
random bits and pieces
Browse files Browse the repository at this point in the history
  • Loading branch information
majek committed Oct 6, 2010
1 parent dab5df0 commit acbafbe
Show file tree
Hide file tree
Showing 20 changed files with 12,074 additions and 0 deletions.
35 changes: 35 additions & 0 deletions concurrent-read/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
ifeq (debian, $(shell hostname))
ITEMS=100
else
ITEMS=3000
endif

ARGS=\
"normal none none sort pread" \
"normal sort fadvise none pread" \
"normal sort readahead none pread"


B=\
"normal sort fadvise rand gthread512" \
"normal sort fadvise sort gthread512"


all: read_bench random.bin
@for ARGS in $(ARGS); do \
sync; \
sudo bash -c "echo 3 > /proc/sys/vm/drop_caches"; \
sync; \
sudo dd if=/dev/sda of=/dev/null bs=1M count=1 2> /dev/null; \
./read_bench $(ITEMS) $$ARGS; \
done


random.bin:
dd if=/dev/urandom of=random.bin bs=1M count=16



read_bench: read_bench.c
gcc -g -O2 -Wall read_bench.c -o read_bench -lm -lrt -I/usr/lib64/glib-2.0/include -I/usr/lib/glib-2.0/include -I/usr/include/glib-2.0 -lgthread-2.0

4 changes: 4 additions & 0 deletions concurrent-read/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* different options for fadvise - random? dontuse? +
* visualize input data
* random and sorted fadvise

24 changes: 24 additions & 0 deletions concurrent-read/hist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env python
import numpy as np
import matplotlib.mlab as mlab
import matplotlib.pyplot as plt

x = []
for line in open("norm.csv"):
x.append( float(line) )


# the histogram of the data
n, bins, patches = plt.hist(x, 50, normed=1, facecolor='green', alpha=0.75)

# add a 'best fit' line
y = mlab.normpdf( bins, 0, 5)
l = plt.plot(bins, y, 'r--', linewidth=1)

plt.xlabel('Smarts')
plt.ylabel('Probability')
plt.title(r'$\mathrm{Histogram\ of\ IQ:}\ \mu=100,\ \sigma=15$')
plt.axis([-5, 5, 0, 0.8])
plt.grid(True)

plt.show()
Loading

0 comments on commit acbafbe

Please sign in to comment.