Skip to content

PerryTS/demo

Repository files navigation

Perry Benchmark Demo

A comprehensive benchmark application that runs on Node.js, Bun, and Perry (native TypeScript compiler) to compare real-time performance.

Live at: https://demo.perryts.com

Quick Start

# Install dependencies
npm install

# Run with Node.js (port 3001)
npm run dev:node

# Run with Bun (port 3002)
npm run dev:bun

# Build and run with Perry (port 3003)
./scripts/build-perry.sh
./scripts/run-perry.sh

Architecture

         Frontend (Static HTML/JS)
              │
    ┌─────────┼─────────┐
    │         │         │
 Node.js   Bun.js    Perry
  :3001    :3002     :3003
    │         │         │
    └─────────┼─────────┘
              │
           MySQL

Benchmarks

CPU Benchmarks

  • fibonacci - Recursive fib(40) - tests raw CPU computation
  • prime-sieve - Sieve of Eratosthenes (primes < 1M)
  • sha256 - SHA256 hashing of 1KB string (pure JS)
  • json-parse - JSON parse/stringify round-trip
  • bigint-ops - BigInt arithmetic (factorial, power, GCD)

Memory Benchmarks

  • array-ops - Create 100K elements, map/filter/reduce
  • object-create - 100K object allocations with nested properties
  • string-ops - String concatenation, indexOf, split/join

Database Benchmarks

  • mysql-query - Simple SELECT 1+1 latency
  • mysql-pool - Connection pool getConnection/release cycle
  • mysql-prepared - Parameterized query with prepared statements

HTTP Benchmarks

  • fetch-single - Single HTTP request latency
  • fetch-concurrent - 10 parallel HTTP requests

API Endpoints

GET  /api/health               - Health check with MySQL status
GET  /api/ping                 - Simple ping for benchmarks
GET  /api/benchmarks           - List all benchmarks
POST /api/benchmarks/run       - Run single benchmark
POST /api/benchmarks/run-category - Run benchmarks by category
GET  /api/benchmarks/run-all   - Run all benchmarks

Project Structure

perry-demo/
├── src/
│   ├── server.ts              # Fastify HTTP server
│   ├── config.ts              # Runtime detection & config
│   ├── benchmarks/
│   │   ├── types.ts           # BenchmarkResult interfaces
│   │   ├── runner.ts          # Benchmark execution engine
│   │   ├── cpu/               # CPU benchmarks
│   │   ├── memory/            # Memory benchmarks
│   │   ├── database/          # MySQL benchmarks
│   │   └── http/              # HTTP benchmarks
│   └── routes/
│       ├── health.ts
│       └── benchmarks.ts
├── frontend/                  # Static HTML/CSS/JS
├── deploy/                    # Nginx & systemd configs
└── scripts/                   # Build & run scripts

Deployment

Prerequisites

Server Setup

# Copy to server
rsync -avz --exclude node_modules . root@webserver.skeloo.net:/opt/perry-demo/

# Install Node.js dependencies
cd /opt/perry-demo && npm install

# Install systemd services
cp deploy/systemd/*.service /etc/systemd/system/
systemctl daemon-reload

# Start services
systemctl enable --now perry-demo-node perry-demo-bun perry-demo-perry

# Configure Nginx
cp deploy/nginx.conf /etc/nginx/sites-available/perry-demo
ln -s /etc/nginx/sites-available/perry-demo /etc/nginx/sites-enabled/
nginx -t && systemctl reload nginx

Environment Variables

Variable Default Description
PORT 3000 Server port
MYSQL_HOST localhost MySQL host
MYSQL_PORT 3306 MySQL port
MYSQL_USER root MySQL user
MYSQL_PASSWORD MySQL password
MYSQL_DATABASE perry_demo MySQL database
PERRY_RUNTIME Set to "1" for Perry runtime

License

MIT

About

Perry demo application — benchmark dashboard comparing Perry vs Node.js

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors