#!/usr/bin/env python

import fileinput
import numpy
import os.path
import scipy.stats
import sys

def main():
	global fill_results
	global sum_results
	global type_names

	for path in sys.argv[1:]:
		if os.path.basename(path).startswith('analyze'):
			continue

		fill_results = {}
		sum_results = {}
		type_names = []

		parse(path)
		analyze(fill_results)
		analyze(sum_results)
		
		out_path = os.path.join(os.path.dirname(path), os.path.basename(path).replace('measure', 'analyze'))
		out = open(out_path, 'w')
		report(fill_results, 'fill', out)
		report(sum_results, 'sum', out)
		out.close()

def parse(path):
	for line in open(path):
		if line[0] == '#':
			continue
	
		fields = line.split()
		type_name = fields[0]
		offset = int(fields[1])
		fill_time = int(fields[-1])
		sum_time = int(fields[-2])
	
		append_results(fill_results, type_name, offset, fill_time)
		append_results(sum_results, type_name, offset, sum_time)

		if not len(type_names) or type_names[-1] != type_name:
			type_names.append(type_name)

def append_results(results, type_name, offset, time):
	try:
		type_result = results[type_name]
	except:
		type_result = {"type_name": type_name, "offset": {}}
		results[type_name] = type_result
	try:
		offset_time = type_result["offset"][offset]["time"]
	except:
		offset_time = []
		type_result["offset"][offset] = {"val": offset, "time": offset_time}
	offset_time.append(time)

def analyze(results):
	for type_name, type_result in results.items():
		time0 = type_result["offset"][0]["time"]
		for offset in type_result["offset"].values():
			time = offset["time"]
			offset["mean"] = numpy.mean(time) / 1000
			offset["std"] = numpy.std(time) / 1000
			offset["ttest"] = scipy.stats.ttest_ind(time, time0, equal_var = False)[1]
			offset["conclusion"] = " (a != b)" if offset["ttest"] < 0.01 else ""
	
	for type_result in results.values():
		offset0 = type_result["offset"][0]
		for offset in type_result["offset"].values():
			offset["reltime"] = offset["mean"] / offset0["mean"]

def report(results, label, out):
	out.write('===\n')
	out.write('=== %s\n' % label)
	out.write('===\n')
	for type_name in type_names:
		out.write('--- %s ---\n' % type_name)
		type_result = results[type_name]
		out.write("%3s\t%12s\t%12s\t%8s\t%12s\n" % ("Off", "rel time", "mean (us)", "stddev", "ttest pvalue"))
		for offset in type_result["offset"].values():
			out.write("%d\t%12f\t%12.2f\t%8.2f\t%12f%s\n" % (offset["val"], offset["reltime"], offset["mean"], offset["std"], offset["ttest"], offset["conclusion"]))


main()

e869717c4c5b594d8c54205d36251e163ce12e43
<mask token>


def main():
    global fill_results
    global sum_results
    global type_names
    for path in sys.argv[1:]:
        if os.path.basename(path).startswith('analyze'):
            continue
        fill_results = {}
        sum_results = {}
        type_names = []
        parse(path)
        analyze(fill_results)
        analyze(sum_results)
        out_path = os.path.join(os.path.dirname(path), os.path.basename(
            path).replace('measure', 'analyze'))
        out = open(out_path, 'w')
        report(fill_results, 'fill', out)
        report(sum_results, 'sum', out)
        out.close()


<mask token>


def append_results(results, type_name, offset, time):
    try:
        type_result = results[type_name]
    except:
        type_result = {'type_name': type_name, 'offset': {}}
        results[type_name] = type_result
    try:
        offset_time = type_result['offset'][offset]['time']
    except:
        offset_time = []
        type_result['offset'][offset] = {'val': offset, 'time': offset_time}
    offset_time.append(time)


<mask token>

<mask token>


def main():
    global fill_results
    global sum_results
    global type_names
    for path in sys.argv[1:]:
        if os.path.basename(path).startswith('analyze'):
            continue
        fill_results = {}
        sum_results = {}
        type_names = []
        parse(path)
        analyze(fill_results)
        analyze(sum_results)
        out_path = os.path.join(os.path.dirname(path), os.path.basename(
            path).replace('measure', 'analyze'))
        out = open(out_path, 'w')
        report(fill_results, 'fill', out)
        report(sum_results, 'sum', out)
        out.close()


def parse(path):
    for line in open(path):
        if line[0] == '#':
            continue
        fields = line.split()
        type_name = fields[0]
        offset = int(fields[1])
        fill_time = int(fields[-1])
        sum_time = int(fields[-2])
        append_results(fill_results, type_name, offset, fill_time)
        append_results(sum_results, type_name, offset, sum_time)
        if not len(type_names) or type_names[-1] != type_name:
            type_names.append(type_name)


def append_results(results, type_name, offset, time):
    try:
        type_result = results[type_name]
    except:
        type_result = {'type_name': type_name, 'offset': {}}
        results[type_name] = type_result
    try:
        offset_time = type_result['offset'][offset]['time']
    except:
        offset_time = []
        type_result['offset'][offset] = {'val': offset, 'time': offset_time}
    offset_time.append(time)


def analyze(results):
    for type_name, type_result in results.items():
        time0 = type_result['offset'][0]['time']
        for offset in type_result['offset'].values():
            time = offset['time']
            offset['mean'] = numpy.mean(time) / 1000
            offset['std'] = numpy.std(time) / 1000
            offset['ttest'] = scipy.stats.ttest_ind(time, time0, equal_var=
                False)[1]
            offset['conclusion'] = ' (a != b)' if offset['ttest'
                ] < 0.01 else ''
    for type_result in results.values():
        offset0 = type_result['offset'][0]
        for offset in type_result['offset'].values():
            offset['reltime'] = offset['mean'] / offset0['mean']


def report(results, label, out):
    out.write('===\n')
    out.write('=== %s\n' % label)
    out.write('===\n')
    for type_name in type_names:
        out.write('--- %s ---\n' % type_name)
        type_result = results[type_name]
        out.write('%3s\t%12s\t%12s\t%8s\t%12s\n' % ('Off', 'rel time',
            'mean (us)', 'stddev', 'ttest pvalue'))
        for offset in type_result['offset'].values():
            out.write('%d\t%12f\t%12.2f\t%8.2f\t%12f%s\n' % (offset['val'],
                offset['reltime'], offset['mean'], offset['std'], offset[
                'ttest'], offset['conclusion']))


<mask token>

<mask token>


def main():
    global fill_results
    global sum_results
    global type_names
    for path in sys.argv[1:]:
        if os.path.basename(path).startswith('analyze'):
            continue
        fill_results = {}
        sum_results = {}
        type_names = []
        parse(path)
        analyze(fill_results)
        analyze(sum_results)
        out_path = os.path.join(os.path.dirname(path), os.path.basename(
            path).replace('measure', 'analyze'))
        out = open(out_path, 'w')
        report(fill_results, 'fill', out)
        report(sum_results, 'sum', out)
        out.close()


def parse(path):
    for line in open(path):
        if line[0] == '#':
            continue
        fields = line.split()
        type_name = fields[0]
        offset = int(fields[1])
        fill_time = int(fields[-1])
        sum_time = int(fields[-2])
        append_results(fill_results, type_name, offset, fill_time)
        append_results(sum_results, type_name, offset, sum_time)
        if not len(type_names) or type_names[-1] != type_name:
            type_names.append(type_name)


def append_results(results, type_name, offset, time):
    try:
        type_result = results[type_name]
    except:
        type_result = {'type_name': type_name, 'offset': {}}
        results[type_name] = type_result
    try:
        offset_time = type_result['offset'][offset]['time']
    except:
        offset_time = []
        type_result['offset'][offset] = {'val': offset, 'time': offset_time}
    offset_time.append(time)


def analyze(results):
    for type_name, type_result in results.items():
        time0 = type_result['offset'][0]['time']
        for offset in type_result['offset'].values():
            time = offset['time']
            offset['mean'] = numpy.mean(time) / 1000
            offset['std'] = numpy.std(time) / 1000
            offset['ttest'] = scipy.stats.ttest_ind(time, time0, equal_var=
                False)[1]
            offset['conclusion'] = ' (a != b)' if offset['ttest'
                ] < 0.01 else ''
    for type_result in results.values():
        offset0 = type_result['offset'][0]
        for offset in type_result['offset'].values():
            offset['reltime'] = offset['mean'] / offset0['mean']


def report(results, label, out):
    out.write('===\n')
    out.write('=== %s\n' % label)
    out.write('===\n')
    for type_name in type_names:
        out.write('--- %s ---\n' % type_name)
        type_result = results[type_name]
        out.write('%3s\t%12s\t%12s\t%8s\t%12s\n' % ('Off', 'rel time',
            'mean (us)', 'stddev', 'ttest pvalue'))
        for offset in type_result['offset'].values():
            out.write('%d\t%12f\t%12.2f\t%8.2f\t%12f%s\n' % (offset['val'],
                offset['reltime'], offset['mean'], offset['std'], offset[
                'ttest'], offset['conclusion']))


main()

import fileinput
import numpy
import os.path
import scipy.stats
import sys


def main():
    global fill_results
    global sum_results
    global type_names
    for path in sys.argv[1:]:
        if os.path.basename(path).startswith('analyze'):
            continue
        fill_results = {}
        sum_results = {}
        type_names = []
        parse(path)
        analyze(fill_results)
        analyze(sum_results)
        out_path = os.path.join(os.path.dirname(path), os.path.basename(
            path).replace('measure', 'analyze'))
        out = open(out_path, 'w')
        report(fill_results, 'fill', out)
        report(sum_results, 'sum', out)
        out.close()


def parse(path):
    for line in open(path):
        if line[0] == '#':
            continue
        fields = line.split()
        type_name = fields[0]
        offset = int(fields[1])
        fill_time = int(fields[-1])
        sum_time = int(fields[-2])
        append_results(fill_results, type_name, offset, fill_time)
        append_results(sum_results, type_name, offset, sum_time)
        if not len(type_names) or type_names[-1] != type_name:
            type_names.append(type_name)


def append_results(results, type_name, offset, time):
    try:
        type_result = results[type_name]
    except:
        type_result = {'type_name': type_name, 'offset': {}}
        results[type_name] = type_result
    try:
        offset_time = type_result['offset'][offset]['time']
    except:
        offset_time = []
        type_result['offset'][offset] = {'val': offset, 'time': offset_time}
    offset_time.append(time)


def analyze(results):
    for type_name, type_result in results.items():
        time0 = type_result['offset'][0]['time']
        for offset in type_result['offset'].values():
            time = offset['time']
            offset['mean'] = numpy.mean(time) / 1000
            offset['std'] = numpy.std(time) / 1000
            offset['ttest'] = scipy.stats.ttest_ind(time, time0, equal_var=
                False)[1]
            offset['conclusion'] = ' (a != b)' if offset['ttest'
                ] < 0.01 else ''
    for type_result in results.values():
        offset0 = type_result['offset'][0]
        for offset in type_result['offset'].values():
            offset['reltime'] = offset['mean'] / offset0['mean']


def report(results, label, out):
    out.write('===\n')
    out.write('=== %s\n' % label)
    out.write('===\n')
    for type_name in type_names:
        out.write('--- %s ---\n' % type_name)
        type_result = results[type_name]
        out.write('%3s\t%12s\t%12s\t%8s\t%12s\n' % ('Off', 'rel time',
            'mean (us)', 'stddev', 'ttest pvalue'))
        for offset in type_result['offset'].values():
            out.write('%d\t%12f\t%12.2f\t%8.2f\t%12f%s\n' % (offset['val'],
                offset['reltime'], offset['mean'], offset['std'], offset[
                'ttest'], offset['conclusion']))


main()

#!/usr/bin/env python

import fileinput
import numpy
import os.path
import scipy.stats
import sys

def main():
	global fill_results
	global sum_results
	global type_names

	for path in sys.argv[1:]:
		if os.path.basename(path).startswith('analyze'):
			continue

		fill_results = {}
		sum_results = {}
		type_names = []

		parse(path)
		analyze(fill_results)
		analyze(sum_results)
		
		out_path = os.path.join(os.path.dirname(path), os.path.basename(path).replace('measure', 'analyze'))
		out = open(out_path, 'w')
		report(fill_results, 'fill', out)
		report(sum_results, 'sum', out)
		out.close()

def parse(path):
	for line in open(path):
		if line[0] == '#':
			continue
	
		fields = line.split()
		type_name = fields[0]
		offset = int(fields[1])
		fill_time = int(fields[-1])
		sum_time = int(fields[-2])
	
		append_results(fill_results, type_name, offset, fill_time)
		append_results(sum_results, type_name, offset, sum_time)

		if not len(type_names) or type_names[-1] != type_name:
			type_names.append(type_name)

def append_results(results, type_name, offset, time):
	try:
		type_result = results[type_name]
	except:
		type_result = {"type_name": type_name, "offset": {}}
		results[type_name] = type_result
	try:
		offset_time = type_result["offset"][offset]["time"]
	except:
		offset_time = []
		type_result["offset"][offset] = {"val": offset, "time": offset_time}
	offset_time.append(time)

def analyze(results):
	for type_name, type_result in results.items():
		time0 = type_result["offset"][0]["time"]
		for offset in type_result["offset"].values():
			time = offset["time"]
			offset["mean"] = numpy.mean(time) / 1000
			offset["std"] = numpy.std(time) / 1000
			offset["ttest"] = scipy.stats.ttest_ind(time, time0, equal_var = False)[1]
			offset["conclusion"] = " (a != b)" if offset["ttest"] < 0.01 else ""
	
	for type_result in results.values():
		offset0 = type_result["offset"][0]
		for offset in type_result["offset"].values():
			offset["reltime"] = offset["mean"] / offset0["mean"]

def report(results, label, out):
	out.write('===\n')
	out.write('=== %s\n' % label)
	out.write('===\n')
	for type_name in type_names:
		out.write('--- %s ---\n' % type_name)
		type_result = results[type_name]
		out.write("%3s\t%12s\t%12s\t%8s\t%12s\n" % ("Off", "rel time", "mean (us)", "stddev", "ttest pvalue"))
		for offset in type_result["offset"].values():
			out.write("%d\t%12f\t%12.2f\t%8.2f\t%12f%s\n" % (offset["val"], offset["reltime"], offset["mean"], offset["std"], offset["ttest"], offset["conclusion"]))


main()
