コード例 #1
0
    def testIterate_restricted(self):
        """Test getting rorps restricted to certain index

        In this case, get assume subdir (subdir3, subdir10) has 50
        files in it.

        """
        temprp = self.write_metadata_to_temp()
        mf = MetadataFile(temprp, 'rb')
        start_time = time.time()
        i = 0
        for rorp in mf.get_objects((b"subdir3", b"subdir10")):
            i += 1
        print("Reading %s metadata entries took %s seconds." %
              (i, time.time() - start_time))
        assert i == 51
コード例 #2
0
    def testSpeed(self):
        """Test testIterator on 10000 files"""
        temprp = self.write_metadata_to_temp()
        mf = MetadataFile(temprp, 'r')

        start_time = time.time()
        i = 0
        for rorp in mf.get_objects():
            i += 1
        print("Reading %s metadata entries took %s seconds." %
              (i, time.time() - start_time))

        start_time = time.time()
        blocksize = 32 * 1024
        with temprp.open("rb", compress=1) as tempfp:
            while 1:
                buf = tempfp.read(blocksize)
                if not buf:
                    break
        print("Simply decompressing metadata file took %s seconds" %
              (time.time() - start_time))