Almetro Library
version number: 1.0.7 author: Arnour Sabino
Overview
A python library to measure algorithms execution time and compare with its theoretical complexity.
Installation / Usage
To install use pip:
$ pip install almetro
Or clone the repo:
$ git clone https://github.com/arnour/almetro.git
$ python setup.py install
Information
Almetro uses timeit module from python to time your algorithms.
See more here
Examples
Applying Almetro to a quadratic algorithm:
import almetro
from almetro.algorithms import loop_n_quadratic
from almetro.complexity import cn_quadratic
from almetro.instance import growing
metro = almetro\
.new()\
.with_execution(trials=5)\
.with_instances(instances=20, provider=growing(initial_size=100, growth_size=100))\
.metro(algorithm=loop_n_quadratic, complexity=cn_quadratic)
chart = metro.chart()
chart.show()
Applying Almetro to a lg n algorithm:
import almetro
from almetro.algorithms import loop_n_log
from almetro.complexity import clog_n
from almetro.instance import growing
metro = almetro\
.new()\
.with_execution(trials=100)\
.with_instances(instances=20, provider=growing(initial_size=10000, growth_size=10000))\
.metro(algorithm=loop_n_log, complexity=clog_n)
chart = metro.chart()
chart.show()
Customazing execution:
import almetro
from almetro.complexity import Complexity
from almetro.instance import generator
my_custom_complexity = Complexity(
theoretical=lambda v=1, e=1, c=1: v * v,
experimental=lambda v=1, e=1, c=1: v + e,
text='O(v^2)',
latex=r'$\mathcal{O}(v^2)$'
)
# You need to provide instances as dict: {'name': '', 'size': {}, 'value': {}}
# Size must contains all needed theoretical complexity arguments
# Value must contain all needed algorithms arguments
def my_custom_instances(n):
g = create_some_graph()
for _ in range(n):
yield {
'name': 'my instance name',
'size': {'v': len(g.nodes()), 'e': len(g.edges())}, 'c': some_order_value(),
'value': {
'graph': g,
'v': len(g.nodes())
}
}
def my_custom_algorithm(graph, v):
# Do some stuff
pass
N = 50
instances_generator = my_custom_instances(N)
# Trials determine how many times each instance will be repeated for Almetro to pick the min time.
metro = almetro\
.new()\
.with_execution(trials=5)\
.with_instances(instances=N, provider=generator(instances_generator)\
.metro(algorithm=my_custom_algorithm, complexity=my_custom_complexity)
metro.chart().show()
metro.table().show()
Metadata
Release files for almetro 1.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| almetro-1.0.7.tar.gz | 11.3 kB | Without provenance | Details for almetro-1.0.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| almetro-1.0.7-py3-none-any.whl | Python 3 | none | any | Details for almetro-1.0.7-py3-none-any.whl |
Total release size: 23.2 kB
Release files / almetro-1.0.7.tar.gz
| Download URL | almetro-1.0.7.tar.gz |
|---|---|
| Size | 11.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fc36e46bf75d97c4a120ee4645e95f7c088ebefd6a279ce6c7cd9fe09ed1155a
|
|
BLAKE2b-256 checksum How to use checksums |
6e24136c3e64edc3c1d5c3a162a5aae7dfa478d6e1d262fed5cefc1f40f4e6f7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.5
|
Release files / almetro-1.0.7-py3-none-any.whl
| Download URL | almetro-1.0.7-py3-none-any.whl |
|---|---|
| Size | 11.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
465e4fc324870c58cdd7ee9b037b0172b194334e1fd70b32e75101eb55b4944a
|
|
BLAKE2b-256 checksum How to use checksums |
f42aecf2c10de34a628b232a80397fa23da45ee72c496bf15a7acbd973cfe29c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.5
|
Security for almetro 1.0.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.