jaanca-chronometer


Namejaanca-chronometer JSON
Version 0.1.5 PyPI version JSON
download
home_pagehttps://github.com/jaanca/python-libraries/tree/main/jaanca-chronometer
SummaryA tool library created by jaanca that allows measuring the time between two moments in the source code.
upload_time2024-06-20 19:57:29
maintainerNone
docs_urlNone
authorJaime Andres Cardona Carrillo
requires_python>=3.8
licenseMIT License
keywords timer stopwatch in interval format for databases
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <p align="center">
    <em>jaanca public libraries</em>
</p>

<p align="center">
<a href="https://pypi.org/project/jaanca-chronometer" target="_blank">
    <img src="https://img.shields.io/pypi/v/jaanca-chronometer?color=blue&label=PyPI%20Package" alt="Package version">
</a>
<a href="(https://www.python.org" target="_blank">
    <img src="https://img.shields.io/badge/Python-%5B%3E%3D3.8%2C%3C%3D3.11%5D-blue" alt="Python">
</a>
</p>


---

#  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](https://github.com/jaanca/python-libraries/tree/main/jaanca-chronometer)
| [Package (PyPI)](https://pypi.org/project/jaanca-chronometer/)
| [Samples](https://github.com/jaanca/python-libraries/tree/main/jaanca-chronometer/samples)

---

# library installation
```console
pip install jaanca-chronometer --upgrade
```

---
# Example of use

```python
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

```sql
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](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 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.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/jaanca/python-libraries/tree/main/jaanca-chronometer",
    "name": "jaanca-chronometer",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "timer stopwatch in interval format for databases",
    "author": "Jaime Andres Cardona Carrillo",
    "author_email": "jacardona@outlook.com",
    "download_url": "https://files.pythonhosted.org/packages/b9/5e/a8be209f799783615df6ef4eeca35adc8ddd1a729a5fb3f12321d1050c41/jaanca_chronometer-0.1.5.tar.gz",
    "platform": null,
    "description": "<p align=\"center\">\r\n    <em>jaanca public libraries</em>\r\n</p>\r\n\r\n<p align=\"center\">\r\n<a href=\"https://pypi.org/project/jaanca-chronometer\" target=\"_blank\">\r\n    <img src=\"https://img.shields.io/pypi/v/jaanca-chronometer?color=blue&label=PyPI%20Package\" alt=\"Package version\">\r\n</a>\r\n<a href=\"(https://www.python.org\" target=\"_blank\">\r\n    <img src=\"https://img.shields.io/badge/Python-%5B%3E%3D3.8%2C%3C%3D3.11%5D-blue\" alt=\"Python\">\r\n</a>\r\n</p>\r\n\r\n\r\n---\r\n\r\n#  A tool library created by jaanca\r\n\r\n* **Python library**: A tool library created by jaanca that allows measuring the time between two moments in the source code.\r\n* **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.\r\n\r\n[Source code](https://github.com/jaanca/python-libraries/tree/main/jaanca-chronometer)\r\n| [Package (PyPI)](https://pypi.org/project/jaanca-chronometer/)\r\n| [Samples](https://github.com/jaanca/python-libraries/tree/main/jaanca-chronometer/samples)\r\n\r\n---\r\n\r\n# library installation\r\n```console\r\npip install jaanca-chronometer --upgrade\r\n```\r\n\r\n---\r\n# Example of use\r\n\r\n```python\r\nfrom datetime import timedelta\r\nfrom jaanca_chronometer import Chronometer\r\nimport time\r\n\r\nif __name__==\"__main__\":\r\n    chronometer=Chronometer()\r\n\r\n    print(f\"date_time format or interval format: {chronometer.get_format_time()}\")\r\n\r\n    chronometer.start()\r\n    time.sleep(1)\r\n    chronometer.stop()\r\n    elapsed_time=str(chronometer.get_elapsed_time())\r\n    print(f\"type[str]:{elapsed_time}\")\r\n\r\n    chronometer.start()\r\n    time.sleep(2)\r\n    chronometer.stop()\r\n    elapsed_time=str(chronometer.get_elapsed_time())\r\n    print(f\"type[str]:{elapsed_time}\")\r\n\r\n    chronometer.start()\r\n    time.sleep(3)\r\n    chronometer.stop()\r\n    elapsed_time:timedelta=chronometer.get_elapsed_time(interval_format=False)\r\n    print(f\"type[timedelta] to insert into databases like PostgreSQL:{elapsed_time}\")\r\n    print(f\"timedelta[seconds]:{elapsed_time.seconds}\")\r\n    \r\n```\r\n\r\n---\r\n# Example of inserting elapsed time into PostgreSQL and totaling the results\r\n\r\n```sql\r\nCREATE TABLE process_execution (\r\n    id SERIAL PRIMARY KEY,\r\n    description VARCHAR(100),\r\n    time INTERVAL\r\n);\r\n\r\nINSERT INTO process_execution (description,time) VALUES ('process_simulator','01:30:00'::interval);\r\nINSERT INTO process_execution (description,time) VALUES ('process_simulator','02:15:00'::interval);\r\nINSERT INTO process_execution (description,time) VALUES ('process_simulator','00:45:00'::interval);\r\nINSERT INTO process_execution (description,time) VALUES ('process_simulator','99:45:00'::interval);\r\n\r\nSELECT SUM(time) FROM process_execution WHERE description = 'process_simulator';\r\n\r\n-- Result:104:15:00\r\n\r\n```\r\n\r\n---\r\n\r\n# Semantic Versioning\r\n\r\njaanca-chronometer < MAJOR >.< MINOR >.< PATCH >\r\n\r\n* **MAJOR**: version when you make incompatible API changes\r\n* **MINOR**: version when you add functionality in a backwards compatible manner\r\n* **PATCH**: version when you make backwards compatible bug fixes\r\n\r\n## Definitions for releasing versions\r\n* https://peps.python.org/pep-0440/\r\n\r\n    - X.YaN (Alpha release): Identify and fix early-stage bugs. Not suitable for production use.\r\n    - X.YbN (Beta release): Stabilize and refine features. Address reported bugs. Prepare for official release.\r\n    - X.YrcN (Release candidate): Final version before official release. Assumes all major features are complete and stable. Recommended for testing in non-critical environments.\r\n    - X.Y (Final release/Stable/Production): Completed, stable version ready for use in production. Full release for public use.\r\n---\r\n\r\n# Changelog\r\n\r\nAll notable changes to this project will be documented in this file.\r\n\r\nThe format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),\r\nand this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).\r\n\r\n## Types of changes\r\n\r\n- Added for new features.\r\n- Changed for changes in existing functionality.\r\n- Deprecated for soon-to-be removed features.\r\n- Removed for now removed features.\r\n- Fixed for any bug fixes.\r\n- Security in case of vulnerabilities.\r\n\r\n## [0.0.1rcX] - 2024-05-21\r\n### Added\r\n- First tests using pypi.org in develop environment.\r\n\r\n## [0.1.X] - 2024-05-21\r\n### Added\r\n- Completion of testing and launch into production.\r\n\r\n## [0.1.3] - 2024-05-23\r\n### Changed\r\n- Documentation improvements.\r\n\r\n## [0.1.4] - 2024-06-20\r\n### Changed\r\n- 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.\r\n\r\n## [0.1.5] - 2024-06-20\r\n### Added\r\n- New parse_elapsed_time functionality to convert str to timedelta.\r\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "A tool library created by jaanca that allows measuring the time between two moments in the source code.",
    "version": "0.1.5",
    "project_urls": {
        "Homepage": "https://github.com/jaanca/python-libraries/tree/main/jaanca-chronometer"
    },
    "split_keywords": [
        "timer",
        "stopwatch",
        "in",
        "interval",
        "format",
        "for",
        "databases"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d592700556ff7b9f4e7b86b7c3ea8a3bfede09f93003b302b9ef8872c6c8ee7c",
                "md5": "b0eed6ba1fa6560fc993ea7dd6f34094",
                "sha256": "5688a05dd0e51f42ad8517fd74fce265ed9dce762e262089b6ef559781158eb6"
            },
            "downloads": -1,
            "filename": "jaanca_chronometer-0.1.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b0eed6ba1fa6560fc993ea7dd6f34094",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 5811,
            "upload_time": "2024-06-20T19:57:27",
            "upload_time_iso_8601": "2024-06-20T19:57:27.829274Z",
            "url": "https://files.pythonhosted.org/packages/d5/92/700556ff7b9f4e7b86b7c3ea8a3bfede09f93003b302b9ef8872c6c8ee7c/jaanca_chronometer-0.1.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b95ea8be209f799783615df6ef4eeca35adc8ddd1a729a5fb3f12321d1050c41",
                "md5": "13ee3e11e8537c99003cf474508bc530",
                "sha256": "b1ef5beba55c8b4542178a2d725a63d69c906f81700f31cda21e55526b07bad9"
            },
            "downloads": -1,
            "filename": "jaanca_chronometer-0.1.5.tar.gz",
            "has_sig": false,
            "md5_digest": "13ee3e11e8537c99003cf474508bc530",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 5080,
            "upload_time": "2024-06-20T19:57:29",
            "upload_time_iso_8601": "2024-06-20T19:57:29.536037Z",
            "url": "https://files.pythonhosted.org/packages/b9/5e/a8be209f799783615df6ef4eeca35adc8ddd1a729a5fb3f12321d1050c41/jaanca_chronometer-0.1.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-20 19:57:29",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "jaanca",
    "github_project": "python-libraries",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "jaanca-chronometer"
}
        
Elapsed time: 0.31303s