Skip to main content

Accurate Measurement of Small Execution Times

Project description

Accurate Measurement of Small Execution Times

This library implements a wrapper that can be used to accuratly measure small execution times. This work is an implementation of the method described in this work [1].

Measuring execution times, especially for quick applications (< 100 milliseconds), can be quite hard. The traditional method to do it is by simply measuring the system time before and after a function call. This is not very robust and it is even susceptible to systematic and random measurement errors:

  1. Systematic error: by invoking the measuring instruction, an unknown amount of time is added to the execution time of the target function. This unknown amount depends on the OS, the particular implementation and other uncontrollable factors.

  2. Random error: the execution time of the target function will vary to a certain degree.

We can minimize the random error by just performing multiple measurements and taking the average of those. However, it is much more challenging to remove the systematic error.

Carlos Moreno and Sebastian Fischmeister presented a novel technique to combat this systematic error. The basic idea is to measure the execution time of an incremental sequential number of function executions. Starting to measure the time of one execution, then two executions and so on. The overall execution time can then be obtained by taking the slope a from the fitted line. The authors also note that this type of measurement is very robust against occasional measurements with large errors.

Running unit tests

Several unit tests were written to validate some corner cases. The unit tests were written in unittest. Run the following commands to execute the unit tests.

python -m unittest

Documentation

This library was documented using the google style docstring, it can be accessed here. Run the following commands to produce the documentation for this library.

pip install pdoc
pdoc --math -d google -o docs exectime \
--logo https://raw.githubusercontent.com/mariolpantunes/exectime/main/media/stopwatch.png \
--favicon https://raw.githubusercontent.com/mariolpantunes/exectime/main/media/stopwatch.png

Instalation

The library can be used by adding this line to the requirement.txt file:

git+https://github.com/mariolpantunes/exectime@main#egg=exectime

Usage

References

[1] C. Moreno and S. Fischmeister, "Accurate Measurement of Small Execution Times—Getting Around Measurement Errors," in IEEE Embedded Systems Letters, vol. 9, no. 1, pp. 17-20, March 2017, doi: 10.1109/LES.2017.2654160.

Authors

License

This project is licensed under the MIT License - see the LICENSE file for details.

Time icons created by Freepik - Flaticon

Python CI

MIT License

Copyright (c) 2022 Mário Antunes

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

exectimeit-0.1.1.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

exectimeit-0.1.1-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file exectimeit-0.1.1.tar.gz.

File metadata

  • Download URL: exectimeit-0.1.1.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for exectimeit-0.1.1.tar.gz
Algorithm Hash digest
SHA256 ef695d070b41b56c74066b5fc12352c9716ff8a3b4ea62f157417347a6ce6632
MD5 a21c16f74ea2ba566f7a440c10987dbf
BLAKE2b-256 3f32541c0389fa7f2cd95a215d7c1dad2f2db3257e7e44c85a0fc15d90554f67

See more details on using hashes here.

File details

Details for the file exectimeit-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: exectimeit-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for exectimeit-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ead8ddc1649786a136198b33308b8db074f1449318e4d0950b59b75a131ad1ad
MD5 8b058bd974b4e101e5cfb536902ff74d
BLAKE2b-256 0804741fc87a54bc23372d22a42d7d7b15c25f8704566954a45ad2120b2ec084

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page