chiark / gitweb /
Makefile, chain.c: Use Xyla found using `pkg-config'.
[wordchain] / format-data
1 #! /usr/bin/perl -w
2
3 use autodie;
4 use strict;
5
6 our %MAP =
7   ("c++-map"        => 'GNU \textsf{libstdc++} \textsf{std::map}',
8    "c++-uomap"      => 'GNU \textsf{libstdc++} \textsf{std::unordered\_map}',
9    "golang"         => 'Golang \textsf{map}',
10    "libavl-avl"     => 'GNU \textsf{libavl} plain AVL trees',
11    "libavl-pavl"    => 'GNU \textsf{libavl} AVL trees, parent pointers',
12    "libavl-rtavl"   => 'GNU \textsf{libavl} AVL trees, right threaded',
13    "libavl-tavl"    => 'GNU \textsf{libavl} AVL trees, threaded',
14    "libavl-rb"      => 'GNU \textsf{libavl} plain red-black trees',
15    "libavl-prb"    => 'GNU \textsf{libavl} red-black trees, parent pointers',
16    "libavl-rtrb"    => 'GNU \textsf{libavl} red-black trees, right threaded',
17    "libavl-trb"     => 'GNU \textsf{libavl} red-black trees, threaded',
18    "lisp-ccl"       => 'Common Lisp (Clozure CL)',
19    "lisp-clisp"     => 'Common Lisp (GNU CLisp)',
20    "lisp-cmucl"     => 'Common Lisp (CMU CL)',
21    "lisp-ecl"       => 'Common Lisp (ECL)',
22    "lisp-sbcl"      => 'Common Lisp (SBCL)',
23    "mLib-sym"       => 'mLib, \textsf{sym} hash table',
24    "perl"           => 'Perl hash',
25    "posix-hsearch1" => 'POSIX hsearch (glibc, fixed size)',
26    "posix-hsearchg" => 'POSIX hsearch (glibc, growing)',
27    "posix-tsearch"  => 'POSIX tsearch (glibc)',
28    "python"         => 'Python \textsf{dict}',
29    "qptrie-qp-fanf" => 'Four-bit QP-trie, recursive \textsf{Tnextl}',
30    "qptrie-qp-mdw"  => 'Four-bit QP-trie, iterative \textsf{Tnextl}',
31    "qptrie-qp-list" => 'Four-bit QP-trie, linked list',
32    "qptrie-fn-fanf" => 'Five-bit QP-trie, recursive \textsf{Tnextl}',
33    "qptrie-fn-mdw"  => 'Five-bit QP-trie, iterative \textsf{Tnextl}',
34    "qptrie-fn-list" => 'Five-bit QP-trie, linked list',
35    "rust-btree"     => 'Rust \textsf{std::collections::BTreeMap}',
36    "rust-hash"      => 'Rust \textsf{std::collections::HashMap}',
37    "sgt-tree234"    => "Simon Tatham's 2-3-4 tree",
38    "xyla-avl"       => 'Xyla AVL tree',
39    "xyla-rb"        => 'Xyla red-black tree',
40    "xyla-splay"     => 'Xyla splay tree',
41    "xyla-treap"     => 'Xyla treap');
42
43 our @STAT = ("lower whisker",
44              "lower quartile",
45              "median",
46              "average",
47              "upper quartile",
48              "upper whisker");
49
50 my @X;
51 while (<>) {
52   my ($impl, $data, $stat) = m{ ^ (\S+)
53                                  ((?: \s+ [0-9.]+)*) \s* \;
54                                  ((?: \s+ [0-9.]+){6}) \s* $ }x
55     or die "bad line";
56   my @data = map { $_ + 0.0 } split ' ', $data;
57   my @stat = map { $_ + 0.0 } split ' ', $stat;
58   my ($wlo, undef, undef, undef, undef, $whi) = @stat;
59   my @out = grep { $_ < $wlo || $_ > $whi } @data;
60   push @X, [$impl, \@stat, \@out];
61 }
62
63 print  "\\begin{axis}\n";
64 printf "    [ytick = {%s},\n", join(", ", 1 .. @X);
65 print  "     yticklabels =\n";
66 for (my $i = 0; $i < @X; $i++) {
67   my $x = $X[$i];
68   printf "       %s{%s}%s\n",
69     $i ? " " : "{",
70     "\\textsf{$x->[0]}",
71     $i == @X - 1 ? "}]" : ",";
72 }
73 for my $x (@X) {
74   print  "  \\addplot+\n";
75   print  "      [boxplot prepared =\n";
76   my ($impl, $stat, $out) = $x->@*;
77   STAT: for (my $j = 0; $j < @STAT; $j++) {
78     next STAT unless defined $stat->[$j];
79     printf "         %s%s = %.3f%s\n",
80       $j ? " " : "{",
81       $STAT[$j], $stat->[$j],
82       $j == @STAT - 1 ? "}]" : ",";
83   }
84   printf "    coordinates {%s};\n",
85     join(" ", map { sprintf "(0, %.3f)", $_ } $out->@*);
86 }
87 print "\\end{axis}\n";