MT-PY-Performancelogging-ver2


NameMT-PY-Performancelogging-ver2 JSON
Version 0.0.1 PyPI version JSON
download
home_page
SummaryA Mouritech package
upload_time2023-10-04 11:38:34
maintainer
docs_urlNone
author
requires_python>=3.7
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Mouritech Custome package on  Performance Logging
## Package Name 
### MT_PY_PerformanceLogging

''' Performance in python.
This is the project ,Whenever you need to check the performance of the code like time taken by the code to perform some task ,we will use this package in our module'''


## Author

* [Sirisha .v](siriteju343@gmail.com)

## Requirements 
'''For running this, you need to have python3 installed on your system'''


## Debugging tools 

'''supported tools pycharm ,Anakonda ,Visual Studio etc...


## Installation 

Install my-project with Python
Install MT_PY_Performancelogging_ver2
### At command Promt
```cmd

  pip install  MT_PY_Performancelogging_ver2
  cd  MT_PY_PerformanceLogging_ver2
``` 
  (Globally )
``` py
pip install MT_PY_Performancelogging_ver2

```

## Steps 

  Before using library, you need setup some things in your django project, please follow this steps
1. Create virtual Environment for our Project ,
2. Setup all required variables in your settings.py

#### At terminal :

```cmd

pip install  MT_PY_Performancelogging_ver2



```

```py
# locally 

from  src.MT_PY_Performancelogging_ver2.MT_Performancelogger import MT_PerformanceLogging1
# globally 
from MT_PY_Performancelogging.MT_Performance import MT_PerformanceLogging1
from MT_Performance import MT_PerformanceLogging1

MT_PerformanceLogging1(

)

```

### Receiver Example  
```py

from src.MT_PY_Performancelogging_ver2.MT_Performancelogger import MT_PerformanceLogging1
# globally 
from  MT_PY_Performancelogging_ver2.MT_Performancelogger import MT_PerformanceLogging1
# test code for our package 
# 

import datetime
import time

import logging
# Create an instance of PerformanceLogger

logger = MT_PerformanceLogging1(__name__)
logging.basicConfig(level=logging.INFO,filename='normfunction.log' ,format='%(asctime)s - %(levelname)s - %(message)s')

# Use the logger to measure function performance
@logger.performance_log
# example code to check the loggingperformance 
# Diasum number =175
# Disarum Number = 1¹ + 7² + 5³ = 1 + 49 + 125= 175
# each digit is added with incrementation in power  and the addition of the powered value should be equal to actual input
def my_function():
    start_time = time.time()

    current_time = datetime.datetime.now()

    num=int(input('Enter Num value:'))

    result=0

    power=1

    for x in str(num):

        y=int(x)

        result= result + y**power

        power=power+1

    if num==result:

        print(f'The provide {num} is Disarum')

    else:

        print(f'The Provided {num} is Not a Disarum Number')

    # time sleep function is used to add delay in the execution of a program

    duration_to_add = datetime.timedelta(hours=0, minutes=1)

# # Estimate the end time by adding the duration to the current time

    ended_time = current_time  + duration_to_add
    end_time = time.time()
    elapsed_time = end_time - start_time
    logging.info(f'Code execution completed. Elapsed time: started at {current_time} {(start_time *10**3):.4f}  ended at {ended_time} {(end_time *10**3):.4f} = {elapsed_time:.4f} seconds')

# Call the function

my_function()
```
```log
2023-09-25 18:05:33,438 - INFO - Code execution completed. Elapsed time: started at 2023-09-25 18:05:30.695571 1695645330695.5710  ended at 2023-09-25 18:06:30.695571 1695645333436.9390 = 2.7414 seconds
2023-09-25 18:05:33,438 - INFO - Function 'my_function' executed in 2.7426 seconds
```


#### Example2:-
```py
from src.MT_PY_Performancelogging_ver2.MT_Performancelogger import MT_PerformanceLogging1
# globally 
from  MT_PY_Performancelogging_ver2.MT_Performancelogger import MT_PerformanceLogging1

import datetime

import time
import logging
# Create an instance of PerformanceLogger
logger = MT_PerformanceLogging1(__name__)
logging.basicConfig(level=logging.INFO, filename='decoresult.log', format='%(asctime)s - %(levelname)s - %(message)s')
def outer_addition(func):  #wrapped function
    @logger.performance_log
    def inner_addition(a, b):
        start_time = time.time()
        print("I'm in addition")
        sum_result = a + b
        print("Sum of", a, "and", b, "is", sum_result)
        print("Returning addition")
        func(sum_result, a)
        end_time = time.time()
        elapsed_time = end_time - start_time
        logging.info(f'Addition execution completed. Elapsed time: {elapsed_time} seconds')
    return inner_addition
def outer_subtraction(func):  #wrapped function
    @logger.performance_log
    def inner_substarction(a, b):
        start_time = time.time()
        print("I'm in subtraction")
        subtraction_result = a - b
        print("Subtraction of", a, "and", b, "is", subtraction_result)
        print("Returning subtraction")
        func(a, b)
        end_time = time.time()
        elapsed_time = end_time - start_time
        logging.info(f'Subtraction execution completed. Elapsed time: {elapsed_time} seconds')
    return inner_substarction
@logger.performance_log
@outer_addition
@logger.performance_log
@outer_subtraction
@logger.performance_log
def mOperations(a, b):
    start_time = time.time()
    print("I'm in mOperations")
    print("mOperations execution completed")
    end_time = time.time()
    elapsed_time = end_time - start_time
    logging.info(f'mOperations execution completed. Elapsed time: {elapsed_time} seconds')
mOperations(15, 10)
```
#### output:-
```log
2023-09-25 18:12:08,428 - INFO - Function 'mOperations' executed in 0.0017 seconds
2023-09-25 18:12:08,428 - INFO - Subtraction execution completed. Elapsed time: 0.001699209213256836 seconds
2023-09-25 18:12:08,428 - INFO - Function 'inner_substarction' executed in 0.0017 seconds
2023-09-25 18:12:08,428 - INFO - Function 'wrapper' executed in 0.0017 seconds
2023-09-25 18:12:08,428 - INFO - Addition execution completed. Elapsed time: 0.003078937530517578 seconds
2023-09-25 18:12:08,428 - INFO - Function 'inner_addition' executed in 0.0031 seconds
2023-09-25 18:12:08,428 - INFO - Function 'wrapper' executed in 0.0031 seconds
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "MT-PY-Performancelogging-ver2",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "",
    "author": "",
    "author_email": "Sirisha <siriteju343@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/b0/82/559e551269d7575870b9c5bc7e1122a22296f37082d4765049e765d2b542/MT_PY_Performancelogging_ver2-0.0.1.tar.gz",
    "platform": null,
    "description": "# Mouritech Custome package on  Performance Logging\r\n## Package Name \r\n### MT_PY_PerformanceLogging\r\n\r\n''' Performance in python.\r\nThis is the project ,Whenever you need to check the performance of the code like time taken by the code to perform some task ,we will use this package in our module'''\r\n\r\n\r\n## Author\r\n\r\n* [Sirisha .v](siriteju343@gmail.com)\r\n\r\n## Requirements \r\n'''For running this, you need to have python3 installed on your system'''\r\n\r\n\r\n## Debugging tools \r\n\r\n'''supported tools pycharm ,Anakonda ,Visual Studio etc...\r\n\r\n\r\n## Installation \r\n\r\nInstall my-project with Python\r\nInstall MT_PY_Performancelogging_ver2\r\n### At command Promt\r\n```cmd\r\n\r\n  pip install  MT_PY_Performancelogging_ver2\r\n  cd  MT_PY_PerformanceLogging_ver2\r\n``` \r\n  (Globally )\r\n``` py\r\npip install MT_PY_Performancelogging_ver2\r\n\r\n```\r\n\r\n## Steps \r\n\r\n  Before using library, you need setup some things in your django project, please follow this steps\r\n1. Create virtual Environment for our Project ,\r\n2. Setup all required variables in your settings.py\r\n\r\n#### At terminal :\r\n\r\n```cmd\r\n\r\npip install  MT_PY_Performancelogging_ver2\r\n\r\n\r\n\r\n```\r\n\r\n```py\r\n# locally \r\n\r\nfrom  src.MT_PY_Performancelogging_ver2.MT_Performancelogger import MT_PerformanceLogging1\r\n# globally \r\nfrom MT_PY_Performancelogging.MT_Performance import MT_PerformanceLogging1\r\nfrom MT_Performance import MT_PerformanceLogging1\r\n\r\nMT_PerformanceLogging1(\r\n\r\n)\r\n\r\n```\r\n\r\n### Receiver Example  \r\n```py\r\n\r\nfrom src.MT_PY_Performancelogging_ver2.MT_Performancelogger import MT_PerformanceLogging1\r\n# globally \r\nfrom  MT_PY_Performancelogging_ver2.MT_Performancelogger import MT_PerformanceLogging1\r\n# test code for our package \r\n# \r\n\r\nimport datetime\r\nimport time\r\n\r\nimport logging\r\n# Create an instance of PerformanceLogger\r\n\r\nlogger = MT_PerformanceLogging1(__name__)\r\nlogging.basicConfig(level=logging.INFO,filename='normfunction.log' ,format='%(asctime)s - %(levelname)s - %(message)s')\r\n\r\n# Use the logger to measure function performance\r\n@logger.performance_log\r\n# example code to check the loggingperformance \r\n# Diasum number =175\r\n# Disarum Number = 1\u00b9 + 7\u00b2 + 5\u00b3 = 1 + 49 + 125= 175\r\n# each digit is added with incrementation in power  and the addition of the powered value should be equal to actual input\r\ndef my_function():\r\n    start_time = time.time()\r\n\r\n    current_time = datetime.datetime.now()\r\n\r\n    num=int(input('Enter Num value:'))\r\n\r\n    result=0\r\n\r\n    power=1\r\n\r\n    for x in str(num):\r\n\r\n        y=int(x)\r\n\r\n        result= result + y**power\r\n\r\n        power=power+1\r\n\r\n    if num==result:\r\n\r\n        print(f'The provide {num} is Disarum')\r\n\r\n    else:\r\n\r\n        print(f'The Provided {num} is Not a Disarum Number')\r\n\r\n    # time sleep function is used to add delay in the execution of a program\r\n\r\n    duration_to_add = datetime.timedelta(hours=0, minutes=1)\r\n\r\n# # Estimate the end time by adding the duration to the current time\r\n\r\n    ended_time = current_time  + duration_to_add\r\n    end_time = time.time()\r\n    elapsed_time = end_time - start_time\r\n    logging.info(f'Code execution completed. Elapsed time: started at {current_time} {(start_time *10**3):.4f}  ended at {ended_time} {(end_time *10**3):.4f} = {elapsed_time:.4f} seconds')\r\n\r\n# Call the function\r\n\r\nmy_function()\r\n```\r\n```log\r\n2023-09-25 18:05:33,438 - INFO - Code execution completed. Elapsed time: started at 2023-09-25 18:05:30.695571 1695645330695.5710  ended at 2023-09-25 18:06:30.695571 1695645333436.9390 = 2.7414 seconds\r\n2023-09-25 18:05:33,438 - INFO - Function 'my_function' executed in 2.7426 seconds\r\n```\r\n\r\n\r\n#### Example2:-\r\n```py\r\nfrom src.MT_PY_Performancelogging_ver2.MT_Performancelogger import MT_PerformanceLogging1\r\n# globally \r\nfrom  MT_PY_Performancelogging_ver2.MT_Performancelogger import MT_PerformanceLogging1\r\n\r\nimport datetime\r\n\r\nimport time\r\nimport logging\r\n# Create an instance of PerformanceLogger\r\nlogger = MT_PerformanceLogging1(__name__)\r\nlogging.basicConfig(level=logging.INFO, filename='decoresult.log', format='%(asctime)s - %(levelname)s - %(message)s')\r\ndef outer_addition(func):  #wrapped function\r\n    @logger.performance_log\r\n    def inner_addition(a, b):\r\n        start_time = time.time()\r\n        print(\"I'm in addition\")\r\n        sum_result = a + b\r\n        print(\"Sum of\", a, \"and\", b, \"is\", sum_result)\r\n        print(\"Returning addition\")\r\n        func(sum_result, a)\r\n        end_time = time.time()\r\n        elapsed_time = end_time - start_time\r\n        logging.info(f'Addition execution completed. Elapsed time: {elapsed_time} seconds')\r\n    return inner_addition\r\ndef outer_subtraction(func):  #wrapped function\r\n    @logger.performance_log\r\n    def inner_substarction(a, b):\r\n        start_time = time.time()\r\n        print(\"I'm in subtraction\")\r\n        subtraction_result = a - b\r\n        print(\"Subtraction of\", a, \"and\", b, \"is\", subtraction_result)\r\n        print(\"Returning subtraction\")\r\n        func(a, b)\r\n        end_time = time.time()\r\n        elapsed_time = end_time - start_time\r\n        logging.info(f'Subtraction execution completed. Elapsed time: {elapsed_time} seconds')\r\n    return inner_substarction\r\n@logger.performance_log\r\n@outer_addition\r\n@logger.performance_log\r\n@outer_subtraction\r\n@logger.performance_log\r\ndef mOperations(a, b):\r\n    start_time = time.time()\r\n    print(\"I'm in mOperations\")\r\n    print(\"mOperations execution completed\")\r\n    end_time = time.time()\r\n    elapsed_time = end_time - start_time\r\n    logging.info(f'mOperations execution completed. Elapsed time: {elapsed_time} seconds')\r\nmOperations(15, 10)\r\n```\r\n#### output:-\r\n```log\r\n2023-09-25 18:12:08,428 - INFO - Function 'mOperations' executed in 0.0017 seconds\r\n2023-09-25 18:12:08,428 - INFO - Subtraction execution completed. Elapsed time: 0.001699209213256836 seconds\r\n2023-09-25 18:12:08,428 - INFO - Function 'inner_substarction' executed in 0.0017 seconds\r\n2023-09-25 18:12:08,428 - INFO - Function 'wrapper' executed in 0.0017 seconds\r\n2023-09-25 18:12:08,428 - INFO - Addition execution completed. Elapsed time: 0.003078937530517578 seconds\r\n2023-09-25 18:12:08,428 - INFO - Function 'inner_addition' executed in 0.0031 seconds\r\n2023-09-25 18:12:08,428 - INFO - Function 'wrapper' executed in 0.0031 seconds\r\n```\r\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "A Mouritech package",
    "version": "0.0.1",
    "project_urls": {
        "Bug Tracker": "https://github.com/pypa/sampleproject/issues",
        "Homepage": "https://github.com/pypa/sampleproject"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "987aa5161f66d12c4ae678a781d01bd8524fce8748aa673940007ba32ab3deaa",
                "md5": "ae6c684e45d5d6f65326f149d43bd6b4",
                "sha256": "1e82a8a299c322770a6d4aef602855c651906f18d36dceeb19ed0b7e10f67f71"
            },
            "downloads": -1,
            "filename": "MT_PY_Performancelogging_ver2-0.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ae6c684e45d5d6f65326f149d43bd6b4",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 6429,
            "upload_time": "2023-10-04T11:38:32",
            "upload_time_iso_8601": "2023-10-04T11:38:32.589422Z",
            "url": "https://files.pythonhosted.org/packages/98/7a/a5161f66d12c4ae678a781d01bd8524fce8748aa673940007ba32ab3deaa/MT_PY_Performancelogging_ver2-0.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b082559e551269d7575870b9c5bc7e1122a22296f37082d4765049e765d2b542",
                "md5": "4bcfe92ed534dc6fda4b564b9e6c926f",
                "sha256": "c93125efce1487e35f45228913b04d9033b69feba43ca4e4be9f036992a91551"
            },
            "downloads": -1,
            "filename": "MT_PY_Performancelogging_ver2-0.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "4bcfe92ed534dc6fda4b564b9e6c926f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 4941,
            "upload_time": "2023-10-04T11:38:34",
            "upload_time_iso_8601": "2023-10-04T11:38:34.525330Z",
            "url": "https://files.pythonhosted.org/packages/b0/82/559e551269d7575870b9c5bc7e1122a22296f37082d4765049e765d2b542/MT_PY_Performancelogging_ver2-0.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-04 11:38:34",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "pypa",
    "github_project": "sampleproject",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "mt-py-performancelogging-ver2"
}
        
Elapsed time: 0.12926s