Permalink
Browse files

GC old ocaml stats scripts

  • Loading branch information...
1 parent 31ccf86 commit fce5bf99213e33cf0800a7d09b13f5319806855e @avsm avsm committed Feb 1, 2012
Showing with 0 additions and 335 deletions.
  1. +0 −27 plot.r
  2. +0 −1 stats/_tags
  3. +0 −2 stats/build.sh
  4. +0 −91 stats/parse.ml
  5. +0 −10 stats/results.ml
  6. +0 −95 stats/stats.ml
  7. +0 −109 stats/summarise.ml
View
27 plot.r
@@ -1,27 +0,0 @@
-plot_fields <- function (inp, lats, xlab, ylab, t) {
- nlats <- length(lats)
- all_lats <- subset(inp, name %in% lats)
- xrange <- range(all_lats$size)
- yrange <- range(all_lats$result)
- plot(xrange, yrange, type="n", xlab=xlab, ylab=ylab)
- title(t)
- colors <- rainbow(nlats)
- linetype <- c(1:nlats)
- plotchar <- seq(18,18+nlats,1)
- for (i in 1:nlats) {
- tree <- subset(inp, name==lats[i])
- lines(tree$size, tree$result, type="b", lwd=1.5,
- lty=linetype[i], col=colors[i], pch=plotchar[i])
- }
- legend(xrange[1], yrange[2], lats, cex=0.8, col=colors,
- pch=plotchar, lty=linetype)
-}
-
-inp_same <- read.table("results-same.csv", header=T)
-inp_diff <- read.table("results-diff.csv", header=T)
-
-par(mfrow=c(2,2))
-plot_fields(inp_same, c("unix_lat", "pipe_lat", "tcp_lat"), "request size (bytes)", "avg latency (us)", "Latency (same CPU)");
-plot_fields(inp_same, c("unix_thr", "pipe_thr", "tcp_thr"), "request size (bytes)", "avg throughput (Mbs)", "Throughput (same CPU)")
-plot_fields(inp_diff, c("unix_lat", "pipe_lat", "tcp_lat"), "request size (bytes)", "avg latency (us)", "Latency (different CPU)");
-plot_fields(inp_diff, c("unix_thr", "pipe_thr", "tcp_thr"), "request size (bytes)", "avg throughput (Mbs)", "Throughput (different CPU)")
View
@@ -1 +0,0 @@
-true: annot
View
@@ -1,2 +0,0 @@
-#!/bin/sh
-ocamlbuild parse.native summarise.native
View
@@ -1,91 +0,0 @@
-(*
- * Copyright (c) 2011 Anil Madhavapeddy <anil@recoil.org>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- *)
-open Printf
-open Scanf
-open Results
-
-(* test parameters *)
-let os = "native48"
-let basedir = "../results.sizes.native48"
-let sizes = [ 128; 4096; 65536 ]
-let modes = [ "thr"; "lat" ]
-let tests = [ "pipe"; "unix"; "tcp"; "tcp_nodelay"; "mempipe"; "vmsplice_pipe" ]
-let ncores = 48
-(* results array is a list of data points *)
-let res : results = Array.make_matrix ncores ncores []
-
-(* progress bar *)
-let pctr = ref 0
-let ping () =
- incr pctr;
- if (!pctr mod 100) = 0 then fprintf stderr "%d\n%!" !pctr
-
-let parse_tsc transformfn fname =
- let fin = open_in fname in
- let points = ref [] in
- (try
- while true do
- points := (transformfn (float_of_string (input_line fin))) :: !points;
- done with End_of_file -> close_in fin);
- Stats.std_dev !points
-
-(* Parse a test directory and add it to the results matrix *)
-let parse ~c1 ~c2 ~mode ~size ~test =
- let file = sprintf "%s/%d/%d-%d-%s_%s/01-%s_%s-headline.log"
- basedir size c1 c2 test mode test mode in
- let rawtsc = sprintf "%s/%d/%d-%d-%s_%s/01-%s_%s-raw_tsc.log"
- basedir size c1 c2 test mode test mode in
- fprintf stderr "%s\n%!" file;
- try
- let fin = open_in file in
- let r = match mode with
- |"thr" ->
- fscanf fin "%s %d %d %f Mbps"
- (fun name size count result ->
- let stddev = parse_tsc
- (fun r -> (float (size) *. 8.) /. (r *. 1e6)) rawtsc in
- { test; size; mode; count; result; stddev }
- )
- |"lat" ->
- let stddev = parse_tsc (fun r -> r) rawtsc in
- fscanf fin "%s %d %d %fs"
- (fun name size count result ->
- { test; size; mode; count; result; stddev }
- )
- |_ -> assert false
- in close_in fin;
- ping ();
- res.(c1).(c2) <- r :: res.(c1).(c2)
- with Sys_error e -> fprintf stderr "err %s!\n%!" e
-
-let _ =
- List.iter (fun test ->
- List.iter (fun size ->
- List.iter (fun mode ->
- for c1 = 0 to ncores - 1 do
- for c2 = 0 to ncores - 1 do
- parse ~c1 ~c2 ~mode ~size ~test
- done
- done
- ) modes
- ) sizes
- ) tests;
- let fname = sprintf "results.%s.marshal" os in
- fprintf stderr "output file: %s\n%!" fname;
- let fout = open_out fname in
- Marshal.to_channel fout res [];
- close_out fout
View
@@ -1,10 +0,0 @@
-type res = {
- test: string;
- size: int;
- mode: string;
- count: int;
- result: float;
- stddev: float;
-}
-
-type results = res list array array
View
@@ -1,95 +0,0 @@
-(*
- * Copyright (c) 2004 Anil Madhavapeddy <anil@recoil.org>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- *)
-
-let mean l =
- let len = float_of_int (List.length l) in
- let sum = List.fold_left (+.) 0. l in
- sum /. len
-
-(* Given a results array and a function to convert a node to a float,
- calculate the mean *)
-let mean_grid g fn =
- let sum = Array.fold_left (fun a rows ->
- a +. (Array.fold_left (fun a r ->
- a +. (fn r)) 0. rows)) 0. g in
- let len = (float) ((Array.length g) * (Array.length g)) in
- sum /. len
-
-(* Given a results array, calculate the mean but ignore the centre diagonal
- when x=y *)
-let mean_grid ?(use=`all) g fn =
- let sum = ref 0. in
- Array.iteri (fun c1 col ->
- Array.iteri (fun c2 allres ->
- match use with
- |`all -> sum := !sum +. (fn allres)
- |`no_diag -> if c1 != c2 then sum := !sum +. (fn allres)
- |`diag -> if c1 = c2 then sum := !sum +. (fn allres)
- ) col
- ) g;
- let len =
- match use with
- |`all -> (Array.length g) * (Array.length g)
- |`no_diag -> (Array.length g) * (Array.length g - 1)
- |`diag -> Array.length g
- in
- !sum /. (float len)
-
-let std_dev l =
- let fl = float_of_int (List.length l) in
- let sqdev s = ((mean l) -. s) ** 2. in
- let sumsqdev = List.fold_left (fun a b -> a +. (sqdev b)) 0. l in
- sqrt (sumsqdev /. (fl -. 1.))
-
-let std_moment e l =
- let fl = float_of_int (List.length l - 1) in
- let raisedev s = ((mean l) -. s) ** e in
- let sumdev = List.fold_left (fun a b -> a +. (raisedev b)) 0. l in
- let stddevraised = (std_dev l) ** e in
- sumdev /. (fl *. stddevraised)
-
-(* skewness measures the left/right of normal, kurtosis is peak of normal,
- see http://www.itl.nist.gov/div898/handbook/eda/section3/eda35b.htm *)
-let skewness = std_moment 3.
-let kurtosis l = (std_moment 4. l) -. 3.
-
-(* variance of a data set is std_dev squared *)
-let variance l =
- let sd = std_dev l in
- sd *. sd
-
-(* standard deviation / root n *)
-let avg_error l =
- let fl = float_of_int (List.length l) in
- (std_dev l) /. (sqrt fl)
-
-(* see http://www.inf.ethz.ch/personal/gutc/lognormal/maths/node10.html *)
-let log_mean l =
- let mu = mean l in
- let sigmasq = (std_dev l) ** 2. in
- exp (mu +. (sigmasq /. 2.))
-
-(* see http://www.inf.ethz.ch/personal/gutc/lognormal/maths/node10.html *)
-let log_sigma l =
- let mu = mean l in
- let sigmasq = (std_dev l) ** 2. in
- let a = (exp sigmasq) -. 1. in
- (exp ((2. *. mu) +. sigmasq)) *. a
-
-(* calculate z-score for an observation given stddev and mean *)
-let zscore stddev mean x =
- (x -. mean) /. stddev
View
@@ -1,109 +0,0 @@
-(*
- * Copyright (c) 2011 Anil Madhavapeddy <anil@recoil.org>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- *)
-open Printf
-open Results
-
-(* Output an HTML grid applied against the matrix *)
-let grid oc res fn =
- fprintf oc "<table>\n";
- Array.iteri (fun c1 col ->
- fprintf oc " <tr>\n";
- Array.iteri (fun c2 allres ->
- fprintf oc " <td>";
- fprintf oc (fn allres);
- fprintf oc " </td>\n"
- ) col;
- fprintf oc " </tr>\n";
- ) res;
- fprintf oc "</table>"
-
-(* Obtain a single results grid for a given test, size, mode *)
-let get_grid ~test ~size ~mode res =
- let len = Array.length res in
- let g = Array.make_matrix len len (0.,0.) in
- Array.iteri (fun c1 col ->
- Array.iteri (fun c2 allres ->
- match List.filter (fun r ->
- r.test = test && r.size = size && r.mode=mode) allres with
- |[{result;stddev}] -> g.(c1).(c2) <- (result, stddev)
- |x -> failwith (sprintf "%d results %s %d %s" (List.length x) test size mode)
- ) col
- ) res;
- g
-
-(* Get list of test names for a given mode. We assume all tests are run on
- all cores *)
-let get_test_names ~mode res =
- List.fold_left (fun a b ->
- if b.mode = mode then
- (if List.mem b.test a then a else b.test :: a)
- else
- a
- ) [] res.(0).(0)
-
-let show_test ~sizes ~tests ~mode ~use oc res =
- fprintf oc "TEST: %s (%s)\n" mode
- (match use with
- |`all -> "all results"
- |`no_diag -> "discarding same core"
- |`diag -> "only same core"
- );
- fprintf oc "%-20s %!" "Test/Req size";
- List.iter (fun sz -> fprintf oc "%-20s" (string_of_int sz)) sizes;
- fprintf oc "\n%!";
- List.iter (fun test ->
- fprintf oc "%-20s %!" (test ^ "_thr");
- List.iter (fun size ->
- let grid = get_grid ~test ~size ~mode res in
- match mode with
- |"lat" ->
- let mean = Stats.mean_grid ~use grid (fun (a,b) -> a *. 1e6) in
- let stddev = Stats.mean_grid ~use grid (fun (a,b) -> b *. 1e6) in
- fprintf oc "%-20s" (sprintf "%.2f (%.2f)" mean stddev)
- |"thr" ->
- let mean = Stats.mean_grid ~use grid fst in
- let stddev = Stats.mean_grid ~use grid snd in
- fprintf oc "%-20s" (sprintf "%.2f (%.2f)" mean stddev)
- |_ -> assert false
- ) sizes;
- fprintf stderr "\n%!"
- ) tests;
- fprintf oc "-----\n%!"
-
-let _ =
- let fname = "results.native48.marshal" in
- let fin = open_in fname in
- let res : results = Marshal.from_channel fin in
- close_in fin;
-
- let ncores = Array.length res in
- fprintf stderr "number of cores: %d\n\n%!" ncores;
-
- (* First, summarise throughput across all cores *)
- let oc = stderr in
- let sizes = [ 128; 4096; 65536 ] in
- List.iter (fun use ->
- let mode = "thr" in
- let tests = get_test_names mode res in
- show_test ~sizes ~tests ~mode ~use oc res;
-
- let mode = "lat" in
- let tests = get_test_names mode res in
- show_test ~sizes ~tests ~mode ~use oc res;
- ) [`all; `no_diag; `diag];
-
- ()

0 comments on commit fce5bf9

Please sign in to comment.