Exemplo n.º 1
0
def shaderStats(compiler, stage, name, vscontext, fscontext):
	collect = ShaderStatCollector()

	for code in (vscontext.code, fscontext.code):
		ops, lcls, copies = astcollector.getAll(code)

		for op in ops:
			collect.op(op)

		collect.copies(len(copies))

	name = remap[name]

	compiler.stats[stage][name] = collect
Exemplo n.º 2
0
def contextStats(compiler, prgm, name, classOK=False):
	if not config.dumpStats: return

	optimization.cullprogram.evaluate(compiler, prgm)

	reportdir = os.path.join(config.outputDirectory, 'stats', name)
	ensureDirectoryExists(reportdir)

	liveCode = prgm.liveCode

	collect = StatCollector()
	collect.name = name
	collect.reportdir = reportdir

	for code in liveCode:
		if not code.isStandardCode(): continue

		cls = classifyCode(code)

		collect.code(cls, code)

		if False:
			print code
			print cls, len(code.annotation.contexts)
			print code.annotation.origin

			print

		ops, lcls, copies = astcollector.getAll(code)

		for op in ops:
			collect.op(cls, code, op)

		collect.copies(cls, code, len(copies))

	# Histogram
	if False:
		for count in sorted(collect.counts.iterkeys()):
			print count
			for cls, num in collect.counts[count].iteritems():
				print '\t', cls, num
			print


	tw = collections.defaultdict(lambda: 0)
	tc = collections.defaultdict(lambda: 0)
	for xtype, count in collect.access.iteritems():
		tw[xtype.obj.pythonType()] += count
		tc[xtype.obj.pythonType()] += 1


	paw = 0
	tow = 0
	otc = 0
	for t, count in collect.taccess.iteritems():
		rel = tw[t]/float(tc[t])
		print t, count, rel
		paw += rel
		tow += count
		otc += 1

	tapo = float(tow)/otc
	papo = paw/otc
	print
	print tapo, papo, papo/tapo
	print

	functionRatios(collect, classOK)
	opRatios(collect, classOK)

	if prgm.stats:
		opsRemoved(collect, prgm.stats)

	if False:
		for cls, lut in collect.opCount.iteritems():
			print cls
			for opT, num in lut.iteritems():
				print '\t', opT, num
			print
		print


	opPieChart(collect)

	print "vparams"
	print collect.vparamCount, collect.contextVparamCount
	print

	print "vargs"
	print collect.vargCount, collect.contextVargCount
	print


	generateIndex(collect)

	prgm.stats = collect

	return collect
Exemplo n.º 3
0
def contextStats(compiler, prgm, name, classOK=False):
    if not config.dumpStats: return

    optimization.cullprogram.evaluate(compiler, prgm)

    reportdir = os.path.join(config.outputDirectory, 'stats', name)
    ensureDirectoryExists(reportdir)

    liveCode = prgm.liveCode

    collect = StatCollector()
    collect.name = name
    collect.reportdir = reportdir

    for code in liveCode:
        if not code.isStandardCode(): continue

        cls = classifyCode(code)

        collect.code(cls, code)

        if False:
            print code
            print cls, len(code.annotation.contexts)
            print code.annotation.origin

            print

        ops, lcls, copies = astcollector.getAll(code)

        for op in ops:
            collect.op(cls, code, op)

        collect.copies(cls, code, len(copies))

    # Histogram
    if False:
        for count in sorted(collect.counts.iterkeys()):
            print count
            for cls, num in collect.counts[count].iteritems():
                print '\t', cls, num
            print

    tw = collections.defaultdict(lambda: 0)
    tc = collections.defaultdict(lambda: 0)
    for xtype, count in collect.access.iteritems():
        tw[xtype.obj.pythonType()] += count
        tc[xtype.obj.pythonType()] += 1

    paw = 0
    tow = 0
    otc = 0
    for t, count in collect.taccess.iteritems():
        rel = tw[t] / float(tc[t])
        print t, count, rel
        paw += rel
        tow += count
        otc += 1

    tapo = float(tow) / otc
    papo = paw / otc
    print
    print tapo, papo, papo / tapo
    print

    functionRatios(collect, classOK)
    opRatios(collect, classOK)

    if prgm.stats:
        opsRemoved(collect, prgm.stats)

    if False:
        for cls, lut in collect.opCount.iteritems():
            print cls
            for opT, num in lut.iteritems():
                print '\t', opT, num
            print
        print

    opPieChart(collect)

    print "vparams"
    print collect.vparamCount, collect.contextVparamCount
    print

    print "vargs"
    print collect.vargCount, collect.contextVargCount
    print

    generateIndex(collect)

    prgm.stats = collect

    return collect