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}")
    

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.

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.5.tar.gz (5.1 kB view hashes)

Uploaded Source

Built Distribution

jaanca_chronometer-0.1.5-py3-none-any.whl (5.8 kB view hashes)

Uploaded Python 3

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