Skip to content

Commit c63ea44

Browse files
committed
Fix: resolved issue sumanth-0#7 (description of fix)
1 parent f3db2ac commit c63ea44

File tree

2 files changed

+83
-0
lines changed

2 files changed

+83
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
"""
2+
Python Speed Test
3+
Measure how fast your computer executes loops or arithmetic operations
4+
"""
5+
6+
import time
7+
8+
def test_loop(n=10**6):
9+
start = time.time()
10+
total = 0
11+
for i in range(n):
12+
total += i
13+
end = time.time()
14+
print(f"Loop Test: Summed 0 to {n-1} in {end-start:.6f} seconds")
15+
16+
def test_arithmetic(n=10**6):
17+
start = time.time()
18+
result = 1.0
19+
for i in range(1, n):
20+
result *= 1.000001
21+
result /= 1.000001
22+
end = time.time()
23+
print(f"Arithmetic Test: Performed {n} multiplications/divisions in {end-start:.6f} seconds")
24+
25+
def main():
26+
print("\n⚡ Python Speed Test ⚡")
27+
while True:
28+
print("\nMenu:")
29+
print("1️⃣ Test Loop Speed")
30+
print("2️⃣ Test Arithmetic Speed")
31+
print("3️⃣ Exit")
32+
choice = input("Choose an option (1-3): ").strip()
33+
if choice == "1":
34+
test_loop()
35+
elif choice == "2":
36+
test_arithmetic()
37+
elif choice == "3":
38+
print("Goodbye! 🏃💨")
39+
break
40+
else:
41+
print("Invalid option. Try again!")
42+
43+
if __name__ == "__main__":
44+
main()

python_speed_test/readme.txt

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# ⚡ Python Speed Test
2+
3+
**Python Speed Test** is a simple script to measure how fast your computer executes loops and arithmetic operations.
4+
It’s interactive and easy to use, giving you a quick benchmark of your Python performance.
5+
6+
---
7+
8+
## Features
9+
10+
- 🏃 Test **loop speed** by summing numbers
11+
- 🔢 Test **arithmetic speed** with multiplications/divisions
12+
- 🖥️ Interactive menu to select tests
13+
- Simple, beginner-friendly Python script
14+
15+
---
16+
17+
## Getting Started
18+
19+
1. **Install Python 3**
20+
2. Save `python_speed_test.py` in a folder
21+
3. Run the script:
22+
```bash
23+
python python_speed_test.py
24+
25+
⚡ Python Speed Test ⚡
26+
27+
Menu:
28+
1️⃣ Test Loop Speed
29+
2️⃣ Test Arithmetic Speed
30+
3️⃣ Exit
31+
Choose an option (1-3): 1
32+
Loop Test: Summed 0 to 999999 in 0.127834 seconds
33+
34+
Menu:
35+
1️⃣ Test Loop Speed
36+
2️⃣ Test Arithmetic Speed
37+
3️⃣ Exit
38+
Choose an option (1-3): 2
39+
Arithmetic Test: Performed 1000000 multiplications/divisions in 0.352918 seconds

0 commit comments

Comments
 (0)