aboutsummaryrefslogtreecommitdiff
path: root/demo.sh
blob: 93da78d84e56f5fb9c49e1bf8a2840be82acb3d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/bash
#
# Demo of RAPPOR.  Automating Python and R scripts.  See README.
#
# Usage:
#   ./demo.sh [function name]
#
# End to end demo of rappor. Notable functions include:
#   quick-python: Runs a demo using the python client
#   quick-cpp: Runs a demo using the c++ client
# If no function is specified the above two will be run consecutivly. 
#
# This takes a minute or so.  It runs a subset of tests from regtest.sh and
# writes an HTML summary.

set -o nounset
set -o pipefail
set -o errexit

. util.sh

readonly THIS_DIR=$(dirname $0)
readonly REPO_ROOT=$THIS_DIR
readonly CLIENT_DIR=$REPO_ROOT/client/python

# All the Python tools need this
export PYTHONPATH=$CLIENT_DIR

#
# Semi-automated demos
#

# Run rappor-sim through the Python profiler.
rappor-sim-profile() {
  local dist=$1
  shift

  # For now, just dump it to a text file.  Sort by cumulative time.
  time python -m cProfile -s cumulative \
    tests/rappor_sim.py \
    -i _tmp/$dist.csv \
    "$@" \
    | tee _tmp/profile.txt
}

quick-python() {  
  ./regtest.sh run-seq '^demo3' python
}

quick-cpp() {
  # For now we build it first.  Don't want to build it in parallel.
  ./build.sh cpp-client

  ./regtest.sh run-seq '^demo3' cpp
}

quick() {
  quick-python
  quick-cpp
}

# TODO: Port these old bad cases to regtest_spec.py.

# Running the demo of the exponential distribution with 10000 reports (x7,
# which is 70000 values).
#
# - There are 50 real values, but we add 1000 more candidates, to get 1050 candidates.
# - And then we remove the two most common strings, v1 and v2.
# - With the current analysis, we are getting sum(proportion) = 1.1 to 1.7

# TODO: Make this sharper by including only one real value?

bad-case() {
  local num_additional=${1:-1000}
  run-dist exp 10000 $num_additional 'v1|v2'
}

# Force it to be less than 1
pcls-test() {
  USE_PCLS=1 bad-case
}

# Only add 10 more candidates.  Then we properly get the 0.48 proportion.
ok-case() {
  run-dist exp 10000 10 'v1|v2'
}

if test $# -eq 0 ; then
  quick
else
  "$@"
fi