一.GitHub地址
二.PSP表格
|
PSP2.1 |
PSP阶段 |
预估耗时 (分钟) |
实际耗时 (分钟) |
|
Planning |
计划 |
30 |
20 |
|
· Estimate |
· 估计这个任务需要多少时间 |
30 |
20 |
|
Development |
开发 |
470 |
550 |
|
· Analysis |
· 需求分析 (包括学习新技术) |
30 |
20 |
|
· Design Spec |
· 生成设计文档 |
20 |
20 |
|
· Design Review |
· 设计复审 (和同事审核设计文档) |
30 |
20 |
|
· Coding Standard |
· 代码规范 (为目前的开发制定合适的规范) |
30 |
30 |
|
· Design |
· 具体设计 |
30 |
40 |
|
· Coding |
· 具体编码 |
180 |
240 |
|
· Code Review |
· 代码复审 |
30 |
30 |
|
· Test |
· 测试(自我测试,修改代码,提交修改) |
120 |
150 |
|
Reporting |
报告 |
90 |
90 |
|
· Test Report |
· 测试报告 |
30 |
30 |
|
· Size Measurement |
· 计算工作量 |
30 |
30 |
|
· Postmortem & Process Improvement Plan |
· 事后总结, 并提出过程改进计划 |
30 |
30 |
|
|
合计 |
590 |
660 |
三.模块编写/接口测试
我负责了输出控制模块,实现过程是通过遍历map的list数组,获得每个元素的value和key,并加入到字符串result中,最后将字符串输出到“result.txt文件”,总的来说过程很简单,只是要注意最后输出的最后一行不换行,这里就需要在遍历的时候检查是否是最后一行。整个代码如下:
public class OutputFile {
public void outPut(List<Map.Entry<String,Integer>> res) throws IOException
{
String result = ""; //输出到文件的内容
//遍历map的list数组并按照指定格式加入到result中
for(int index = 0;index<res.size();index++){
result += res.get(index).getKey()+" "+res.get(index).getValue();
if(index != res.size()-1){
result +="\r\n"; //除了最后一个单词的词频不加换行符其他都要加
}
}
File f = null;
FileWriter file = null;
try{
f = new File("result.txt");//打开名为result的文件
file = new FileWriter(f);
file.write(result);//写入到指定文件
}
catch(Exception e){
System.out.println(e);
}
finally{
file.close();//关闭文件流
}
}
}
四.测试用例设计
创建了个OutPutFileTest类,在@Test标签下的测试函数中只负责加入数据和测试,在@before中初始化全局化变量,同时写了个testTwoResult方法,此方法在每个测试函数中都有调用。对于测试数据,输入不用关心是否排序,因为这不属于自己的模块,自己只关心按照输入顺序遍历输出,并采用指定格式即可。在输入数据设计上随意即可。相关函数如下:
void testTwoResult() throws IOException{
res=new ArrayList<Map.Entry<String,Integer>>(m.entrySet());
test.outPut(res);
InputStream file = new FileInputStream("result.txt");
int ch = file.read();
while(ch != -1){
fileResult += (char)ch;
ch = file.read();
}
file.close();
assertEquals(supposedResult,fileResult);
}
@Before
public void setUp() throws Exception {
m = new LinkedHashMap<String,Integer>();
test = new OutputFile();
}
@Test
public void testOutPut1() throws IOException {
m.put("as", 1);
m.put("xiha", 3);
supposedResult = "as 1\r\nxiha 3";
testTwoResult();
}
@Test
public void testOutPut2() throws IOException {
m.put("as", 1);
supposedResult = "as 1";
testTwoResult();
}
测试用例清单部分如图:

五.单元测试运行截图

如图,测试均是通过了的
六.静态测试
PMD静态检测工具相关地址https://blog.csdn.net/sadamdiyi/article/details/6073694
通过用PMD检测工具对17003代码做静态检测,发现了如下问题:
1.方法名最好不要用大写字母开头
2.用于控制for循环的变量使用了i,不容易看出变量的含义;
3.注释不够详细,比如for循环的作用和文件具体输出部分没有注释解释
七.性能测试与优化
我们小组针对词频统计性能讨论,得出如下结论:认为主要性能制约因素是:词频统计模块。
和读取文件,存入map的模块。
因为这涉及到文件的输入流,要逐行读取,分别处理。
这就耗费了很大时间,尤其是文件规模很大的情况

数据集大小大概是1Mkb
八.小组贡献
本次我所负责模块工程量小,所以贡献评分为0.22,小组其他成员所做的比我多,理当评分高点。
来源:https://www.cnblogs.com/ldisbest/p/8743300.html