Skip to main content

A small timer utility that has all the helpful features you could ever want!

Project description

Active Development CI Test Status License: LGPL-2.1 PyPI Downloads coverage

chronix

chronix is every concept timer you've ever seen, rolled into one. It has all the helpful features you could ever want.

Compatibility

🟩 (Works perfectly); 🟨 (Untested); 🟧 (Some Issues); 🟥 (Unusable)

OS
Windows 🟩
MacOS 🟩
Linux (Ubuntu 22.04 LTS) 🟩

Features

  • Easy to use for beginners, but not lacking for experts
  • Efficient
  • Fully cross-platform
  • Regular updates and support
  • Comprehensive documentation

Installation

You can install chronix via pip:

pip install chronix --pre --upgrade

Or clone the repository and install manually:

git clone https://github.com/Adalfarus/chronix.git
cd chronix
python -m pip install .

If you have problems with the package please use py -m pip install chronix[cli,dev] --pre --upgrade --user

📦 Usage

Here are a few quick examples of how to use chronix.


⏱ Basic Timing (chronix)

Measure elapsed time with nanosecond resolution.


⏲ Use BasicTimer for simple measurements

from chronix import BasicTimer
import time

timer = BasicTimer(auto_start=True)
time.sleep(0.123)
timer.stop()

print(timer.get())          # timedelta
print(timer.get_readable()) # Human-readable

📏 Create precise deltas

from chronix import PreciseTimeDelta

delta = PreciseTimeDelta(seconds=1.5, microseconds=250)
print(str(delta))           # 0:00:01.500250
print(delta.to_readable())  # "1.500s"

⏱ Flexible Timing with FlexTimer

Advanced control for performance tracking, interval measurements, and benchmarking.


🧪 Measure CPU-only time (ignores sleep)

from chronix import CPUFTimer

with CPUFTimer():
    sum(i * i for i in range(100_000))

Ideal for benchmarking with minimal system interference.


🔄 Manual start/stop and waiting

from chronix import FlexTimer

t = FlexTimer(start_now=False)
t.start(start_at=1.2)
t.wait(0.8)
t.stop()

print(t.get().to_clock_string())  # e.g., 00:00:02.00

⏱ Record laps (interval checkpoints)

t = FlexTimer()
# ... task 1 ...
t.lap()
# ... task 2 ...
t.lap()

print(t.show_laps())  # List of lap durations

🪄 Time entire functions with a decorator

@FlexTimer().time()
def compute():
    return [x**2 for x in range(1_000_000)]

compute()  # Prints execution time

🕒 Schedule callbacks after a delay

def on_done():
    print("Finished!")

FlexTimer().after(2, on_done)

🧵 Run functions at intervals

def tick():
    print("Tick!")

FlexTimer().interval(1, count=5, callback=tick)

📈 Estimate time complexity of a function

def fn(n):
    return [i ** 2 for i in range(n)]

def gen_inputs():
    for i in range(1000, 50000, 1000):
        yield ((i,), {})

from chronix import FlexTimer
print(FlexTimer.complexity(fn, gen_inputs()))  # e.g., "O(N)"

chrono cli

Can currently run tests with chrono tests run tests/ -minimal and show a basic help using chrono help.

For more detailed usage and examples, check out our documentation.

Naming convention, dependencies and library information

PEP 8 -- Style Guide for Python Code

For modules I use 'lowercase', classes are 'CapitalizedWords' and functions and methods are 'lower_case_with_underscores'.

Contributing

We welcome contributions! Please see our contributing guidelines for more details on how you can contribute to chronix.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a pull request

Aps Build master

You can use the aps_build_master script for your os to make your like a lot easier. It supports running tests, installing, building and much more as well as chaining together as many commands as you like.

This example runs test, build the project and then installs it

call .\aps_build_master.bat 234
sudo apt install python3-pip
sudo apt install python3-venv
chmod +x ./aps_build_master.sh
./aps_build_master.sh 234

License

chronix is licensed under the LGPL-3.0 License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chronix-2.0.0.4.tar.gz (27.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chronix-2.0.0.4-py3-none-any.whl (25.3 kB view details)

Uploaded Python 3

File details

Details for the file chronix-2.0.0.4.tar.gz.

File metadata

  • Download URL: chronix-2.0.0.4.tar.gz
  • Upload date:
  • Size: 27.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for chronix-2.0.0.4.tar.gz
Algorithm Hash digest
SHA256 359e59e8595a637918582f9a2fec8caa06d5938b177273348ea7913ad73a86cd
MD5 7558a35b693436b2ae29ddae2ca88d3a
BLAKE2b-256 3291ad0dda0604e750efad191a717326253734144116bf463cb3f116b4c2d67d

See more details on using hashes here.

File details

Details for the file chronix-2.0.0.4-py3-none-any.whl.

File metadata

  • Download URL: chronix-2.0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 25.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for chronix-2.0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 0404ddfa51d11cb7aa40951aa7cafcb1fd3aa5d6a55fc71fd94496c447d727ef
MD5 cd9ca4abb9be0e765de914e778f93e5c
BLAKE2b-256 96f9de716fbbf48f1b240b75429620d924d7b02d65d16e52957d77f6cd660b78

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page