diff --git a/MIPS-Benchmark/MIPSBenchmark.py b/MIPS-Benchmark/MIPSBenchmark.py index f18db79..38789a2 100644 --- a/MIPS-Benchmark/MIPSBenchmark.py +++ b/MIPS-Benchmark/MIPSBenchmark.py @@ -1,4 +1,3 @@ -import numpy as np from time import time class MIPSBenchmark: @@ -12,19 +11,20 @@ class MIPSBenchmark: def ips_operation(self): # Run basic 7 ALU operations - _ = np.random.randint(10) + np.random.randint(10) - _ = np.random.randint(10) - np.random.randint(10) - _ = np.random.randint(10) * np.random.randint(10) - _ = np.random.randint(10) // (np.random.randint(10) + 1) # Prevent Division by Zero - _ = np.random.choice([True, False]) & np.random.choice([True, False]) - _ = np.random.choice([True, False]) | np.random.choice([True, False]) - _ = np.random.choice([True, False]) ^ np.random.choice([True, False]) + _ = 5 + 5 + _ = 5 - 5 + _ = 5 * 5 + _ = 5 // 5 + _ = True & True + _ = True | False + _ = False ^ False def calculate(self): self.elapsed_time = self.end_time - self.start_time self.total_instructions = self.iters*7 - self.mips = (self.total_instructions / self.elapsed_time) / 1000000 - print(f"=> Executed {self.total_instructions} within {self.elapsed_time}\n=> Result : {self.mips:.2f} MIPS") + self.mips = (self.total_instructions / self.elapsed_time) + print(f"=> Executed {self.total_instructions} within {self.elapsed_time:.2f}") + print(f"=> Result : {self.mips:.2f} IPS / {self.mips/1e6:.2f} MIPS") def run(self): print("# MIPS CPU Benchmark #") diff --git a/README.md b/README.md index 6b7c4f6..93c6205 100644 --- a/README.md +++ b/README.md @@ -7,5 +7,5 @@ This repository contains useful programs written in **Python 3.9**. Each folder * **Pickle Compress Program** : compress variable dumps using **gzip**, **bzip2**, **lzma**, or **no compression at all** * **FastAPI Simple Example** : contains API standard operations (Normal Request, GET Request, HTML Request) * **Matrix-based Bencmark** : contains a class to recreate Linpack (Matrix-based) Floating-point Per Second (FLOPS) Benchmark. Based on **numpy** or **scipy** libs -* **MIPS-Benchmark** : contains a script to benchmark your CPU's Intrusion Execution Speed (Million Instructions Per Second). The result might be lower but consistent on numerous runs. +* **MIPS-Benchmark** : contains a script to benchmark your CPU's Execution Speed (Million Instructions Per Second). The result is often consistent * *adding more soon*