Created
January 29, 2019 08:46
-
-
Save spence/fdedd0ce310c3cfe25fdaffbd05f08cf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# brew install gnuplot | |
histfile=histogram-bytes.png | |
# histfile=histogram-random.png | |
psql -p5432 -h localhost -d happy_dev -U happy_dev << EOF 2>&1 | head -n -1 | cut -d' ' -f3 | gnuplot -p -e "n=100;max=9999.;min=1000.;width=(max-min)/n;hist(x,width)=width*floor(x/width)+width/2.0;set term png;set output '$histfile';set xrange [min:max];set yrange [0:];set offset graph 0.05,0.05,0.05,0.0;set xtics min,(max-min)/5,max;set boxwidth width*0.9;set style fill solid 0.5;set tics out nomirror;set xlabel 'x';set ylabel 'Frequency';plot '-' u (hist(\$1,width)):(1.0) smooth freq w boxes lc rgb'green' notitle;" | |
DO | |
\$do\$ | |
DECLARE | |
i INT; | |
BEGIN | |
FOR i IN 1..1000 LOOP | |
SELECT LEFT(('x' || RIGHT(gen_random_bytes(3)::TEXT, 6))::BIT(24)::INT::TEXT, 4)::INT INTO i; | |
-- SELECT (random() * 8999)::INT + 1000 INTO i; | |
RAISE NOTICE '%', i; | |
END LOOP; | |
END | |
\$do\$; | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment