Initial commit: Pi calculation benchmark with 34 languages
- Added implementations for: bash, brainfuck, c, cpp, crystal, csharp, d, dart, elixir, erlang, fortran, go, haskell, java, javascript, julia, kotlin, objective-c, scala, typescript, lua, nim, odin, perl, php, python, r, ruby, rust, swift, zig, assembly, vimscript, wolfram - All implementations use Machin's formula: π/4 = 4*arctan(1/5) - arctan(1/239) - Build system with ./build.sh, test system with ./test.sh - Performance testing with ./run_all.sh - Comprehensive README.md explaining performance differences - Test framework verifies correctness against known π values
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Build script for all pi calculation programs
|
||||
# This script calls build.sh for each language
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
cd "$SCRIPT_DIR"
|
||||
|
||||
echo "=== Building all pi calculation programs ==="
|
||||
echo ""
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Track success/failure
|
||||
BUILD_SUCCESS=0
|
||||
BUILD_FAILED=0
|
||||
|
||||
# Function to print success message
|
||||
print_success() {
|
||||
echo -e "${GREEN}✓${NC} $1 built successfully"
|
||||
BUILD_SUCCESS=$((BUILD_SUCCESS + 1))
|
||||
}
|
||||
|
||||
# Function to print error message
|
||||
print_error() {
|
||||
echo -e "${RED}✗${NC} $1 build failed"
|
||||
BUILD_FAILED=$((BUILD_FAILED + 1))
|
||||
}
|
||||
|
||||
# Function to print warning message
|
||||
print_warning() {
|
||||
echo -e "${YELLOW}⚠${NC} $1"
|
||||
}
|
||||
|
||||
# List of all languages
|
||||
LANGUAGES="bash brainfuck c cpp crystal csharp d dart elixir erlang fortran go haskell java javascript julia kotlin objective-c scala typescript lua nim odin perl php python r ruby rust swift zig assembly wolfram vimscript"
|
||||
|
||||
# Build each language
|
||||
for lang in $LANGUAGES; do
|
||||
echo "=== $lang ==="
|
||||
if [ -f "$lang/cmd/build.sh" ]; then
|
||||
cd "$lang"
|
||||
if cmd/build.sh 2>&1; then
|
||||
print_success "$lang"
|
||||
else
|
||||
print_error "$lang"
|
||||
fi
|
||||
cd "$SCRIPT_DIR"
|
||||
else
|
||||
print_error "$lang/cmd/build.sh not found"
|
||||
fi
|
||||
echo ""
|
||||
done
|
||||
|
||||
echo "=== Build Summary ==="
|
||||
echo -e "Successful: ${GREEN}$BUILD_SUCCESS${NC}"
|
||||
echo -e "Failed: ${RED}$BUILD_FAILED${NC}"
|
||||
|
||||
if [ $BUILD_FAILED -eq 0 ]; then
|
||||
echo -e "${GREEN}✓ All builds completed successfully!${NC}"
|
||||
exit 0
|
||||
else
|
||||
echo -e "${RED}✗ Some builds failed${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# ============================================
|
||||
# Bash (no compilation needed)
|
||||
# ============================================
|
||||
Reference in New Issue
Block a user