source "$EXP_ROOT/experiments/memcached.shared.sh"

pre_start() {
    load_config

    while [[ $# -gt 0 ]]; do
        case $1 in
            -t)
                [ -z "$2" ] && echo "# of threads must not be empty" && exit 1
                THREADS="$2"
                shift
                shift
                ;;
            *)
                break
                ;;
        esac
    done

    EXPERIMENT_NAME_EXT="t$THREADS.c$CONNS"

    cleanup_mutilate    
}

run_exp() {
    start_memcached
    start_mutilate
    warmup

    QPS_START=$((QPS_START_PER_THREAD * THREADS))
    QPS_END=$((QPS_END_PER_THREAD * THREADS))
    QPS_STEP=$((QPS_STEP_PER_THREAD * THREADS))

    for QPS in $(seq $QPS_START $QPS_STEP $QPS_END); do
        export QPS
        run_mutilate $QPS
    done    

    cleanup_mutilate
    cleanup_memcached
}

post_start() {
    cleanup_memcached
    cleanup_mutilate
}
