prefetchers = Config('user', ['--prefetcher=on_access=true:policy=proxy'])

# Tests to run
tests = spec_configs
#tests = spec_configs[:2]

configs = cross(tests, prefetchers)

# Run tests
os.chdir(os.path.dirname(__file__))
os.environ['M5_CPU2000'] = 'lib/cpu2000'
run_configs(configs)

# Read statistics
stats.BASELINE_PF = 'none'
pf_stats = stats.read_stats(*glob.glob('lib/stats/*_1e7'))

pf_stats.update(stats.build_stats('output'))

# Write statistics
stats_file = open('stats.txt', 'w')
def save_stats(pf, test, echo):
    table = stats.format_stats(pf_stats, pf, test)
    stats_file.write(table)
    if echo:
        print table

# Prefetcher comparison for each test
for test in sorted(pf_stats['user']):
    save_stats('all', test, False)
# User prefetcher results.
prefetchers = Config('user', ['--prefetcher=on_access=true:policy=proxy'])

# Tests to run
tests = spec_configs
#tests = spec_configs[:2]

configs = cross(tests, prefetchers)

# Run tests
os.chdir(os.path.dirname(os.path.abspath(__file__)))
os.environ['M5_CPU2000'] = 'lib/cpu2000'
run_configs(configs)

# Read statistics
stats.BASELINE_PF = 'none'
pf_stats = stats.read_stats(*glob.glob('lib/stats/*_1e7'))

pf_stats.update(stats.build_stats('output'))

# Write statistics
stats_file = open('stats.txt', 'w')


def save_stats(pf, test, echo):
    table = stats.format_stats(pf_stats, pf, test)
    stats_file.write(table)
    if echo:
        print table


# Prefetcher comparison for each test
# Tests to run
#tests = spec_configs
#tests = spec_configs[:2]
tests = spec_configs[-3]

configs = cross(tests, prefetchers)

# Run tests
os.chdir(homeDir)
os.environ['M5_CPU2000'] = homeDir + '/data/cpu2000'
run_configs(configs)

# Read statistics
stats.BASELINE_PF = 'none'
pf_stats = stats.read_stats(*glob.glob(frameDir + '/lib/stats/*_1e7'))

pf_stats.update(stats.build_stats(homeDir + '/output'))

# Write statistics
stats_file = open(homeDir + '/stats.txt', 'w')


def save_stats(pf, test, echo):
    table = stats.format_stats(pf_stats, pf, test)
    stats_file.write(table)
    if echo:
        print table


# Prefetcher comparison for each test