duck.utils.performanceΒΆ

Performance Utilities Module

Provides functions for measuring code performance, timing code execution, and optimizing operations.

Module ContentsΒΆ

FunctionsΒΆ

async_exec_time

A decorator that measures the execution time of a function.

exec_time

A decorator that measures the execution time of a function.

measure_time

Measures the time taken to run a function.

optimize_list_sort

Optimizes sorting by removing duplicates before sorting the list.

APIΒΆ

duck.utils.performance.async_exec_time(func)[source]ΒΆ

A decorator that measures the execution time of a function.

Parameters:

func – The function to measure.

Returns:

The wrapped asynchronous function that will time its execution.

Return type:

function

duck.utils.performance.exec_time(func)[source]ΒΆ

A decorator that measures the execution time of a function.

Parameters:

func – The function to measure.

Returns:

The wrapped function that will time its execution.

Return type:

function

duck.utils.performance.measure_time(func)[source]ΒΆ

Measures the time taken to run a function.

Parameters:

func – The function to measure.

Returns:

The execution time in seconds.

Return type:

float

duck.utils.performance.optimize_list_sort(lst: list) β†’ list[source]ΒΆ

Optimizes sorting by removing duplicates before sorting the list.

Parameters:

lst – The list to be sorted.

Returns:

The sorted list without duplicates.

Return type:

list