def generateReport(self, report):
     report.name = self.name
     report.fractionOfUsedMemoryDirty = self.fractionOfUsedMemoryDirty()
     report.usedMemory = self.usedMemory()
     report.lastAccessTime = self.lastAccessTime()
     report.type = type(self)
     report.id = id(self)
    
     for i, (b_ind, block) in enumerate(self._labelers.iteritems()):
         start = self._blockShape*self._flatBlockIndices[b_ind]
         stop  = numpy.minimum(start + self._blockShape, self.Output.meta.shape)
        
         n = MemInfoNode()
         n.roi = (start, stop)
         report.children.append(n)
         block.generateReport(n)
Esempio n. 2
0
 def testAPIConformity(self):
     g = Graph()
     op = self.Model(graph=g)
     r = MemInfoNode()
     op.generateReport(r)
     assert r.type is not None
     assert r.id is not None
     assert r.name is not None
    def generateReport(self, report):
        report.name = self.name
        report.fractionOfUsedMemoryDirty = self.fractionOfUsedMemoryDirty()
        report.usedMemory = self.usedMemory()
        report.lastAccessTime = self.lastAccessTime()
        report.type = type(self)
        report.id = id(self)

        for i, (b_ind, block) in enumerate(self._labelers.iteritems()):
            start = self._blockShape * self._flatBlockIndices[b_ind]
            stop = numpy.minimum(start + self._blockShape,
                                 self.Output.meta.shape)

            n = MemInfoNode()
            n.roi = (start, stop)
            report.children.append(n)
            block.generateReport(n)
Esempio n. 4
0
 def _updateReport(self):
     # we keep track of dirty reports so we just have to update the tree
     # instead of reconstructing it
     reports = []
     for c in self._mgr.getFirstClassCaches():
         r = MemInfoNode()
         c.generateReport(r)
         reports.append(r)
     self._root.handleChildrenReports(reports, root=self.tree.invisibleRootItem())
Esempio n. 5
0
    def generateReport(self, report):
        report.name = self.name
        report.fractionOfUsedMemoryDirty = self.fractionOfUsedMemoryDirty()
        report.usedMemory = self.usedMemory()
        report.type = type(self)
        report.id = id(self)

        for block_index in self._cache_list.keys():
            start = self._blockShape*self._get_block_multi_index(block_index)
            stop = map(lambda z: z[0]+z[1], zip(start, self._blockShape))
            stop = numpy.minimum(stop, self.Output.meta.shape)
            
            n = MemInfoNode()
            n.roi = (start, stop)
            report.children.append(n)
            try:
                block = self._cache_list[block_index]
            except KeyError:
                # probably cleaned up 
                pass
            else:
                block.generateReport(n)
Esempio n. 6
0
    def generateReport(self, report):
        report.name = self.name
        report.fractionOfUsedMemoryDirty = self.fractionOfUsedMemoryDirty()
        report.usedMemory = self.usedMemory()
        report.type = type(self)
        report.id = id(self)

        for block_index in self._cache_list.keys():
            start = self._blockShape * self._get_block_multi_index(block_index)
            stop = map(lambda z: z[0] + z[1], zip(start, self._blockShape))
            stop = numpy.minimum(stop, self.Output.meta.shape)

            n = MemInfoNode()
            n.roi = (start, stop)
            report.children.append(n)
            try:
                block = self._cache_list[block_index]
            except KeyError:
                # probably cleaned up
                pass
            else:
                block.generateReport(n)
Esempio n. 7
0
    def generateReport(self, report):
        report.name = self.name
        report.fractionOfUsedMemoryDirty = self.fractionOfUsedMemoryDirty()
        report.usedMemory = self.usedMemory()
        report.dtype = self.Output.meta.dtype
        report.type = type(self)
        report.id = id(self)
        sh = self.Output.meta.shape
        if sh is not None:
            report.roi = ([0] * len(sh), sh)

        for iOp in self._innerOps:
            n = MemInfoNode()
            report.children.append(n)
            iOp.generateReport(n)
Esempio n. 8
0
    def testAPIConformity(self):
        g = Graph()
        op = self.Model(graph=g)
        r = MemInfoNode()
        op.generateReport(r)

        used = op.usedMemory()
        assert used is not None
        assert used >= 0
        assert used == r.usedMemory
        frac = op.fractionOfUsedMemoryDirty()
        assert frac is not None
        assert frac >= 0.0
        assert frac <= 1.0
        assert frac == r.fractionOfUsedMemoryDirty
Esempio n. 9
0
    def testAPIConformity(self):
        g = Graph()
        op = self.Model(graph=g)
        r = MemInfoNode()
        op.generateReport(r)

        t = op.lastAccessTime()
        assert t is not None
        assert t >= 0.0
        assert t == r.lastAccessTime

        dirty = op.fractionOfUsedMemoryDirty()
        memFreed = op.freeDirtyMemory()
        assert op.fractionOfUsedMemoryDirty() <= dirty
        assert memFreed is not None
        assert memFreed >= 0

        memFreed = op.freeMemory()
        assert op.usedMemory() == 0
        assert memFreed is not None
        assert memFreed >= 0
Esempio n. 10
0
    def testReportGeneration(self):
        graph = Graph()
        sampleData = numpy.random.randint(0, 256, size=(50, 50, 50))
        sampleData = sampleData.astype(numpy.uint8)
        sampleData = vigra.taggedView(sampleData, axistags='xyz')

        opData = OpArrayPiper(graph=graph)
        opData.Input.setValue(sampleData)

        op = OpCompressedCache(parent=None, graph=graph)
        op.BlockShape.setValue((25, 25, 25))
        op.Input.connect(opData.Output)

        before = time.time()
        assert op.Output.ready()
        assert op.usedMemory() == 0.0,\
            "cache must not be filled at this point"
        op.Output[...].wait()
        assert op.usedMemory() > 0.0,\
            "cache must contain data at this point"
        after = time.time()

        r = MemInfoNode()
        op.generateReport(r)
        # not sure how good this can be compressed, but the cache
        # should hold memory by now
        assert r.usedMemory > 0
        # check sanity of last access time
        assert r.lastAccessTime >= before, str(r.lastAccessTime)
        assert r.lastAccessTime <= after, str(r.lastAccessTime)
        assert r.fractionOfUsedMemoryDirty == 0.0

        opData.Input.setDirty((slice(0, 25), slice(0, 25), slice(0, 25)))
        assert op.fractionOfUsedMemoryDirty() < 1.0
        assert op.fractionOfUsedMemoryDirty() > 0

        opData.Input.setDirty(slice(None))
        assert op.fractionOfUsedMemoryDirty() == 1.0