Skip to main content

This is Moruitech_LoggingPerformance Package

Project Title

Creating custom package for Logging 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 .

Technologie

Python

Installation

Install my-project with Python INstall Mouritech__LoggingPerformance

  pip install MT-PY-PerformanceLogging-Ver1==0.0.1
  cd MT-PY-PerformanceLogging-Ver1==0.0.1

Steps

from Mouritech_LoggingPerformance.LogPerformance import  PerformanceLogger
logger = PerformanceLogger(__name__)

PerformanceLogger(

)

Authors

License

MIT

MIT License GPLv3 License AGPL License

Used By

This project is used by the following Cases:

  • Projects :-Logging Performance for checking the Time duration taken by the code to Excute Task/program .
from Mouritech_LoggingPerformance.LogPerformance import  PerformanceLogger
logger = PerformanceLogger(__name__)

PerformanceLogger(
  
)

Receiver Example

test code for our package

from Mouritech_LoggingPerformance.LogPerformance import  PerformanceLogger

import datetime
import time

import logging
# Create an instance of PerformanceLogger
logger = PerformanceLogger(__name__)
logging.basicConfig(level=logging.INFO,filename='normfunction.log' ,format='%(asctime)s - %(levelname)s - %(message)s')

# Use the logger to measure function performance
@logger.log_performance
# 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()

Example:- 2

import time
import logging
# Create an instance of PerformanceLogger
logger = PerformanceLogger(__name__)
logging.basicConfig(level=logging.INFO, filename='decoresult.log', format='%(asctime)s - %(levelname)s - %(message)s')
def outer_addition(func):  #wrapped function
    @logger.log_performance
    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.log_performance
    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.log_performance
@outer_addition
@logger.log_performance
@outer_subtraction
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)

Release files for MT-PY-PerformanceLogging-Ver1 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for MT-PY-PerformanceLogging-Ver1 0.0.1
File Size Uploaded
MT_PY_PerformanceLogging_Ver1-0.0.1.tar.gz 4.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for MT-PY-PerformanceLogging-Ver1 0.0.1
File Interpreter ABI Platform
MT_PY_PerformanceLogging_Ver1-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 10.5 kB

Release files / MT_PY_PerformanceLogging_Ver1-0.0.1.tar.gz

Download URL MT_PY_PerformanceLogging_Ver1-0.0.1.tar.gz
Size 4.4 kB
Tags Source
SHA-256 checksum
How to use checksums
7a3d0e4985269fa06c434622bb11813a7f8c396f343e386b91cf2e792136e178
BLAKE2b-256 checksum
How to use checksums
c143c6802bd3bf6e00b17e03a2b56933d35e58d56055c38911b3889c2f05039c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / MT_PY_PerformanceLogging_Ver1-0.0.1-py3-none-any.whl

Download URL MT_PY_PerformanceLogging_Ver1-0.0.1-py3-none-any.whl
Size 6.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8ad1945412ca08010e73f25275f26860f0135a949090dd5ae2a96886ace70d2c
BLAKE2b-256 checksum
How to use checksums
0dec4ec250cc99572a3d82a77331e9ecf823751e7bd92e7c56786aac804e551c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page