finish 2025-11-21 ppt
This commit is contained in:
259
2025-11-21/slides_component/figures.typ
Normal file
259
2025-11-21/slides_component/figures.typ
Normal file
@@ -0,0 +1,259 @@
|
||||
#let serial_timeline() = {
|
||||
let cpu-color = blue.lighten(70%)
|
||||
let io-color = green.lighten(70%)
|
||||
let bar-height = 40pt
|
||||
|
||||
// 使用一个水平堆叠来放置时间块
|
||||
stack(
|
||||
dir: ltr, // 布局方向:从左到右
|
||||
spacing: 0pt, // 块之间没有间隔
|
||||
|
||||
// 第一个 CPU 时间片
|
||||
rect(
|
||||
width: 3cm,
|
||||
height: bar-height,
|
||||
fill: cpu-color,
|
||||
stroke: black,
|
||||
align(center, "CPU 1")
|
||||
),
|
||||
|
||||
// 第一个 I/O 等待
|
||||
rect(
|
||||
width: 6cm,
|
||||
height: bar-height,
|
||||
fill: io-color,
|
||||
stroke: black,
|
||||
align(center, "I/O 1")
|
||||
),
|
||||
|
||||
// 第二个 CPU 时间片
|
||||
rect(
|
||||
width: 3cm,
|
||||
height: bar-height,
|
||||
fill: cpu-color,
|
||||
stroke: black,
|
||||
align(center, "CPU 2")
|
||||
),
|
||||
|
||||
// 第二个 I/O 等待
|
||||
rect(
|
||||
width: 6cm,
|
||||
height: bar-height,
|
||||
fill: io-color,
|
||||
stroke: black,
|
||||
align(center, "I/O 2")
|
||||
),
|
||||
// 示意后续
|
||||
rect(
|
||||
width: 2cm,
|
||||
height: bar-height,
|
||||
fill: gray.lighten(80%),
|
||||
stroke: black,
|
||||
align(center, "...")
|
||||
)
|
||||
)
|
||||
|
||||
// 添加时间轴标签
|
||||
align(center, [
|
||||
#pad(top: 8pt, text("串行化的计算与处理"))
|
||||
])
|
||||
}
|
||||
|
||||
#let batched_timeline() = {
|
||||
let cpu-color = blue.lighten(70%)
|
||||
let io-color = green.lighten(70%)
|
||||
let bar-height = 40pt
|
||||
|
||||
// 使用一个水平堆叠来放置时间块
|
||||
stack(
|
||||
dir: ltr, // 布局方向:从左到右
|
||||
spacing: 0pt, // 块之间没有间隔
|
||||
|
||||
// 第一个 CPU 时间片
|
||||
rect(
|
||||
width: 3cm,
|
||||
height: bar-height,
|
||||
fill: cpu-color,
|
||||
stroke: black,
|
||||
align(center, "CPU 1")
|
||||
),
|
||||
// 第二个 CPU 时间片
|
||||
rect(
|
||||
width: 3cm,
|
||||
height: bar-height,
|
||||
fill: cpu-color,
|
||||
stroke: black,
|
||||
align(center, "CPU 2")
|
||||
),
|
||||
// 第三个 CPU 时间片
|
||||
rect(
|
||||
width: 3cm,
|
||||
height: bar-height,
|
||||
fill: cpu-color,
|
||||
stroke: black,
|
||||
align(center, "CPU 3")
|
||||
),
|
||||
|
||||
// 第一个 I/O 等待
|
||||
rect(
|
||||
width: 6cm,
|
||||
height: bar-height,
|
||||
fill: io-color,
|
||||
stroke: black,
|
||||
align(center, "I/O 1")
|
||||
),
|
||||
|
||||
// 示意后续
|
||||
rect(
|
||||
width: 2cm,
|
||||
height: bar-height,
|
||||
fill: gray.lighten(80%),
|
||||
stroke: black,
|
||||
align(center, "...")
|
||||
)
|
||||
)
|
||||
|
||||
// 添加时间轴标签
|
||||
align(center, [
|
||||
#pad(top: 8pt, text("批次化的计算与传输"))
|
||||
])
|
||||
}
|
||||
|
||||
#let async_timeline() = {
|
||||
let cpu-color = blue.lighten(70%)
|
||||
let io-color = green.lighten(70%)
|
||||
let bar-height = 40pt
|
||||
let max-width = 18cm // 定义一个固定的最大宽度
|
||||
|
||||
// 1. 使用 box 容器定义固定宽度,并让内部元素对齐到左侧
|
||||
box(width: max-width, {
|
||||
align(left, {
|
||||
// 过程 1 (P1)
|
||||
stack(
|
||||
dir: ltr, // 布局方向:从左到右
|
||||
spacing: 0pt, // 块之间没有间隔
|
||||
|
||||
// 第一个 CPU 时间片
|
||||
rect(
|
||||
width: 3cm,
|
||||
height: bar-height,
|
||||
fill: cpu-color,
|
||||
stroke: black,
|
||||
align(center, "CPU 1")
|
||||
),
|
||||
// 第一个 I/O 等待
|
||||
rect(
|
||||
width: 6cm,
|
||||
height: bar-height,
|
||||
fill: io-color,
|
||||
stroke: black,
|
||||
align(center, "I/O 1")
|
||||
),
|
||||
// 第四个 CPU 时间片
|
||||
rect(
|
||||
width: 3cm,
|
||||
height: bar-height,
|
||||
fill: cpu-color,
|
||||
stroke: black,
|
||||
align(center, "CPU 4")
|
||||
),
|
||||
// 示意后续
|
||||
rect(
|
||||
width: 2cm,
|
||||
height: bar-height,
|
||||
fill: gray.lighten(80%),
|
||||
stroke: black,
|
||||
align(center, "...")
|
||||
)
|
||||
)
|
||||
// 过程 2 (P2)
|
||||
stack(
|
||||
dir: ltr, // 布局方向:从左到右
|
||||
spacing: 0pt, // 块之间没有间隔
|
||||
|
||||
// 占位符 (已完成/占用时间),用于错位对齐
|
||||
rect(
|
||||
width: 3cm,
|
||||
height: bar-height,
|
||||
fill: white, // 改为白色以匹配截图视觉效果
|
||||
stroke: black,
|
||||
align(center, "")
|
||||
),
|
||||
// 第二个 CPU 时间片
|
||||
rect(
|
||||
width: 3cm,
|
||||
height: bar-height,
|
||||
fill: cpu-color,
|
||||
stroke: black,
|
||||
align(center, "CPU 2")
|
||||
),
|
||||
// 第二个 I/O 等待
|
||||
rect(
|
||||
width: 6cm,
|
||||
height: bar-height,
|
||||
fill: io-color,
|
||||
stroke: black,
|
||||
align(center, "I/O 2")
|
||||
),
|
||||
// 示意后续
|
||||
rect(
|
||||
width: 2cm,
|
||||
height: bar-height,
|
||||
fill: gray.lighten(80%),
|
||||
stroke: black,
|
||||
align(center, "...")
|
||||
)
|
||||
)
|
||||
// 过程 3 (P3)
|
||||
stack(
|
||||
dir: ltr, // 布局方向:从左到右
|
||||
spacing: 0pt, // 块之间没有间隔
|
||||
// 占位符 1
|
||||
rect(
|
||||
width: 3cm,
|
||||
height: bar-height,
|
||||
fill: white,
|
||||
stroke: black,
|
||||
align(center, "")
|
||||
),
|
||||
// 占位符 2
|
||||
rect(
|
||||
width: 3cm,
|
||||
height: bar-height,
|
||||
fill: white,
|
||||
stroke: black,
|
||||
align(center, "")
|
||||
),
|
||||
// 第三个 CPU 时间片
|
||||
rect(
|
||||
width: 3cm,
|
||||
height: bar-height,
|
||||
fill: cpu-color,
|
||||
stroke: black,
|
||||
align(center, "CPU 3")
|
||||
),
|
||||
// 第三个 I/O 等待
|
||||
rect(
|
||||
width: 6cm,
|
||||
height: bar-height,
|
||||
fill: io-color,
|
||||
stroke: black,
|
||||
align(center, "I/O 3")
|
||||
),
|
||||
// 示意后续
|
||||
rect(
|
||||
width: 2cm,
|
||||
height: bar-height,
|
||||
fill: gray.lighten(80%),
|
||||
stroke: black,
|
||||
align(center, "...")
|
||||
)
|
||||
)
|
||||
|
||||
// 添加时间轴标签
|
||||
align(center, [
|
||||
#pad(top: 8pt, text("异步化的计算与传输"))
|
||||
])
|
||||
})
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user