File size: 3,906 Bytes
d982819
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/bin/bash
# ─── HFT Orderbook Build & Deploy Script ────────────────────────────────────
set -e

PROJ_DIR="$(cd "$(dirname "$0")" && pwd)"
BUILD_DIR="$PROJ_DIR/build"

echo "════════════════════════════════════════"
echo " HFT Order Book Engine — Build System"
echo "════════════════════════════════════════"

# ── Prerequisites ──────────────────────────────────────────────────────────
check_tool() {
    if ! command -v "$1" &>/dev/null; then
        echo "[ERROR] $1 not found. Install with: sudo apt install $2"
        exit 1
    fi
}
check_tool cmake cmake
check_tool g++ g++

GCC_VER=$(g++ --version | head -1 | grep -oP '\d+\.\d+' | head -1)
echo "[INFO]  Compiler : g++ $GCC_VER"
echo "[INFO]  Cores    : $(nproc)"

# ── Build ──────────────────────────────────────────────────────────────────
echo ""
echo "[BUILD] Configuring..."
mkdir -p "$BUILD_DIR"
cd "$BUILD_DIR"
cmake "$PROJ_DIR" -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=20 2>&1 | tail -3

echo "[BUILD] Compiling with $(nproc) cores..."
make -j$(nproc) 2>&1

echo ""
echo "[BUILD] ✓ Build successful"
echo "  Binaries: $BUILD_DIR/benchmark"
echo "             $BUILD_DIR/run_tests"

# ── Tests ─────────────────────────────────────────────────────────────────
echo ""
echo "════════════════════════════════════════"
echo " Running Test Suite"
echo "════════════════════════════════════════"
"$BUILD_DIR/run_tests"
echo ""

# ── Quick benchmark ────────────────────────────────────────────────────────
if [[ "${1:-}" == "--quick" ]]; then
    echo "════════════════════════════════════════"
    echo " Quick Benchmark (1M orders)"
    echo "════════════════════════════════════════"
    "$BUILD_DIR/benchmark" --orders 1000000
fi

if [[ "${1:-}" == "--full" ]]; then
    echo "════════════════════════════════════════"
    echo " Full Benchmark (20M orders)"
    echo "════════════════════════════════════════"
    "$BUILD_DIR/benchmark" --orders 20000000
fi

if [[ "${1:-}" == "--json" ]]; then
    "$BUILD_DIR/benchmark" --orders 1000000 --json --quiet
fi

echo ""
echo "════════════════════════════════════════"
echo " Deployment"
echo "════════════════════════════════════════"
echo "[INFO]  Frontend : $PROJ_DIR/frontend/index.html"
echo "[INFO]  README   : $PROJ_DIR/README.md"
echo ""
echo "To deploy to Hugging Face Spaces:"
echo "  1. Create a new Space (SDK: Static)"
echo "  2. Upload frontend/index.html as index.html"
echo "  3. Upload README.md"
echo "  4. Push C++ sources to Space repo for reference"
echo ""
echo "✓ Done"