这台模拟器复现了三条结论

👁️ 1 人浏览 💬 0 人评论 ❤️ 添加收藏

运行下面这段程序,填写它打印出来的结果。

STAGES = 5
FLUSH = 3

def pipelined(n):
    return n + STAGES - 1

def wrong_guesses(pattern):
    last = -1
    wrong = 0
    for t in pattern:
        if last == -1 or t != last:
            wrong = wrong + 1
        last = t
    return wrong
BLK = 4
LINES = 4

def cache(addrs):
    tags = [-1] * LINES
    hit = 0
    miss = 0
    for a in addrs:
        b = a // BLK
        line = b % LINES
        if tags[line] == b:
            hit = hit + 1
        else:
            miss = miss + 1
            tags[line] = b
    return hit, miss

a = round(10 * STAGES / pipelined(10), 2)
b = cache(list(range(32)) * 2)[1]
c = pipelined(16) + wrong_guesses([1, 0] * 8) * FLUSH
print(str(a) + "/" + str(b) + "/" + str(c))
提交你的答案
请登录后提交答案。
去登录
代码编辑器
Ctrl + Enter 运行
本次输入:
输出:

                        
👩‍🏫
AI
💬 题目评论

全部评论