Example #1
0
    else:
        allow_print = False
    problem_c(cache, allow_print)
print cache.getCacheTable()
print 'miss(c): %f' % (cache.getMissRate() * 100), '%'

#Problem D
print("\n\n############ Part D ############\n")
cache = SetAssociativeCache(2, 4, 2, 16)
for i in range(100):
    if (i < 2):
        allow_print = True
        print "\nLoop %s" % (i, )
    else:
        allow_print = False
    problem_d(cache, allow_print)
print cache.getCacheTable()
print 'miss(d): %f' % (cache.getMissRate() * 100), '%'

#Problem E
print("\n\n############ Part E ############\n")
cache = FullAssociativeCache(16, 1, 16)
for i in range(100):
    if (i < 2):
        allow_print = True
        print "\nLoop %s" % (i, )
    else:
        allow_print = False
    problem_e(cache, allow_print)
print cache.getCacheTable()
print 'miss(e): %f' % (cache.getMissRate() * 100), '%'
Example #2
0
    else:
        allow_print = False
    problem_c(cache, allow_print)
print cache.getCacheTable()
print 'miss(c): %f'% (cache.getMissRate() * 100), '%'

#Problem D
print("\n\n############ Part D ############\n")
cache = SetAssociativeCache(2, 4, 2, 16)
for i in range(100):
    if(i < 2):
        allow_print = True
        print "\nLoop %s" %(i,)
    else:
        allow_print = False
    problem_d(cache, allow_print)
print cache.getCacheTable()
print 'miss(d): %f'% (cache.getMissRate() * 100), '%'

#Problem E
print("\n\n############ Part E ############\n")
cache = FullAssociativeCache(16, 1, 16)
for i in range(100):
    if(i < 2):
        allow_print = True
        print "\nLoop %s" %(i,)
    else:
        allow_print = False
    problem_e(cache, allow_print)
print cache.getCacheTable()
print 'miss(e): %f'% (cache.getMissRate() * 100), '%'
from cache.DirectMappingCache import DirectMappingCache
from cache.SetAssociativeCache import SetAssociativeCache
from cache.FullAssociativeCache import FullAssociativeCache

#Problem B
cache = DirectMappingCache(16, 1, 16)
for i in range(100):
    problem_b(cache)
print cache.getCacheTable()
print 'miss(b): %f'% (cache.getMissRate() * 100), '%'

#Problem C
cache = DirectMappingCache(8, 2, 16)
for i in range(100):
    problem_c(cache)
print cache.getCacheTable()
print 'miss(c): %f'% (cache.getMissRate() * 100), '%'

#Problem D
cache = SetAssociativeCache(2, 4, 2, 16)
for i in range(100):
    problem_d(cache)
print cache.getCacheTable()
print 'miss(d): %f'% (cache.getMissRate() * 100), '%'

#Problem E
cache = FullAssociativeCache(16, 1, 16)
for i in range(100):
    problem_e(cache)
print cache.getCacheTable()
print 'miss(e): %f'% (cache.getMissRate() * 100), '%'
Example #4
0
from cache.DirectMappingCache import DirectMappingCache
from cache.SetAssociativeCache import SetAssociativeCache
from cache.FullAssociativeCache import FullAssociativeCache

#Problem B
cache = DirectMappingCache(16, 1, 16)
for i in range(100):
    problem_b(cache)
print cache.getCacheTable()
print 'miss(b): %f' % (cache.getMissRate() * 100), '%'

#Problem C
cache = DirectMappingCache(8, 2, 16)
for i in range(100):
    problem_c(cache)
print cache.getCacheTable()
print 'miss(c): %f' % (cache.getMissRate() * 100), '%'

#Problem D
cache = SetAssociativeCache(2, 4, 2, 16)
for i in range(100):
    problem_d(cache)
print cache.getCacheTable()
print 'miss(d): %f' % (cache.getMissRate() * 100), '%'

#Problem E
cache = FullAssociativeCache(16, 1, 16)
for i in range(100):
    problem_e(cache)
print cache.getCacheTable()
print 'miss(e): %f' % (cache.getMissRate() * 100), '%'