Skip to main content

A tool library created by jaanca that allows measuring the time between two moments in the source code.

Project description

jaanca public libraries

Package version Python


A tool library created by jaanca

  • Python library: A tool library created by jaanca that allows measuring the time between two moments in the source code.
  • Analyze results in database: The output format can be inserted in an INTERVAL attribute for example in PostgreSQL and add the time of several processes.

Source code | Package (PyPI) | Samples


library installation

pip install jaanca-chronometer --upgrade

Example of use

from datetime import timedelta
from jaanca_chronometer import Chronometer
import time

if __name__=="__main__":
    chronometer=Chronometer()

    print(f"date_time format or interval format: {chronometer.get_format_time()}")

    chronometer.start()
    time.sleep(1)
    chronometer.stop()
    elapsed_time=str(chronometer.get_elapsed_time())
    print(f"type[str]:{elapsed_time}")

    chronometer.start()
    time.sleep(2)
    chronometer.stop()
    elapsed_time=str(chronometer.get_elapsed_time())
    print(f"type[str]:{elapsed_time}")

    chronometer.start()
    time.sleep(3)
    chronometer.stop()
    elapsed_time:timedelta=chronometer.get_elapsed_time(interval_format=False)
    print(f"type[timedelta] to insert into databases like PostgreSQL:{elapsed_time}")
    print(f"timedelta[seconds]:{elapsed_time.seconds}")
    
    parse_elapsed_time = Chronometer.parse_elapsed_time("20:3:35")
    print(f"parse_elapsed_time[20:3:35]:{parse_elapsed_time}")

    parse_elapsed_time = Chronometer.parse_elapsed_time("1:1")
    print(f"parse_elapsed_time[1:1]:{parse_elapsed_time}")
    

Example of inserting elapsed time into PostgreSQL and totaling the results

CREATE TABLE process_execution (
    id SERIAL PRIMARY KEY,
    description VARCHAR(100),
    time INTERVAL
);

INSERT INTO process_execution (description,time) VALUES ('process_simulator','01:30:00'::interval);
INSERT INTO process_execution (description,time) VALUES ('process_simulator','02:15:00'::interval);
INSERT INTO process_execution (description,time) VALUES ('process_simulator','00:45:00'::interval);
INSERT INTO process_execution (description,time) VALUES ('process_simulator','99:45:00'::interval);

SELECT SUM(time) FROM process_execution WHERE description = 'process_simulator';

-- Result:104:15:00

Semantic Versioning

jaanca-chronometer < MAJOR >.< MINOR >.< PATCH >

  • MAJOR: version when you make incompatible API changes
  • MINOR: version when you add functionality in a backwards compatible manner
  • PATCH: version when you make backwards compatible bug fixes

Definitions for releasing versions

  • https://peps.python.org/pep-0440/

    • X.YaN (Alpha release): Identify and fix early-stage bugs. Not suitable for production use.
    • X.YbN (Beta release): Stabilize and refine features. Address reported bugs. Prepare for official release.
    • X.YrcN (Release candidate): Final version before official release. Assumes all major features are complete and stable. Recommended for testing in non-critical environments.
    • X.Y (Final release/Stable/Production): Completed, stable version ready for use in production. Full release for public use.

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

Types of changes

  • Added for new features.
  • Changed for changes in existing functionality.
  • Deprecated for soon-to-be removed features.
  • Removed for now removed features.
  • Fixed for any bug fixes.
  • Security in case of vulnerabilities.

[0.0.1rcX] - 2024-05-21

Added

  • First tests using pypi.org in develop environment.

[0.1.X] - 2024-05-21

Added

  • Completion of testing and launch into production.

[0.1.3] - 2024-05-23

Changed

  • Documentation improvements.

[0.1.4] - 2024-06-20

Changed

  • It is added to the get_elapsed_time function to return the elapsed time in timedelta format, which is accepted to insert the record into a database engine such as PostgreSQL.

[0.1.5] - 2024-06-20

Added

  • New parse_elapsed_time functionality to convert str to timedelta.

[0.1.6] - 2024-07-11

Added

  • New sum_elapsed_times functionality to takes two times in HH:mm format, converts them to seconds, adds them and converts the result back to HH:mm.

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

jaanca_chronometer-0.1.6.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

jaanca_chronometer-0.1.6-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file jaanca_chronometer-0.1.6.tar.gz.

File metadata

  • Download URL: jaanca_chronometer-0.1.6.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.7

File hashes

Hashes for jaanca_chronometer-0.1.6.tar.gz
Algorithm Hash digest
SHA256 22e9bc7e1fe2ce1ad63c4f1ec2627a0cded88c810ab8f2e6ad06011fceb83851
MD5 01879ab90bd6283416f3a9c3d9f7a18e
BLAKE2b-256 de9975af3998fd8133c465a31fafcfd1c263e18f4fd2ef38f63dac0e7bcf0403

See more details on using hashes here.

File details

Details for the file jaanca_chronometer-0.1.6-py3-none-any.whl.

File metadata

File hashes

Hashes for jaanca_chronometer-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 9fce5a5c44e4cedd0a1e7701a8cdcee044bc8f0dd1ece7ce6ece15be8b25c1f9
MD5 f996a9c2f53ee2e5c76603c12aa384c5
BLAKE2b-256 88ff96472099d20fa7e9e457e5e848c40d05b336eb0e85903a3b43784e8a05a2

See more details on using hashes here.

Supported by

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