#!/usr/bin/python '''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 = os.open('rcm-input-data', os.O_RDONLY) 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 os.close(file_handle) def main(): '''Main function''' profile.run('sample_rcm()', os.path.join(os.getcwd(), 'profile-rcm.pstats')) main()