Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

A Python framework to measure and compare the execution speed of different methods in a class.

Project Description

What?

A small and simple framework to measure and compare the execution speed of different methods in a class.

Example

#!/usr/bin/python

from testlap import TestLap
from random import randint

class Conditional_vs_Exception():
    '''
    Compare if then against try: except.
    '''

    def __init__(self):
        pass

    def test_1_if_then_else(self):
        '''Evaluate a value using if then else.'''

        number = randint(0,1)
        if number == 1:
            pass
        else:
            pass

    def test_2_try_except(self):
        '''Evaluate a value using try: except.'''

        number = randint(0,1)
        try:
            number == 1
        except:
            pass
        else:
            pass

if __name__ == '__main__':

    test_lap=TestLap(instance=Conditional_vs_Exception(), iterations=10000000)
    test_lap.go()
Running test_1_if_then_else
OK
Running test_2_try_except
OK
3.6.0 (default, Feb 12 2017, 22:33:51)
[GCC 6.3.1 20161221 (Red Hat 6.3.1-1)]
Linux-4.9.10-100.fc24.x86_64-x86_64-with-fedora-24-Twenty_Four

    Compare if then against try: except.

+---------------------+--------------------------------------+--------+---------+--------------+
| Function            | Description                          | Result | Seconds | Iterations/s |
+---------------------+--------------------------------------+--------+---------+--------------+
| test_1_if_then_else | Evaluate a value using if then else. | OK     |  13.586 |   736049.706 |
| test_2_try_except   | Evaluate a value using try: except.  | OK     |  13.898 |   719536.763 |
+---------------------+--------------------------------------+--------+---------+--------------+
Release History

Release History

This version
History Node

1.0.0

Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
testlap-1.0.0.tar.gz (3.1 kB) Copy SHA256 Checksum SHA256 Source Mar 4, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting