1#!/bin/bash 2# 3# Demo of RAPPOR. Automating Python and R scripts. See README. 4# 5# Usage: 6# ./demo.sh [function name] 7# 8# End to end demo of rappor. Notable functions include: 9# quick-python: Runs a demo using the python client 10# quick-cpp: Runs a demo using the c++ client 11# If no function is specified the above two will be run consecutivly. 12# 13# This takes a minute or so. It runs a subset of tests from regtest.sh and 14# writes an HTML summary. 15 16set -o nounset 17set -o pipefail 18set -o errexit 19 20. util.sh 21 22readonly THIS_DIR=$(dirname $0) 23readonly REPO_ROOT=$THIS_DIR 24readonly CLIENT_DIR=$REPO_ROOT/client/python 25 26# All the Python tools need this 27export PYTHONPATH=$CLIENT_DIR 28 29# 30# Semi-automated demos 31# 32 33# Run rappor-sim through the Python profiler. 34rappor-sim-profile() { 35 local dist=$1 36 shift 37 38 # For now, just dump it to a text file. Sort by cumulative time. 39 time python -m cProfile -s cumulative \ 40 tests/rappor_sim.py \ 41 -i _tmp/$dist.csv \ 42 "$@" \ 43 | tee _tmp/profile.txt 44} 45 46quick-python() { 47 ./regtest.sh run-seq '^demo3' python 48} 49 50quick-cpp() { 51 # For now we build it first. Don't want to build it in parallel. 52 ./build.sh cpp-client 53 54 ./regtest.sh run-seq '^demo3' cpp 55} 56 57quick() { 58 quick-python 59 quick-cpp 60} 61 62# TODO: Port these old bad cases to regtest_spec.py. 63 64# Running the demo of the exponential distribution with 10000 reports (x7, 65# which is 70000 values). 66# 67# - There are 50 real values, but we add 1000 more candidates, to get 1050 candidates. 68# - And then we remove the two most common strings, v1 and v2. 69# - With the current analysis, we are getting sum(proportion) = 1.1 to 1.7 70 71# TODO: Make this sharper by including only one real value? 72 73bad-case() { 74 local num_additional=${1:-1000} 75 run-dist exp 10000 $num_additional 'v1|v2' 76} 77 78# Force it to be less than 1 79pcls-test() { 80 USE_PCLS=1 bad-case 81} 82 83# Only add 10 more candidates. Then we properly get the 0.48 proportion. 84ok-case() { 85 run-dist exp 10000 10 'v1|v2' 86} 87 88if test $# -eq 0 ; then 89 quick 90else 91 "$@" 92fi 93