Smart timer whith limits, code comparison and analysis
Project description
⏱️ WiseTimer - Smart Timer from 11-Year-Old Developer
Smart timer with limits, benchmarking, code comparison, and performance analysis.
✨ Features
✅All-in-one solution - multiple tools in one package
✅No dependencies - uses only Python standard libraries
✅For everyone - suitable for both beginners and advanced developers
✅Multiple usage methods - methods, context managers, decorators, limits
✅Beautiful output with emojis 😊
✅Smart advice through AST analysis
✅Very simple API - easy to learn and use
✅Clear error messages - human-readable with solutions
📦 Installation
'''bash pip install wisetimer'''
🚀 Quick Start
'''python
from wisetimer import Timer
from wisetimer import Analyze
from wisetimer import Benchmark
import time
timer = Timer()
a = Analyze()
Basic timer
print(timer.done()) print("Hello wisetimer!") print(timer.done())
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 = code = '''a = "aaaaaaaaa" b = "bbbbbbbbbb" x = 1 z = [] for i in range(10): y = 0 z = z.append(i) y = 0 + 1 a += "b" if x == 3: print(x+x+x+x) if x == 3: print("") if x == 2: print("1") elif x == 2: print(x+x+x) def x(): import time x() class X(): def init(self): for z in range(1): self.y = 0 z = 5 while z > 3: z -= 1 if x == 2: print(x+x+x) elif x == 5: print("WOW!") elif x == 5: print("WOW!")''' analyzer = Analyze() analyzer.code(code)'''
📃 Detailed Documentation
Timer Class
Timer is the base class containing all timer functions.
Import
'''python from wisetimer imoprt Timer'''
Timer Methods
Timer.done() - automatically starts/stops timer
'''python timer = Timer() print(timer.done()) # Start print("Your code") # Your code here print(timer.done()) # Stop and get time'''
Timer().start()/Timer().done("start") - starts the timer
Timer().stop()/Timer.finish()/Timer.end()/Timer().done("stop/end/fiish") - stops the timer
Timer().lap()/Timer().done("lap") - creates a checkpoint without stopping
Timer().status()/Timer().done("status") - returns timer status
Timer().reset()/Timer().done("reset") - stops and resets the timer
'''python timer = Timer() print(timer.start()) # ✅Timer started! x = 1234567890 print(timer.lap()) # 🚩Checkpoint at ... sec. print(x * 100) print(timer.done()) # ⏰Timer stopped... print(timer.reset()) # ✅Timer reset! print(timer.done()) # Start again print("Hi!") print(timer.status()) # ✔️Timer running... print(timer.end()) # ⏰Timer stopped...'''
Timer().limit(seconds) - sets execution time limit and starts counting
Timer().limitRevise() - checks if limit is exceeded
'''python timer = Timer() timer.limit(0.1) for x in range(5): time.sleep(0.001) timer.limitRevise()'''
@Timer.funcTimer - decorator for timing functions
'''python @Timer.funcTimer def example(): return "Hello!" result = example() print(result) #🕒Function 'example' executed in ... sec.'''
Context Manager - simple benchmark with with statement
'''python 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
Benchmark().reset() - clears benchmark data
'''python 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() - sets checkpoints for speed analysis (minimum 4 checkpoints required)
Analyze().getAdvice() - provides performance patterns based on checkpoints
'''python timer = Timer() timer.start() for x in range(10): print(x) Analyze().checkpoint() Analyze().getAdvice()'''
Analyze().code('''Your code''') - analyzes code for performance issues using AST and gives optimization advice
'''python code = '''
for i in range(1000): result = [] result.append(i * 2) ''' analyzer = Analyze() analyzer.code(code)'''
😮Error explanation
All errors are understandable toa personand contain an explanationand solution to it
📊Сравнение с аналогами
| Feature | wisetimer | time.time() | cProfile | timeit |
|---|---|---|---|---|
| Ease of use | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ | ⭐ | ⭐⭐ |
| Precision | nanoseconds | seconds | nanoseconds | nanoseconds |
| AST 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.0.0-py3-none-any.whl.
File metadata
- Download URL: wisetimer-1.0.0-py3-none-any.whl
- Upload date:
- Size: 7.7 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 |
cfbdca0bd8b89b5fa891bf54263066a7b5b9d2238d97f36d2fb0195a297ca76d
|
|
| MD5 |
8b9ac687ab8d1687e4a61199eef7b3cd
|
|
| BLAKE2b-256 |
ab3612b86af7f50e4e8218ce0c505e3bc9cfddda98fa58e4827a7142006f1df2
|