[软件测试] Assignment4

[软件测试]Assignment4

课程名称软件测试任课老师蔡国扬
年级大三专业(方向)计应
学号16340015姓名陈彬彬
专业(方向)软件工程(计应)Email944131226@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 表示程序中出现的语句个数

  1. 程序词汇表长度(Program vocabulary) : n = n 1 + n 2 n = n_1 + n_2 n=n1+n2
  2. 程序长度或简单长度(Program length): N = N 1 + N 2 N = N_1 + N_2 N=N1+N2
  3. 程序的预测长度(Calculated program length):KaTeX parse error: Expected group after '\textrm' at position 9: N\textrm^̲=n_1log_2n_1+n_…
  4. 程序体积或容量(Program volume): V = N l o g 2 ( n ) V = Nlog_2(n) V=Nlog2(n)
  5. 程序级别(Program level):KaTeX parse error: Expected group after '\textrm' at position 9: L\textrm^̲ = (2/n_1) \tim…
  6. 程序难度(Program difficulty):KaTeX parse error: Expected group after '\textrm' at position 9: D\textrm^̲ = 1 / L\textrm…
  7. 编程工作量(Effort):KaTeX parse error: Expected group after '\textrm' at position 23: …es D=V/L\textrm^̲
  8. 语言级别:KaTeX parse error: Expected group after '\textrm' at position 12: L'=L\textrm^̲\times L\textrm…
  9. 编程时间(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
  10. 平均语句大小: N ‾ = N / p \overline{N} = N/p N=N/p
  11. 程序中的错误数预测值: 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

OperatorNumber of Occurrences
if1
+=1
return1
+6
/4
<1
-1
dayray1
int1
*2
%1
n 1 = 11 n_1=11 n1=11 N 1 = 20 N_1=20 N1=20

3.2 Operand

OperandNumber of Occurrences
month3
31
121
year5
day1
11
261
101
41
61
1001
4001
71
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

  1. 程序词汇表长度: n = n 1 + n 2 = 11 + 13 = 24 n=n_1+n_2=11+13=24 n=n1+n2=11+13=24
  2. 程序长度: N = N 1 + N 2 = 20 + 19 = 39 N=N_1+N_2=20+19=39 N=N1+N2=20+19=39
  3. 程序预测长度:KaTeX parse error: Expected group after '\textrm' at position 9: N\textrm^̲=n_1log_2n_1+n_…
  4. 程序体积: 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
  5. 程序级别:KaTeX parse error: Expected group after '\textrm' at position 9: L\textrm^̲ = (2/n_1) \tim…
  6. 程序难度:KaTeX parse error: Expected group after '\textrm' at position 9: D\textrm^̲ = 1 / L\textrm…
  7. 编程工作量:KaTeX parse error: Expected group after '\textrm' at position 23: …es D=V/L\textrm^̲=178.8135/0.124…
  8. 语言级别:KaTeX parse error: Expected group after '\textrm' at position 12: L'=L\textrm^̲\times L\textrm…
  9. 编程时间:KaTeX parse error: Expected group after '\textrm' at position 9: T\textrm^̲=E/(s\times f)=…
  10. 平均语句大小: N ‾ = N / p = 39 / 4 = 9.75 \overline{N} = N/p=39/4=9.75 N=N/p=39/4=9.75
  11. 程序中的错误数预测值: 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
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
这段代码是上一段代码的测试代码 需要输出成功 #include "Assignment-3.h" #include "SVF-LLVM/LLVMUtil.h" #include "SVF-LLVM/SVFIRBuilder.h" #include "WPA/Andersen.h" #include "Util/Options.h" #include "Util/CommandLine.h" void Test1() { SVF::SVFModule *svfModule = SVF::LLVMModuleSet::getLLVMModuleSet()->buildSVFModule({"./Assignment-3/testcase/bc/no_alias.ll"}); /// Build Program Assignment Graph (SVFIR) SVF::SVFIRBuilder builder(svfModule); SVF::SVFIR *pag = builder.build(); pag->dump ("./Assignment-3/testcase/dot/no_alias_init"); AndersenPTA *andersenPTA = new AndersenPTA(pag); andersenPTA->analyze(); andersenPTA->dump_consCG("./Assignment-3/testcase/dot/no_alias_final"); delete andersenPTA; SVF::LLVMModuleSet::releaseLLVMModuleSet(); SVF::SVFIR::releaseSVFIR(); } void Test2() { SVF::SVFModule *svfModule = SVF::LLVMModuleSet::getLLVMModuleSet()->buildSVFModule({"./Assignment-3/testcase/bc/CI-global.ll"}); /// Build Program Assignment Graph (SVFIR) SVF::SVFIRBuilder builder(svfModule); SVF::SVFIR *pag = builder.build(); pag->dump ("./Assignment-3/testcase/dot/CI-global_init"); AndersenPTA *andersenPTA = new AndersenPTA(pag); andersenPTA->analyze(); andersenPTA->dump_consCG("./Assignment-3/testcase/dot/CI-global_final"); delete andersenPTA; SVF::SVFIR::releaseSVFIR(); SVF::LLVMModuleSet::releaseLLVMModuleSet(); } void Test3() { SVF::SVFModule *svfModule = SVF::LLVMModuleSet::getLLVMModuleSet()->buildSVFModule({"./Assignment-3/testcase/bc/CI-local.ll"}); /// Build Program Assignment Graph (SVFIR) SVF::SVFIRBuilder builder(svfModule); SVF::SVFIR *pag = builder.build(); pag->dump ("./Assignment-3/testcase/dot/CI-local_init"); AndersenPTA *andersenPTA = new AndersenPTA(pag); andersenPTA->analyze(); andersenPTA->dump_consCG("./Assignment-3/testcase/dot/CI-local_final"); SVF::LLVMModuleSet::releaseLLVMModuleSet(); SVF::SVFIR::releaseSVFIR(); delete andersenPTA; } void Test() { Test1(); Test2(); Test3(); } int main(int argc, char ** argv) { int arg_num = 0; int extraArgc = 1; char **arg_value = new char [argc + extraArgc]; for (; arg_num < argc; ++arg_num) { arg_value[arg_num] = argv[arg_num]; } // You may comment it to see the details of the analysis arg_value[arg_num++] = (char) "-stat=false"; std::vectorstd::string moduleNameVec; moduleNameVec = OptionBase::parseOptions( arg_num, arg_value, "Teaching-Software-Analysis Assignment 3", "[options]" ); Test(); return 0; }
05-22

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值