[软件测试]Assignment4
课程名称 | 软件测试 | 任课老师 | 蔡国扬 |
---|---|---|---|
年级 | 大三 | 专业(方向) | 计应 |
学号 | 16340015 | 姓名 | 陈彬彬 |
专业(方向) | 软件工程(计应) | 944131226@qq.com |
1.问题描述
计算下列代码片段的 Halstead
复杂度的11项内容:
if (month < 3) {
month += 12;
–year;
}
return dayray((int)(day + (month + 1) * 26/10 + year + year/4 + 6 * (year/100) + year/400)% 7);
2.Halstead复杂度11项内容
n 1 n_1 n1 表示程序中不同的操作符个数, n 2 n_2 n2 表示程序中不同的操作数个数
N 1 N_1 N1 表示程序中出现的操作符个数, N 2 N_2 N2 表示程序中出现的操作数个数
p p p 表示程序中出现的语句个数
- 程序词汇表长度(Program vocabulary) : n = n 1 + n 2 n = n_1 + n_2 n=n1+n2
- 程序长度或简单长度(Program length): N = N 1 + N 2 N = N_1 + N_2 N=N1+N2
- 程序的预测长度(Calculated program length):KaTeX parse error: Expected group after '\textrm' at position 9: N\textrm^̲=n_1log_2n_1+n_…
- 程序体积或容量(Program volume): V = N l o g 2 ( n ) V = Nlog_2(n) V=Nlog2(n)
- 程序级别(Program level):KaTeX parse error: Expected group after '\textrm' at position 9: L\textrm^̲ = (2/n_1) \tim…
- 程序难度(Program difficulty):KaTeX parse error: Expected group after '\textrm' at position 9: D\textrm^̲ = 1 / L\textrm…
- 编程工作量(Effort):KaTeX parse error: Expected group after '\textrm' at position 23: …es D=V/L\textrm^̲
- 语言级别:KaTeX parse error: Expected group after '\textrm' at position 12: L'=L\textrm^̲\times L\textrm…
- 编程时间(hours):KaTeX parse error: Expected group after '\textrm' at position 9: T\textrm^̲=E/(s\times f) ,这里 s = 60 × 60 s=60\times 60 s=60×60, f = 18 f=18 f=18
- 平均语句大小: N ‾ = N / p \overline{N} = N/p N=N/p
- 程序中的错误数预测值: B = V / 3000 = N l o g 2 ( n ) / 3000 B=V/3000=Nlog_2(n)/3000 B=V/3000=Nlog2(n)/3000
3.问题解答
3.1 Operator
Operator | Number of Occurrences |
---|---|
if | 1 |
+= | 1 |
return | 1 |
+ | 6 |
/ | 4 |
< | 1 |
- | 1 |
dayray | 1 |
int | 1 |
* | 2 |
% | 1 |
n 1 = 11 n_1=11 n1=11 | N 1 = 20 N_1=20 N1=20 |
3.2 Operand
Operand | Number of Occurrences |
---|---|
month | 3 |
3 | 1 |
12 | 1 |
year | 5 |
day | 1 |
1 | 1 |
26 | 1 |
10 | 1 |
4 | 1 |
6 | 1 |
100 | 1 |
400 | 1 |
7 | 1 |
n 2 = 13 n_2=13 n2=13 | N 2 = 19 N_2=19 N2=19 |
3.3 Complexity Calculate
n 1 = 11 n_1=11 n1=11, N 1 = 20 N_1=20 N1=20, n 2 = 13 n_2=13 n2=13, N 2 = 19 N_2=19 N2=19, p = 4 p=4 p=4
- 程序词汇表长度: n = n 1 + n 2 = 11 + 13 = 24 n=n_1+n_2=11+13=24 n=n1+n2=11+13=24
- 程序长度: N = N 1 + N 2 = 20 + 19 = 39 N=N_1+N_2=20+19=39 N=N1+N2=20+19=39
- 程序预测长度:KaTeX parse error: Expected group after '\textrm' at position 9: N\textrm^̲=n_1log_2n_1+n_…
- 程序体积: V = N l o g 2 ( n ) = 39 l o g 2 ( 24 ) = 178.8135 V = Nlog_2(n)=39log_2(24)=178.8135 V=Nlog2(n)=39log2(24)=178.8135
- 程序级别:KaTeX parse error: Expected group after '\textrm' at position 9: L\textrm^̲ = (2/n_1) \tim…
- 程序难度:KaTeX parse error: Expected group after '\textrm' at position 9: D\textrm^̲ = 1 / L\textrm…
- 编程工作量:KaTeX parse error: Expected group after '\textrm' at position 23: …es D=V/L\textrm^̲=178.8135/0.124…
- 语言级别:KaTeX parse error: Expected group after '\textrm' at position 12: L'=L\textrm^̲\times L\textrm…
- 编程时间:KaTeX parse error: Expected group after '\textrm' at position 9: T\textrm^̲=E/(s\times f)=…
- 平均语句大小: N ‾ = N / p = 39 / 4 = 9.75 \overline{N} = N/p=39/4=9.75 N=N/p=39/4=9.75
- 程序中的错误数预测值: B = V / 3000 = N l o g 2 ( n ) / 3000 = 178.8135 / 3000 = 0.05960 B=V/3000=Nlog_2(n)/3000=178.8135/3000=0.05960 B=V/3000=Nlog2(n)/3000=178.8135/3000=0.05960