EE308_Lab2
| The Link Your Class | https://bbs.csdn.net/forums/MUEE308FZ |
| The Link of Requirement of This Assignment | https://bbs.csdn.net/topics/600798588 |
| The Aim of This Assignment | Code personally & learn git and github & learn the process of writing a project & learn unit test and performance test |
| MU STU ID and FZU STU ID | 19104740_831901308 |
Github code
https://github.com/JoeyLee0111/Lab2.git
PSP Form
| Personal Software Process Stages | Estimated Time/minutes | Completed Time/minutes |
|---|---|---|
| Planning | 10 | 10 |
| Estimate | 10 | 10 |
| Analysis | 60 | 100 |
| Design Spec | 40 | 40 |
| Design Review | 30 | 30 |
| Coding Standard | 30 | 30 |
| Design | 60 | 60 |
| Coding | 500 | 600 |
| Code Review Planning | 60 | 60 |
| Test | 90 | 120 |
| Test Report | 60 | 100 |
| Postmortem&Process Improvement | 120 | 120 |
| Total | 1070 | 1280 |
Logic Design
Main thinking.

First step

Second step

Third step
Fourth step

Fifth step

Process (with Code)(It's been optimized)
First, we need to get plain text.
def get_text():
file = open("text.c", "r", encoding="UTF-8") #Ensure normal opening
text = file.read()
for i in '!#$%&()+,-.:;<=>?@[\\]^_{|}~': # Remove the punctuation
text = text.replace(i, " ")
file.close()
return text
Second, we need to filt some characters and add into the list to make the next four steps easier.
def filting():
text = get_text().replace("else if", "elseif")
separator_word = [r'//.*', r'\/\*(?:[^\*]|\*+[^\/\*])*\*+\/', r'".*"'] # Remove // , / and '
for i in separator_word:
wordlist1 = re.split(i, text)
text = ""
for word in wordlist1:
text = text + word
wordlist1 = text.split()
return wordlist1
Third, I used the traversal way to search keywords. It's a very simple solution to the first problem. Also, this method also works well for the next problem.
Fourth, I used two lists to solve this question and that'll make it more clearer.
def first_second_question(): # Number of output keywords.
words = filting()
keyWords = {"auto", "break", "case", "char", "const",
"continue", "default", "do", "double", "else",
"enum", "extern", "float", "for", "goto",
"if", "int", "long", "register", "return",
"short", "signed", "sizeof", "static", "struct",
"switch", "typedef", "union", "unsigned",
"void", "volatile", "while", "elseif"}
number = 0
fWords = []
counts1 = {}
for word in words:
if len(word) == 1 or (word not in keyWords):
continue
counts1[word] = counts1.get(word, 0) + 1
fWords.append(word)
number = number + 1
number = number + counts1.get("elseif", 0)
print("total num: {}".format(number))
num = counts1.get("switch", 0)
print("switch num: {}".format(num))
if num == 0:
print("case num: {}".format(num))
return
list2 = []
flag = -1
for word in words:
if word == "switch":
list2.append(0)
flag += 1
elif word == "case":
list2[flag] += 1
else:
continue
print("case num: ", end="")
print(" ".join(str(x) for x in list2))
return fWords
Fifth, I also used the traversal way to search keywords. Thinking over, I find that Q3 and Q4 can be solved together.The differences between them is else and elseif. By the 'if' , I got the result.
def three_fourth_question():
fWords=first_second_question()
listf = []
num_if_else = 0
num_if_elseif_else = 0
for word in fWords:
if word == "if":
listf.append(word)
elif word == "elseif" and listf[-1] != "elseif":
listf.append(word)
elif word == "else":
if listf[-1] == "elseif":
listf.pop()
listf.pop()
num_if_elseif_else += 1
elif listf[-1] == "if":
listf.pop()
num_if_else += 1
print("if-else num: {}".format(num_if_else))
print("if-elseif-else num: {}".format(num_if_elseif_else))
return
Run Result

Unit Test
import timeit
def fun():
for i in range(100000):
a = i * i
print(timeit.timeit('fun()', 'from __main__ import fun', number=1))
import profile
def fun():
for i in range(100000):
a = i * i
print(profile.run('fun()'))
Optimization
I put all the code that was outside the method inside the method, and the average speed increased by more than 0.003 seconds.
Summary
We studied Python in the first semester of freshman year. This lab is not difficult in the code part. I think the difficult parts are optimization and unit test. Though I tried to make code run quickly, I never do so carefully about every detail.
I learned how to use Github when I was learning Java. So it can save my time and I can improve my code.
I major in Electronic Engineering. The learning is more about hardware. I hope learn more knowleage about software by this course.
相关推荐
EE-308 LAB4 final version.7z
这是本次实验的压缩包
地方工信局想通过技术转移联合体推动产业升级,推荐哪种合作模式?.docx
科易网(厦门科易网科技有限公司)创立于2007年,是技术转移与科技创新数智化服务平台,拥有国家科技成果转化服务示范基地、国家技术转移示范机构等资质。平台以“AI+科技成果转化”为核心,整合成果、专利、专家、政策等多维数据,构建知识图谱与科创智能体,面向企业、政府、高校院所提供成果转化、技术需求对接、产业服务等数智化解决方案。截至目前,已服务全国企业超43万家,推动落地项目11800余项,总金额逾80亿元
Strata + Three.js 本地多模态大模型3D场景生成实战源码(含三个版本、测试及提示词)
本资源为《本地大模型能看图修 Bug 吗?Strata + Three.js 三维场景生成与多模态视觉反馈实战》配套教学源码。 使用 Strata、DeepSeek Harness 和本地 Qwen3.8 Flash Next IQ3_S 模型,完成 Three.js 日式樱花庭院的三个开发版本: - v0.1:纯文字自主生成,17项独立自动化测试通过。 - v0.2:人工文字反馈优化,20项独立自动化测试通过。 - v0.3:多模态视觉反馈修复,23项独立自动化测试及6项人工视觉验收通过。 资源包含三个版本完整工程源码、自动化测试、五阶段实验提示词、真实渲染截图、版本对照图、历史验收记录、Python 本地静态服务器及 SHA256 校验工具。 场景完全采用程序化建模,不依赖外部三维模型或图片纹理。使用 Three.js 0.187.0,无需 Vite、Webpack 等构建工具。 运行已经生成的场景不需要安装 Strata,也不需要高性能大模型推理显卡。安装 Node.js、Three.js 依赖及 Python 后即可体验。 适合学习 Three.js、WebGL、程序化建模、本地大模型、多模态视觉理解、AI Coding Agent 和独立工程验收。 资源不包含大模型权重及 node_modules。实验结果为历史实测记录,自动化测试通过不代表所有视觉效果及几何关系均已得到完整验证。
新产品导入正式文件.doc
技术分享
FreeRTOS 软件定时器实战:STM32 守护任务、命令队列与回调阻塞排查
这份教程解决 STM32 FreeRTOS 工程里"软件定时器回调阻塞导致全体停摆、命令队列打满导致启动失败"的问题。基于 F103C8T6 + FreeRTOS V10.4.6,从守护任务 Tmr Svc 与 SysTick 时基讲起,逐项给出 configTIMER 三宏配置、xTimerCreate/Start 与 FromISR 全链路代码,并用实测数据回答精度调优:守护任务优先级 1→5 后回调平均延迟 +2.1ms 收敛到 +0.1ms、最大抖动 8.4ms 降到 0.4ms;命令队列 5→20 后中断高频重置失败率 2.3% 降为 0。含 6 类故障排查链与可勾选验收清单。


