#!/usr/bin/python

# pylint: disable=superfluous-parens
# superfluous-parens: Parentheses are good for clarity and portability

'''A little harness for profiling rolling_checksum_mod'''

import os
import profile
# We prefer the py module for this, because other forms might not profile as accurately
import rolling_checksum_py_mod as rolling_checksum_mod


def sample_rcm():
    '''
    Just generate the chunks, and report a little about them - just to generate a graph
    depicting how well rolling_checksum_mod is doing
    '''
    file_handle = open('rcm-input-data', 'rb')
    for chunkno, chunk in enumerate(rolling_checksum_mod.min_max_chunker(file_handle)):
        print('%d %d' % (chunkno, len(chunk)))
        if chunkno == 3:
            # Otherwise this script takes forever to run with profiling enabled
            break
    file_handle.close()


def main():
    '''Main function'''
    profile.run('sample_rcm()', os.path.join(os.getcwd(), 'profile-rcm.pstats'))

main()