Update AGENT.md with English translation and project status
- Translated beginning of AGENT.md to English - Added project status section with current languages (34 total) - Added test environment specifications (Apple A18 Pro, 8GB RAM) - Added performance results summary - Added binary size information - Partial translation in progress
This commit is contained in:
@@ -1,53 +1,72 @@
|
||||
# Agent: Lägg till nytt programmeringsspråk
|
||||
# Agent: Add New Programming Language to Pi Calculation Benchmark
|
||||
|
||||
## Översikt
|
||||
## Overview
|
||||
|
||||
För att lägga till ett nytt programmeringsspråk till pi-beräkningsprojektet, följ dessa steg exakt.
|
||||
This project benchmarks 34 programming languages calculating π (pi) using Machin's formula. Each language implements the same algorithm for fair performance comparison. This document provides complete instructions for adding new languages.
|
||||
|
||||
## VIKTIGT: Undantag för Bash
|
||||
## Project Status
|
||||
|
||||
**Bash är ett UNDANTAG** och används endast som referenskod. Bash använder `bc -l` med formeln `4*a(1)` för att beräkna pi, vilket är en annan algoritm än Machins formel. Bash inkluderas inte i prestandajämförelser och kraven nedan gäller inte för Bash.
|
||||
**Current Languages (34 total):**
|
||||
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
|
||||
|
||||
Alla andra språk (Go, Rust, Python, C, C++, Haskell, Erlang, etc.) MÅSTE följa reglerna nedan exakt.
|
||||
**Test Environment:**
|
||||
- **Hardware:** MacBook Neo, Apple A18 Pro (6 cores: 2 performance + 4 efficiency), 8 GB RAM
|
||||
- **OS:** macOS (Darwin)
|
||||
- **Test Date:** 2026-04-23
|
||||
|
||||
## Steg 1: Skapa katalogstruktur
|
||||
**Performance Results (10000 decimals):**
|
||||
- **Fastest:** C (24 ms), Objective-C (25 ms), Assembly (27 ms)
|
||||
- **Slowest:** TypeScript (10334 ms), JavaScript (10065 ms), Swift (6735 ms)
|
||||
|
||||
Skapa en ny katalog i projektroten med språkets namn (gemener) med följande struktur:
|
||||
**Binary Sizes:**
|
||||
- **Smallest:** 103B (wrapper scripts for interpreted languages)
|
||||
- **Largest:** 13M (Haskell native binary)
|
||||
- **Typical compiled:** 34K-2.5M
|
||||
|
||||
## IMPORTANT: Bash Exception
|
||||
|
||||
**Bash is an EXCEPTION** and serves only as reference code. Bash uses `bc -l` with formula `4*a(1)` to calculate pi, which is a different algorithm than Machin's formula. Bash is not included in performance comparisons and the requirements below do not apply to Bash.
|
||||
|
||||
All other languages (Go, Rust, Python, C, C++, Haskell, Erlang, etc.) MUST follow the rules below exactly.
|
||||
|
||||
## Step 1: Create Directory Structure
|
||||
|
||||
Create a new directory in the project root with the language name (lowercase) with the following structure:
|
||||
|
||||
```
|
||||
/Users/einand/Code/test/<språk>/
|
||||
├── bin/ # Kompilerade binärer eller wrapper-scripts
|
||||
│ └── print_hej # Den körbara filen
|
||||
├── src/ # Källkod
|
||||
│ └── print_hej.<extension> # Källkodsfilen
|
||||
└── cmd/ # Kommandon och scripts
|
||||
├── build.sh # Byggscript
|
||||
/Users/einand/Code/test/<language>/
|
||||
├── bin/ # Compiled binaries or wrapper scripts
|
||||
│ └── print_hej # The executable file
|
||||
├── src/ # Source code
|
||||
│ └── print_hej.<extension> # Source file
|
||||
└── cmd/ # Commands and scripts
|
||||
├── build.sh # Build script
|
||||
└── test.sh # Test script
|
||||
```
|
||||
|
||||
Exempel:
|
||||
Examples:
|
||||
- `python/src/print_hej.py`
|
||||
- `python/bin/print_hej` (wrapper script)
|
||||
- `python/cmd/build.sh`
|
||||
- `python/cmd/test.sh`
|
||||
|
||||
- `rust/src/print_hej.rs`
|
||||
- `rust/bin/print_hej` (kompilerad binär)
|
||||
- `rust/bin/print_hej` (compiled binary)
|
||||
- `rust/cmd/build.sh`
|
||||
- `rust/cmd/test.sh`
|
||||
|
||||
## Steg 2: Skapa programfil
|
||||
## Step 2: Create Program File
|
||||
|
||||
Skapa en fil som heter `print_hej.<extension>` i `src/`-katalogen.
|
||||
Create a file named `print_hej.<extension>` in the `src/` directory.
|
||||
|
||||
### Obligatoriska krav för programmet:
|
||||
### Mandatory Program Requirements:
|
||||
|
||||
1. **Ta emot argument**: Programmet ska acceptera ett kommandoradsargument med antal decimaler att beräkna.
|
||||
- Om inget argument ges, använd default 100 decimaler
|
||||
- Om ogiltigt argument, använd default 100 decimaler
|
||||
1. **Accept argument**: The program must accept one command-line argument specifying the number of decimal places to calculate.
|
||||
- If no argument provided, use default 100 decimals
|
||||
- If invalid argument, use default 100 decimals
|
||||
|
||||
2. **Beräkna pi korrekt**: Använd Machins formel med Taylor-serien för arctan.
|
||||
- Machins formel: `pi/4 = 4*arctan(1/5) - arctan(1/239)`
|
||||
2. **Calculate pi correctly**: Use Machin's formula with Taylor series for arctan.
|
||||
- Machin's formula: `pi/4 = 4*arctan(1/5) - arctan(1/239)`
|
||||
- Taylor-serien för arctan: `arctan(1/x) = 1/x - 1/(3*x^3) + 1/(5*x^5) - ...`
|
||||
|
||||
## Steg 2.5: OBLIGATORISK ALGORITM
|
||||
|
||||
Reference in New Issue
Block a user