Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Stress-tests #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
saxbophone opened this issue Oct 18, 2018 · 3 comments
Closed

Stress-tests #29

saxbophone opened this issue Oct 18, 2018 · 3 comments

Comments

@saxbophone
Copy link
Owner

Write some more comprehensive stress-tests which check that the encoder and decoder functions successfully handle many different unusual output bases, including with partial input to check that padding works successfully across any output base.

@saxbophone
Copy link
Owner Author

I wrote a quick stress-test right now:

import random

from basest.core import best_ratio, encode_raw, decode_raw


# stress test of Basest

# input bases in range 3..256
for input_base in range(3, 256 + 1):
    # output bases in range 2..256
    for output_base in range(2, 256 + 1):
        # only continue if output base is not larger than input base
        if not (output_base > input_base):
            # get an encoding ratio to use
            _, ratio = best_ratio(input_base, [output_base], range(1, 10 + 1))
            # explore the whole input window
            for input_window in range(1, ratio[0] + 1):
                # generate some random data, half as many items as the input ratio
                input_data = [random.randint(0, input_base - 1) for _ in range(input_window)]
                # encode the data
                encoded_data = encode_raw(
                    input_base, output_base,
                    ratio[0], ratio[1],
                    input_data
                )
                # decode the data
                decoded_data = decode_raw(
                    output_base, input_base,
                    ratio[1], ratio[0],
                    encoded_data
                )
                # check what we got back is the same as the original
                assert decoded_data == input_data
                # display some stuff
                print(input_data, encoded_data)

@saxbophone
Copy link
Owner Author

I haven't found a nice way of integrating this (and any future) stress-tests into the project yet, so I will not block the public release on this. I will put the test code file in the project tree on its own, pending complete integration into the build process.

@saxbophone
Copy link
Owner Author

Or maybe I can do this simply by putting the stress-test code into a file in the project root and adding commands to the Makefile to run that as the stress-test..?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant