Smart timer with limits, code comparison and analysis
Project description
⏱️ WiseTimer - Smart Timer from 11-Year-Old Developer
Smart timer with limits, benchmarking, code comparison, and performance AI analysis.
✨ Features
✅All-in-one solution - multiple tools in one package
✅For everyone - suitable for both beginners and advanced developers
✅Multiple usage methods - methods, context managers, decorators, limits
✅Beautiful output with emojis 😊
✅Very simple API - easy to learn and use
✅Clear error messages - human-readable with solutions
📦 Installation
pip install wisetimer
🚀 Quick Start
from wisetimer import Timer
from wisetimer import Analyze
from wisetimer import Benchmark
import time
timer = Timer()
a = Analyze()
# Basic timer
print(timer.start())
print("Hello wisetimer!")
print(timer.stop())
# Context manager for benchmarking
with Timer() as t:
x = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 0
# Decorator for function timing
@Timer.funcTimer
def example():
return "Hello world!"
result = example()
print(result)
# Benchmark comparison
with Benchmark("a"):
print("Hello wisetimer!")
with Benchmark("b"):
print("Hello wisetimer!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
Benchmark().compar()
Benchmark().reset()
with Benchmark("c"):
print("Hello wisetimer")
with Benchmark("d"):
print("Hello wisetimer!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
Benchmark().compar()
# Time limits
timer2 = Timer()
timer2.limit(0.1)# Set 0.1 second limit
for x in range(5):
time.sleep(0.001)
timer2.limitRevise()
print("✅Limit revise = OK")
# Code analysis
code = '''x = 0
for i in range(100):
x = (range(1000))'''
analyzer = Analyze()
analyzer.AiCode(code)
📃 Detailed Documentation
Timer Class
Timer is the base class containing all timer functions.
Import
from wisetimer import Timer
Timer Methods
Timer().start() - starts the timer
Timer().stop() - stops the timer
Timer().lap()- creates a checkpoint without stopping
Timer().status() - returns timer status
Timer().reset() - stops and resets the timer
timer = Timer()
print(timer.start()) # ✅Timer started!
x = 1234567890
print(timer.lap()) # 🚩Checkpoint at ... sec.
print(x \* 100)
print(timer.stop()) # ⏰Timer stopped...
print(timer.reset()) # ✅Timer reset!
print(timer.start()) # Start again
print("Hi!")
print(timer.status()) # ✔️Timer running...
print(timer.stop()) # ⏰Timer stopped...
Timer().limit(seconds) - sets execution time limit and starts counting
Timer().limitRevise() - checks if limit is exceeded
timer = Timer()
timer.limit(0.1)
for x in range(5):
time.sleep(0.001)
timer.limitRevise()
@Timer.funcTimer - decorator for timing functions
@Timer.funcTimer
def example():
return "Hello!"
result = example()
print(result) #🕒Function 'example' executed in ... sec.
Context Manager - simple benchmark with with statement
with Timer() as t:
x = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 0
Benchmark Class
Benchmark class for creating and comparing named benchmarks.
Benchmark Methods
Benchmark("name") - named benchmark (default name is "_")
Benchmark().compar() - compares benchmark execution times and ploting a graph
Benchmark().reset() - clears benchmark data
with Benchmark("a"):
print("Hello wisetimer!")
with Benchmark("b"):
print("Hello wisetimer!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
Benchmark().compar() # Shows fastest and slowest
Benchmark().reset() # ✅Benchmarks reset!
with Benchmark("c"):
print("Hello wisetimer")
with Benchmark("d"):
print("Hello wisetimer!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
Benchmark().compar() # Shows fastest and slowest
Analyze Class
Analyze class for code performance analysis and optimization advice.
Analyze Methods
Analyze().checkpoint("name") - sets checkpoints for speed analysis (minimum 4 checkpoints required)
Analyze().getAdvice() - provides performance patterns based on checkpoints
for x in range(10):
print(x)
Analyze().checkpoint(x)
Analyze().getAdvice()
Analyze().AiCode('''Your code''') - analysis code using Google Gemeni AI!(the key is securely stored in the operating system(using the keyring library))
Analyze().AstCode('''Your code''') - analysis code using AST
code = '''
for i in range(1000):
result = []
result.append(i \* 2)
'''
analyzer = Analyze()
analyzer.AiCode(code)
analyzer.AstCode(code)
😮Error explanation
All errors are understandable toa personand contain an explanationand solution to it
❓What's new?
🆕Improved documentation
🆕Simplified api
🆕Instead of ast analysis, Google Gamini 3 AI has been added(the key is securely stored in the operating system)
🆕Improved structure
🆕Added ASCII graphs
📊Comparison with analogues
| Feature | wisetimer | time.time() | cProfile | timeit |
|---|---|---|---|---|
| Ease of use | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ | ⭐ | ⭐⭐ |
| Precision | nanoseconds | seconds | nanoseconds | nanoseconds |
| AI analysis | ✅ | ❌ | ❌ | ❌ |
| Optimization advice | ✅ | ❌ | ❌ | ❌ |
| Clear error messages | ✅ | ❌ | ❌ | ❌ |
| Time limits | ✅ | ❌ | ❌ | ❌ |
👦🏻About the Developer
My name is Andrey Egupov, I'm 11 years old. I've been programming for several years. Started with Scratch, now I write in Python and JavaScript.
The idea for this library didn't come out of nowhere. I wanted to create something truly useful, spent a long time asking AI assistants what libraries Python was missing. But I eventually found a suitable one. The wisetimer library not only measures time like regular timer libraries do, but also gives optimization advice. It's very simple and suitable for everyone - both beginners and advanced developers due to its simple interface and system accuracy.
During development I learned a lot - from what optimization advice to give for code performance improvement, to benchmarking and decorators.
In the future I plan to develop my library: I'll add more unique advice, progress bars, and much more.
📄License
This project is distributed under the MIT license. For more details see the LICENSE file.
*Created by Andrey Egupov - 11-year-old developer 👦🏻
AI assistant helped with publication and development stages.
If you liked this project, please give it ⭐(a star) on GitHub*
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wisetimer-1.2.0-py3-none-any.whl.
File metadata
- Download URL: wisetimer-1.2.0-py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d6657935e6f07b83b64f153770f7d78d6d22da14035edce1b89293d75187d13
|
|
| MD5 |
d6cac743c0aa214deb05d6e55eb99f38
|
|
| BLAKE2b-256 |
24269f2de4fe88d0ffc3ef2ac5700232696a56f511b57c0c608257c91400bd37
|