{"id":26027071,"url":"https://github.com/tqt97/dsa_benchmark_with_php","last_synced_at":"2026-06-09T14:31:23.232Z","repository":{"id":277817962,"uuid":"933575730","full_name":"tqt97/dsa_benchmark_with_php","owner":"tqt97","description":"Lean Data Structure Algorithms using PHP","archived":false,"fork":false,"pushed_at":"2025-02-17T12:59:42.000Z","size":17,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-06T15:41:13.616Z","etag":null,"topics":["algorithms","benchmark","complexity","data-structures","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tqt97.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-16T09:56:00.000Z","updated_at":"2025-02-17T12:59:45.000Z","dependencies_parsed_at":"2025-02-16T11:20:18.754Z","dependency_job_id":null,"html_url":"https://github.com/tqt97/dsa_benchmark_with_php","commit_stats":null,"previous_names":["tqt97/dsa_benchmark_with_php"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tqt97/dsa_benchmark_with_php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tqt97%2Fdsa_benchmark_with_php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tqt97%2Fdsa_benchmark_with_php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tqt97%2Fdsa_benchmark_with_php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tqt97%2Fdsa_benchmark_with_php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tqt97","download_url":"https://codeload.github.com/tqt97/dsa_benchmark_with_php/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tqt97%2Fdsa_benchmark_with_php/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34112225,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-09T02:00:06.510Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithms","benchmark","complexity","data-structures","php"],"created_at":"2025-03-06T15:34:14.736Z","updated_at":"2026-06-09T14:31:23.211Z","avatar_url":"https://github.com/tqt97.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 📚 Lean Data Structure Algorithms using PHP\n\n----\n\n## 🚀 Overview\nThis project is designed to **learn and benchmark algorithms using PHP**. It focuses on fundamental **data structures, algorithms, and complexity analysis**. The benchmarking system allows performance comparisons of different implementations.\n\n## 🔨 Project Status\n🚧 This project is currently under development. Features and benchmarks may change as improvements are made. Contributions and feedback are welcome!\n\n## 👨‍💻 Author\n[![GitHub](https://img.shields.io/badge/GitHub-TQT97-blue?logo=github\u0026style=for-the-badge)](https://github.com/tqt97)\n\n📧 Contact: quoctuanit2018@gmail.com\n\n## 🛠 Features\n- ✅ **Benchmarking Engine**: Compare multiple algorithm implementations.\n- 📊 **Execution Time Analysis**: Evaluate the efficiency of each function.\n- 💾 **Memory Usage Tracking**: Identify the most optimized approach.\n- 🎨 **Formatted Output**: Clean and structured result presentation.\n- 🔬 **Unit Testing**: Ensure the accuracy of benchmark results.\n\n## 📜 List of Algorithms\n\u003e 📌 Click the link below to view all implemented algorithms:\n\n[📖 **View All Algorithms**](algorithms.md) *(updating...)*\n\n### 🔢 Categories:\n| Algorithm Type  | Examples |\n|----------------|----------|\n| 🏁 **Sorting** | Bubble Sort, Quick Sort, Merge Sort |\n| 🔍 **Searching** | Linear Search, Binary Search |\n| 🔗 **Graph Algorithms** | BFS, DFS, Dijkstra’s Algorithm |\n| 🧠 **Dynamic Programming** | Fibonacci, Knapsack Problem |\n| 💡 **Greedy Algorithms** | Huffman Coding, Kruskal’s Algorithm |\n\n📂 **Full List:** See [`algorithms.md`](algorithms.md)*(updating...)*\n\n---\n\n## 📖 What are Data Structure and Algorithms?\n\n### **Data Structure**\nA **Data Structure (DS)** is a way of organizing and storing data efficiently to perform operations like searching, sorting, and modifying data effectively. Common types of data structures include:\n\n- **Arrays** 📊 – Fixed-size lists of elements stored in contiguous memory.\n- **Linked Lists** 🔗 – Dynamic lists where elements (nodes) are linked together.\n- **Stacks \u0026 Queues** 📥📤 – LIFO (Last In, First Out) and FIFO (First In, First Out) structures.\n- **Trees** 🌳 – Hierarchical structures used in databases, search operations (e.g., Binary Search Trees).\n- **Graphs** 🕸 – A set of nodes connected by edges, useful for networking and social connections.\n- **Hash Tables** 🔑 – Key-value storage used for quick lookups (e.g., associative arrays, maps).\n\n### **Algorithms**\nAn **Algorithm** is a step-by-step procedure to solve a problem efficiently. Algorithms work alongside data structures to process data effectively. Some common algorithms include:\n\n- **Sorting Algorithms** 📌 (Bubble Sort, Quick Sort, Merge Sort)\n- **Searching Algorithms** 🔍 (Binary Search, Linear Search)\n- **Graph Algorithms** 🔗 (Dijkstra's Algorithm, BFS, DFS)\n- **Divide and Conquer** 🪓 (Merge Sort, Quick Sort)\n- **Dynamic Programming** 🎭 (Fibonacci, Knapsack Problem)\n- **Greedy Algorithms** 💰 (Huffman Coding, Prim’s Algorithm)\n\n---\n\n## 🛠 **Time Complexity \u0026 Space Complexity**\n### **Time Complexity** ⏳\nTime complexity measures how the runtime of an algorithm grows as the input size increases. It is represented using **Big-O Notation**:\n\n| Complexity  | Notation  | Example Algorithms |\n|-------------|----------|--------------------|\n| Constant    | O(1)     | Hash Table Lookup  |\n| Logarithmic | O(log n) | Binary Search      |\n| Linear      | O(n)     | Linear Search      |\n| Quadratic   | O(n²)    | Bubble Sort        |\n| Exponential | O(2ⁿ)    | Recursive Fibonacci|\n\n### **Space Complexity** 💾\nSpace complexity measures the amount of memory required by an algorithm as the input size grows. It includes:\n\n1. **Auxiliary Space** – Extra space required beyond input data.\n2. **Input Space** – Memory occupied by input data.\n\n| Complexity  | Notation  | Example |\n|-------------|----------|---------|\n| O(1)        | Constant | Swapping two variables |\n| O(n)        | Linear   | Storing results in an array |\n| O(n²)       | Quadratic | Creating an adjacency matrix for graphs |\n\n💡 **Example: Space Complexity in Recursion**\n```php\nfunction factorial($n) {\n    if ($n == 0) return 1;\n    return $n * factorial($n - 1);\n}\n```\n- This function has **O(n) space complexity** due to recursive stack calls.\n\n---\n\n## 📂 Project Structure\n```\n📦 project/                   \n│── 📂 benchmarks/                     # 💨 Algorithm benchmarks\n│   ├── 📂 array/                      # 🔢 Contains array algorithms\n│   ├── 📂 graph/                      # 🕸 Contains graph algorithms\n│   ├── 📂 linked_list/                # 🔗 Contains linked list algorithms\n│   ├── 📂 queue/                      # 📤 Contains queue algorithms\n│   ├── 📂 string/                     # 🔡 Contains string algorithms\n│   ├── 📂 stack/                      # 📥 Contains stack algorithms\n│   ├── 📂 tree/                       # 🌳 Contains tree algorithms\n│\n│── 📂 results/                        # 📊 Benchmark logs (auto-generated)\n│   ├── 📂 array/                      # 📝 Results of array benchmarks\n│   ├── 📂 string/                     # 📝 Results of string benchmarks\n│\n│── 📂 logs/                           # 📁 Store runtime logs\n│\n│── 📂 src/                            # 🔧 Core logic (business logic)\n│   ├── 📂 bootstrap/                  # 🚀 Bootstrap \u0026 initialization\n│   │   ├── 📄 autoload.php            # 🔄 Load all functions and config\n│   │── 📂 commands/                   # 🖥️ CLI command handlers\n│   │   ├── 📄 benchmark.php           # ⚡ Handle benchmarking\n│   │   ├── 📄 clean.php               # 🧹 Handle cleaning results\n│   │   ├── 📄 list.php                # 📜 Generate list of algorithms\n│   ├── 📂 functions/                  # 🏗️ Core utility functions\n│   │   ├── 📄 benchmark.php           # ⏳ Benchmarking logic\n│   │   ├── 📄 deleteFile.php          # 🗑️ File deletion utilities\n│   │   ├── 📄 env.php                 # 🌎 Load environment variables\n│   │   ├── 📄 format.php              # 🎨 Format output, print, and timing\n│   │   ├── 📄 help.php                # ℹ️ Show CLI help text\n│   │   ├── 📄 logger.php              # 📝 Write output to file\n│   │   ├── 📄 utils.php               # 🛠️ General helper functions\n│\n│── 📂 tests/                          # ✅ Unit tests\n│\n│── 📄 .env.example                    # 🔧 Example env file\n│── 📄 .gitignore                      # 🚫 Ignore unnecessary files\n│── 📄 config.php                      # ⚙️ Configuration settings\n│── 📄 index.php                       # 🚀 Main entry point\n│── 📖 README.md                       # 📚 Documentation\n```\n\n### 📌 Key Files \u0026 Directories\n- [**benchmarks/**](./benchmarks) - Contains different algorithm benchmarks.\n- [**src/**](./src) - Core logic including benchmark execution and formatting.\n- [**results/**](./results) - Stores benchmarking logs.\n- [**tests/**](./tests) - Unit tests to validate accuracy.\n- [**index.php**](./index.php) - Main script to execute benchmarks.\n\n## 🚀 Getting Started\n\n#### 1️⃣ Clone the Repository\n```bash\ngit clone https://github.com/tqt97/benchmark-project.git\ncd benchmark-project\n```\n\n#### 2️⃣ 🚀 Usage\n\n\u003e📢 **Guide:** How to implement benchmark. [how_to_implement_benchmark.md](./how_to_implement_benchmark.md)\n\n##### **Run a benchmark**\n```sh\nphp index.php benchmark benchmarks/array/1_sum.php\n```\n- 🏁 This will execute the benchmark script `benchmarks/array/1_sum.php`.\n- If no action (`benchmark`, `list`, `clean`) is specified, it defaults to **benchmark**.\n\n##### **Generate algorithm list**\n```sh\nphp index.php list\n```\n- 📜 This will create a **`algorithms.md`** file listing all available benchmark scripts with clickable links.\n\n##### **Clean the results directory**\n```sh\nphp index.php clean\n```\n- 🧹 This will delete all files inside the **results** directory after confirmation.\n\n##### **Auto-detect benchmark mode**\n```sh\nphp index.php benchmarks/array/1_sum.php\n```\n- 🤖 Since no action (`benchmark`, `list`, `clean`) is provided, the system assumes **benchmark mode** automatically.\n\n---\n\n## 🤝 Contributing\n\nWe appreciate contributions to improve this project! If you’d like to contribute, follow these steps:\n\n### 1️⃣ Fork the repository\nClick the **Fork** button on GitHub to create your own copy of the project.\n\n### 2️⃣ Clone the project\n```sh\ngit clone https://github.com/your-username/benchmark-project.git\ncd benchmark-project\n```\n\n### 3️⃣ Create a new branch\n```sh\ngit checkout -b feature/new-feature\n```\n\n### 4️⃣ Make changes and commit\n- Improve benchmarks, optimize algorithms, or add new features.\n- Follow the existing code structure for consistency.\n- **Add a new algorithm** inside the `benchmarks/` directory under the appropriate data structure folder.\n   ```\n   benchmarks/\n   ├── array/\n   │   ├── 1.sum.php  # Example of array algorithm\n   ├── stack/\n   │   ├── stack_push.php  # Example of stack algorithm\n   ```\n```sh\ngit commit -m \"✨ Added new sorting algorithm\"\n```\n\n### 5️⃣ Push and create a Pull Request\n```sh\ngit push origin feature/new-feature\n```\n- Open a **Pull Request (PR)** from your fork to the main repository.\n- Add a description of your changes.\n\n📢 **Note:** All new algorithms must be added inside the `benchmarks/` directory!\n\n---\n\n## 📜 Contribution Guidelines\n✔ Keep code **clean** and **well-documented**.  \n✔ Follow **PSR-12** PHP coding standards.  \n✔ Run tests before submitting PRs.  \n\n\u003e 💡 **Have a suggestion or found a bug?** Open an **Issue** on GitHub! 🚀\n\nEnjoy coding! 🚀\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftqt97%2Fdsa_benchmark_with_php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftqt97%2Fdsa_benchmark_with_php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftqt97%2Fdsa_benchmark_with_php/lists"}