From fd1e09a6d42aae0876f6f6545759583bbac0de0c Mon Sep 17 00:00:00 2001 From: Dave Taht Date: Fri, 6 Jan 2012 16:00:03 +0100 Subject: [PATCH] current tests --- src/staqfq.lua | 4 +- test/cdf.lua | 36 ++++++ test/gnuplot_examples/gnuplot.org | 97 +++++++++++++++++ test/gnuplot_examples/sin.log | 175 ++++++++++++++++++++++++++++++ 4 files changed, 310 insertions(+), 2 deletions(-) create mode 100644 test/cdf.lua create mode 100644 test/gnuplot_examples/gnuplot.org create mode 100644 test/gnuplot_examples/sin.log diff --git a/src/staqfq.lua b/src/staqfq.lua index 759b688..f7b1cb4 100755 --- a/src/staqfq.lua +++ b/src/staqfq.lua @@ -47,8 +47,8 @@ MAX_HWQ_BYTES=4500 -- 24, which is far, far better than 1000. -- might need to be larger on gigE+ -BIGDISC="pfifo_head_drop limit 12" -MDISC="pfifo limit 16" +BIGDISC="pfifo_head_drop limit 24" +MDISC="pfifo limit 32" NORMDISC="pfifo limit 32" -- You shouldn't need to touch anything after this line diff --git a/test/cdf.lua b/test/cdf.lua new file mode 100644 index 0000000..ee0b718 --- /dev/null +++ b/test/cdf.lua @@ -0,0 +1,36 @@ +-- A cumulative distribution function should be EASY in lua +-- I was going to try to get gnuplot to do it, but I like it +-- as data - I can look at the 50% on a large number of plots +-- and know I'm winning + +-- There happens to be a one liner to do this in gnuplot as well + +-- via: http://www.christian-rossow.de/articles/Cumulative_Distribution_Function_CDF_With_Gnuplot_And_PostgreSQL.php + +SELECT + -- x-value: number of cars + cars AS x, + -- y-value: percentage of days at most x cars passed the street + -- calculated as the number of days with at most x cars devided by + -- the total number days in the measurement period + COUNT(day) OVER (ORDER BY cars) / + (SELECT COUNT(*) FROM cars_per_day)::real AS y +FROM cars_per_day + +In statistics, CDFs are a common way to describe the probability that a random variable Z with a given probability distribution will be found at a value less than or equal to Z. Have a look at Figure 1. It shows a CDF for how many cars are passing on my street per day. You can read it like this: 35 or fewer cars (x-axis) are passing on my street in approximately 60% (y-axis) of all days. + +Now comes the tricky thing. Listing 1 shows how I stored the data in my database. As everyone would do it, I just inserted one row per measurement interval (i.e., a day). + +Listing 1: Plain measurement results in table 'cars_per_day' + +day cars +1 8 +2 25 +3 47 +4 16 +5 25 +6 39 +7 5 + + +However, to draw a CDF, gnuplot expects the following format: Given a number of cars Z (x-value), what percentage of days at most Z cars passed on the street? To make this more clear, Listing 2 shows the outcome that gnuplot expects. diff --git a/test/gnuplot_examples/gnuplot.org b/test/gnuplot_examples/gnuplot.org new file mode 100644 index 0000000..f3b2101 --- /dev/null +++ b/test/gnuplot_examples/gnuplot.org @@ -0,0 +1,97 @@ +* Logscale +set logscale y +plot "silver.dat" t "rate" w errorb, \ + "" smooth sbezier t "bezier" + + +* multipole data sets + +set xrange [1:8] +#set xdtic +set title "Convex November 1-7 1989" +set key below +set label "(Weekend)" at 5,25 center +plot 'using.dat' using 3:4 title "Logged in" with impulses,\ + 'using.dat' using 3:5 t "Load average" with points,\ + 'using.dat' using 3:6 t "%CPU used" with lines +unset label + +# set terminal png transparent nocrop enhanced font arial 8 size 420,320 +# set output 'using.2.png' +set key bmargin center horizontal Right noreverse enhanced autotitles box linetype -1 linewidth 1.000 +set title "Convex November 1-7 1989" +set xrange [ 1.00000 : 8.00000 ] noreverse nowriteback +plot 'using.dat' using 3:4 title "Logged in" with impulses, 'using.dat' using 3:5 t "Load average" with points, 'using.dat' using 3:6 t "%CPU used" with lines + +* This gives me my dots + +# +# $Id: random.dem,v 1.12.2.1 2006/10/23 05:43:30 sfeam Exp $ +# +# random.dem +# +# Lattice test for random numbers; +# If you can see any patterns in this plot, the random number generator +# is not very good. +# +# Copyright (c) 1991, Jos van der Woude, jvdwoude@hut.nl + +# History: +# - 6. 6. 2006 ds: added univariate and multivariate normal example +# - 10. 5. 2006 ds: added univariate and multivariate normal example +# - ?. ? 1991 jvdw: 1st version + +unset key +set xrange [0: 1] +set yrange [0: 1] +set zrange [0: 1] +set title "Lattice test for random numbers" +set xlabel "rand(n) ->" +set ylabel "rand(n + 1) ->" +set zlabel "rand(n + 2) ->" +set format x "%3.2f" +set format y "%3.2f" +set format z "%3.2f" +set tics +set sample 1000 +set style function dots +set parametric +plot rand(0), rand(0) +** +set terminal png transparent nocrop enhanced font arial 8 size 1000,1000 +set output 'random.1.png' +set dummy t,y +set format x "%3.2f" +set format y "%3.2f" +set format z "%3.2f" +unset key +set parametric +set samples 1000, 1000 +set style function dots +set title "Lattice test for random numbers" +set xlabel "rand(n) ->" +set xrange [ 0.00000 : 1.00000 ] noreverse nowriteback +set ylabel "rand(n + 1) ->" +set yrange [ 0.00000 : 1.00000 ] noreverse nowriteback +set zlabel "rand(n + 2) ->" +set zrange [ 0.00000 : 1.00000 ] noreverse nowriteback +plot rand(0), rand(0) +* Colors + +set border -1 front linetype -1 linewidth 1.000 +set ticslevel 0 +set xtics border +set ytics border +set ztics border +set xlabel "Red" tc rgb "red" +set xrange [0:255] +set ylabel "Green" tc rgb "green" +set yrange [0:255] +set zlabel "Blue" tc rgb "blue" +set zrange [0:255] +# +rgb(r,g,b) = int(r)*65536 + int(g)*256 + int(b) +# +splot 'rgb_variable.dat' using 1:2:3:(rgb($1,$2,$3)) with points pt 7 ps 4 lc rgb variable, \ + '' using 1:2:3:(sprintf("0x%x",rgb($1,$2,$3))) with labels left offset 1 notitle + diff --git a/test/gnuplot_examples/sin.log b/test/gnuplot_examples/sin.log new file mode 100644 index 0000000..04a9150 --- /dev/null +++ b/test/gnuplot_examples/sin.log @@ -0,0 +1,175 @@ +This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian) (format=pdflatex 2011.10.28) 31 DEC 2011 01:08 +entering extended mode + %&-line parsing enabled. +**sin.tex +(./sin.tex +LaTeX2e <2009/09/24> +Babel and hyphenation patterns for english, usenglishmax, dumylang, noh +yphenation, loaded. +(/usr/share/texmf-texlive/tex/latex/base/article.cls +Document Class: article 2007/10/19 v1.4h Standard LaTeX document class +(/usr/share/texmf-texlive/tex/latex/base/size10.clo +File: size10.clo 2007/10/19 v1.4h Standard LaTeX file (size option) +) +\c@part=\count79 +\c@section=\count80 +\c@subsection=\count81 +\c@subsubsection=\count82 +\c@paragraph=\count83 +\c@subparagraph=\count84 +\c@figure=\count85 +\c@table=\count86 +\abovecaptionskip=\skip41 +\belowcaptionskip=\skip42 +\bibindent=\dimen102 +) +(/usr/share/texmf-texlive/tex/latex/base/fontenc.sty +Package: fontenc 2005/09/27 v1.99g Standard LaTeX package + +(/usr/share/texmf-texlive/tex/latex/base/t1enc.def +File: t1enc.def 2005/09/27 v1.99g Standard LaTeX file +LaTeX Font Info: Redeclaring font encoding T1 on input line 43. +)) +(/usr/share/texmf-texlive/tex/latex/base/textcomp.sty +Package: textcomp 2005/09/27 v1.99g Standard LaTeX package +Package textcomp Info: Sub-encoding information: +(textcomp) 5 = only ISO-Adobe without \textcurrency +(textcomp) 4 = 5 + \texteuro +(textcomp) 3 = 4 + \textohm +(textcomp) 2 = 3 + \textestimated + \textcurrency +(textcomp) 1 = TS1 - \textcircled - \t +(textcomp) 0 = TS1 (full) +(textcomp) Font families with sub-encoding setting implement +(textcomp) only a restricted character set as indicated. +(textcomp) Family '?' is the default used for unknown fonts. +(textcomp) See the documentation for details. +Package textcomp Info: Setting ? sub-encoding to TS1/1 on input line 71. + +(/usr/share/texmf-texlive/tex/latex/base/ts1enc.def +File: ts1enc.def 2001/06/05 v3.0e (jk/car/fm) Standard LaTeX file +) +LaTeX Info: Redefining \oldstylenums on input line 266. +Package textcomp Info: Setting cmr sub-encoding to TS1/0 on input line 281. +Package textcomp Info: Setting cmss sub-encoding to TS1/0 on input line 282. +Package textcomp Info: Setting cmtt sub-encoding to TS1/0 on input line 283. +Package textcomp Info: Setting cmvtt sub-encoding to TS1/0 on input line 284. +Package textcomp Info: Setting cmbr sub-encoding to TS1/0 on input line 285. +Package textcomp Info: Setting cmtl sub-encoding to TS1/0 on input line 286. +Package textcomp Info: Setting ccr sub-encoding to TS1/0 on input line 287. +Package textcomp Info: Setting ptm sub-encoding to TS1/4 on input line 288. +Package textcomp Info: Setting pcr sub-encoding to TS1/4 on input line 289. +Package textcomp Info: Setting phv sub-encoding to TS1/4 on input line 290. +Package textcomp Info: Setting ppl sub-encoding to TS1/3 on input line 291. +Package textcomp Info: Setting pag sub-encoding to TS1/4 on input line 292. +Package textcomp Info: Setting pbk sub-encoding to TS1/4 on input line 293. +Package textcomp Info: Setting pnc sub-encoding to TS1/4 on input line 294. +Package textcomp Info: Setting pzc sub-encoding to TS1/4 on input line 295. +Package textcomp Info: Setting bch sub-encoding to TS1/4 on input line 296. +Package textcomp Info: Setting put sub-encoding to TS1/5 on input line 297. +Package textcomp Info: Setting uag sub-encoding to TS1/5 on input line 298. +Package textcomp Info: Setting ugq sub-encoding to TS1/5 on input line 299. +Package textcomp Info: Setting ul8 sub-encoding to TS1/4 on input line 300. +Package textcomp Info: Setting ul9 sub-encoding to TS1/4 on input line 301. +Package textcomp Info: Setting augie sub-encoding to TS1/5 on input line 302. +Package textcomp Info: Setting dayrom sub-encoding to TS1/3 on input line 303. +Package textcomp Info: Setting dayroms sub-encoding to TS1/3 on input line 304. + +Package textcomp Info: Setting pxr sub-encoding to TS1/0 on input line 305. +Package textcomp Info: Setting pxss sub-encoding to TS1/0 on input line 306. +Package textcomp Info: Setting pxtt sub-encoding to TS1/0 on input line 307. +Package textcomp Info: Setting txr sub-encoding to TS1/0 on input line 308. +Package textcomp Info: Setting txss sub-encoding to TS1/0 on input line 309. +Package textcomp Info: Setting txtt sub-encoding to TS1/0 on input line 310. +Package textcomp Info: Setting futs sub-encoding to TS1/4 on input line 311. +Package textcomp Info: Setting futx sub-encoding to TS1/4 on input line 312. +Package textcomp Info: Setting futj sub-encoding to TS1/4 on input line 313. +Package textcomp Info: Setting hlh sub-encoding to TS1/3 on input line 314. +Package textcomp Info: Setting hls sub-encoding to TS1/3 on input line 315. +Package textcomp Info: Setting hlst sub-encoding to TS1/3 on input line 316. +Package textcomp Info: Setting hlct sub-encoding to TS1/5 on input line 317. +Package textcomp Info: Setting hlx sub-encoding to TS1/5 on input line 318. +Package textcomp Info: Setting hlce sub-encoding to TS1/5 on input line 319. +Package textcomp Info: Setting hlcn sub-encoding to TS1/5 on input line 320. +Package textcomp Info: Setting hlcw sub-encoding to TS1/5 on input line 321. +Package textcomp Info: Setting hlcf sub-encoding to TS1/5 on input line 322. +Package textcomp Info: Setting pplx sub-encoding to TS1/3 on input line 323. +Package textcomp Info: Setting pplj sub-encoding to TS1/3 on input line 324. +Package textcomp Info: Setting ptmx sub-encoding to TS1/4 on input line 325. +Package textcomp Info: Setting ptmj sub-encoding to TS1/4 on input line 326. +) +(/usr/share/texmf-texlive/tex/latex/base/inputenc.sty +Package: inputenc 2008/03/30 v1.1d Input encoding file +\inpenc@prehook=\toks14 +\inpenc@posthook=\toks15 + + +! LaTeX Error: File `utf8x.def' not found. + +Type X to quit or to proceed, +or enter new name. (Default extension: def) + +Enter file name: + +Package inputenc Warning: No characters defined +(inputenc) by input encoding change to `utf8x' +(inputenc) on input line 131. + +) + +! LaTeX Error: File `gnuplot-lua-tikz.sty' not found. + +Type X to quit or to proceed, +or enter new name. (Default extension: sty) + +Enter file name: + +! LaTeX Error: File `preview.sty' not found. + +Type X to quit or to proceed, +or enter new name. (Default extension: sty) + +Enter file name: + +! LaTeX Error: Unknown option `active' for package `preview'. + +See the LaTeX manual or LaTeX Companion for explanation. +Type H for immediate help. + ... + +l.10 \PreviewEnvironment + {tikzpicture} +? + +! LaTeX Error: Unknown option `tightpage' for package `preview'. + +See the LaTeX manual or LaTeX Companion for explanation. +Type H for immediate help. + ... + +l.10 \PreviewEnvironment + {tikzpicture} +? \q +Type to proceed, S to scroll future error messages, +R to run without stopping, Q to run quietly, +I to insert something, E to edit your file, +1 or ... or 9 to ignore the next 1 to 9 tokens of input, +H for help, X to quit. +? +! Emergency stop. + ... + +l.10 \PreviewEnvironment + {tikzpicture} +The option `tightpage' was not declared in package `preview', perhaps you +misspelled its name. Try typing to proceed. + + +Here is how much of TeX's memory you used: + 860 strings out of 495061 + 10350 string characters out of 1182620 + 48997 words of memory out of 3000000 + 4110 multiletter control sequences out of 15000+50000 + 4403 words of font info for 15 fonts, out of 3000000 for 9000 + 28 hyphenation exceptions out of 8191 + 23i,0n,19p,158b,37s stack positions out of 5000i,500n,10000p,200000b,50000s +! ==> Fatal error occurred, no output PDF file produced!