功能单元最大扇入扇出工具分析

文档名称:功能单元最大扇入扇出工具分析

作 者: 日 期:

1. 概念

由于度量的目标是C 源代码,所以“功能单元的最大扇入扇出”的含义如下: 功能单元:c 语言的函数。

扇入:有多少其他函数调用了A 函数。

扇出:A 函数调用了多少其他函数。

2 cFlow

2.1 工具简介

GNU 计划,又称革奴计划,是由Richard Stallman在1983年9月27日公开发起的。它的目标是创建一套完全自由的操作系统。Richard Stallman 最早是在net.unix-wizards 新闻组上公布该消息,并附带一份《GNU 宣言》等解释为何发起该计划的文章,其中一个理由就是 要“重现当年软件界合作互助的团结精神”。为保证GNU 软件可以自由地“使用、复制、修改和发布”,所有GNU 软件都在一份在禁止其他人添加任何限制的情 况下授权所有权利给任何人的协议条款,GNU 通用公共许可证(GNU General Public License,GPL )。即“反版权”(或称Copyleft )概念。

2.2 工具优缺点总结

cflow 程序会输出一个函数调用树,这是一个显示函数调用关系的图表。这对于查看程序结构来了解他是如何操作的以及了解对于一个函数有哪些影响是十分有用的。一些版本的cflow 可以同时作用于目标文件与源代码。查看手册页我们可以了解更为详细的操作。

GNU 官方的一个工具,最大的优点是成熟、可靠。

但源代码比较难读懂。GNU 的东西,封装性、技巧性比较强。

2.3 使用例程

1. 下载源代码

2. 解压

3. ./configure

4. make

5. make install

6. cflow tes.c

main() :

printf()

do_something_firstly() : malloc()

free()

do_something_finally() : printf()

7. 输出结果

2.4 核心代码抽取

通过此工具的源代码,可以获取匹配函数定义语句的功能,函数调用关系的功能,从来实现fan-in ,fan-out 度量。

3 C and C++ Code Counter

3.1 工具简介

3.2 工具优缺点总结

功能强大,基本能够进行所有的静态度量。支持c 语言。 缺点:源代码比较复杂,研读需要时间。

并不支持函数的扇入扇出。

4.3 实例

1. 实例代码:

#include

/*test example*/

int f1()

{

int a=1,b=2;

if (a==1)

a=4;

else

{

if (b==2)

{

a=4;

}

}

return 1;

}

int f2()

{

return 1;

}

int f3()

{

f1();

f2();

return 1;

}

main()

{

int a=10;

f1();

f2();

f3();

}

2. 安装cccc

官方网站下载安装文件

3. 执行度量

4. 查看结果

F3调用了f1,f2,但度量结果,并没有反应出来。

4.4 分析

扇出扇出的分析:

Fan-In, Fan-Out (FI,FIc,FIv,FO,FOc,FOv)

Traditionally, use relationships between modules were identified by counting function invocations or access to module data in procedural code. CCCC identifies relationships only through

structures apparent in the definitions of the interfaces of C++ classes or Java classes or interfaces. The specific relationships which can be detected are inheritance of a supplier class by a client, containment of an instance of a supplier class in a client, and the

existence of member functions of the client class which accept or return an instance of the supplier.

While these relationships may seem unrelated to the

invocation and module data counts, they are likely to show

a strong corelation because of the fact that in an object

oriented environment, it is likely (but not inevitable) that

the low-level use relationships of invocation and direct

access to data structures require an object of the class of

the supplier module to be available. This availability can

be through instantiation of an instance of the supplier class

within procedural code, but will often be due to the existence

of one of the higher level relationships described above.

The counts of Fan-In and Fan-Out are regarded as a measure

of the structural quality of a program, with high values of

either (and particularly high values of both within the same

module) indicating increased risk of changes required in one

module requiring changes across other modules. CCCC chooses

to define the relationship counts in such a way that each

supplier or client module is counted only once, however many

separate ways the relationship is detected. CCCC applies

filtering to the relationships identified to distinguish

between different kinds of uses which may carry with them

different levels of structural risk. There are two filters:

visibility and concreteness.

The visibility filter removes from consideration

relationships which are known to be only accessible from the

private interface of a module. Relationships which are

defined in the visible part of the interface can be exploited

by clients of the current module, thus forcing those clients

also to be clients of the current module's supplier. Visible

relationships also increase the range of operations

available on an object, thus increasing the cognitive

complexity of the interface from the point of view of a

programmer required to use a module.

The concreteness filter removes from consideration

relationships which do not create a dependency of the

implementation of the client module on the implementation of

the supplier class. Dependency-creating relationships

increase risk because they may not be cyclical, and thus

inhibit the creation of other relationships. They also

inhibit the ability of modules to be built separately,

requiring recompilation of the client module when the

supplier changes. The test for this filter in C++ is whether

a forward declaration of the supplier class is adequate to

allow the client module definition to be compiled:

containment and parameter passing where the client module is

modified by a referential operator are allowed in this case,

containment or passing by value or inheritance are all

dependency-creating. In Java, relationships except

inheritance are treated as non-dependency creating.

通过上述cccc 的原文,可以得知,cccc 中的扇入扇出是关于类之间的。 4 结论

计算java 语言的圈复杂度工具有很多,例如Analysis(eclipse的一个插件) 。

计算扇入扇出的主要技术点:

1.确定函数定义部分

2.确定函数调用fanout

3.确定被调次数fanin

可以通过cFlow 和Cccc 的源代码,尽量抽取出来。 CherryPick , Lachesis

文档名称:功能单元最大扇入扇出工具分析

作 者: 日 期:

1. 概念

由于度量的目标是C 源代码,所以“功能单元的最大扇入扇出”的含义如下: 功能单元:c 语言的函数。

扇入:有多少其他函数调用了A 函数。

扇出:A 函数调用了多少其他函数。

2 cFlow

2.1 工具简介

GNU 计划,又称革奴计划,是由Richard Stallman在1983年9月27日公开发起的。它的目标是创建一套完全自由的操作系统。Richard Stallman 最早是在net.unix-wizards 新闻组上公布该消息,并附带一份《GNU 宣言》等解释为何发起该计划的文章,其中一个理由就是 要“重现当年软件界合作互助的团结精神”。为保证GNU 软件可以自由地“使用、复制、修改和发布”,所有GNU 软件都在一份在禁止其他人添加任何限制的情 况下授权所有权利给任何人的协议条款,GNU 通用公共许可证(GNU General Public License,GPL )。即“反版权”(或称Copyleft )概念。

2.2 工具优缺点总结

cflow 程序会输出一个函数调用树,这是一个显示函数调用关系的图表。这对于查看程序结构来了解他是如何操作的以及了解对于一个函数有哪些影响是十分有用的。一些版本的cflow 可以同时作用于目标文件与源代码。查看手册页我们可以了解更为详细的操作。

GNU 官方的一个工具,最大的优点是成熟、可靠。

但源代码比较难读懂。GNU 的东西,封装性、技巧性比较强。

2.3 使用例程

1. 下载源代码

2. 解压

3. ./configure

4. make

5. make install

6. cflow tes.c

main() :

printf()

do_something_firstly() : malloc()

free()

do_something_finally() : printf()

7. 输出结果

2.4 核心代码抽取

通过此工具的源代码,可以获取匹配函数定义语句的功能,函数调用关系的功能,从来实现fan-in ,fan-out 度量。

3 C and C++ Code Counter

3.1 工具简介

3.2 工具优缺点总结

功能强大,基本能够进行所有的静态度量。支持c 语言。 缺点:源代码比较复杂,研读需要时间。

并不支持函数的扇入扇出。

4.3 实例

1. 实例代码:

#include

/*test example*/

int f1()

{

int a=1,b=2;

if (a==1)

a=4;

else

{

if (b==2)

{

a=4;

}

}

return 1;

}

int f2()

{

return 1;

}

int f3()

{

f1();

f2();

return 1;

}

main()

{

int a=10;

f1();

f2();

f3();

}

2. 安装cccc

官方网站下载安装文件

3. 执行度量

4. 查看结果

F3调用了f1,f2,但度量结果,并没有反应出来。

4.4 分析

扇出扇出的分析:

Fan-In, Fan-Out (FI,FIc,FIv,FO,FOc,FOv)

Traditionally, use relationships between modules were identified by counting function invocations or access to module data in procedural code. CCCC identifies relationships only through

structures apparent in the definitions of the interfaces of C++ classes or Java classes or interfaces. The specific relationships which can be detected are inheritance of a supplier class by a client, containment of an instance of a supplier class in a client, and the

existence of member functions of the client class which accept or return an instance of the supplier.

While these relationships may seem unrelated to the

invocation and module data counts, they are likely to show

a strong corelation because of the fact that in an object

oriented environment, it is likely (but not inevitable) that

the low-level use relationships of invocation and direct

access to data structures require an object of the class of

the supplier module to be available. This availability can

be through instantiation of an instance of the supplier class

within procedural code, but will often be due to the existence

of one of the higher level relationships described above.

The counts of Fan-In and Fan-Out are regarded as a measure

of the structural quality of a program, with high values of

either (and particularly high values of both within the same

module) indicating increased risk of changes required in one

module requiring changes across other modules. CCCC chooses

to define the relationship counts in such a way that each

supplier or client module is counted only once, however many

separate ways the relationship is detected. CCCC applies

filtering to the relationships identified to distinguish

between different kinds of uses which may carry with them

different levels of structural risk. There are two filters:

visibility and concreteness.

The visibility filter removes from consideration

relationships which are known to be only accessible from the

private interface of a module. Relationships which are

defined in the visible part of the interface can be exploited

by clients of the current module, thus forcing those clients

also to be clients of the current module's supplier. Visible

relationships also increase the range of operations

available on an object, thus increasing the cognitive

complexity of the interface from the point of view of a

programmer required to use a module.

The concreteness filter removes from consideration

relationships which do not create a dependency of the

implementation of the client module on the implementation of

the supplier class. Dependency-creating relationships

increase risk because they may not be cyclical, and thus

inhibit the creation of other relationships. They also

inhibit the ability of modules to be built separately,

requiring recompilation of the client module when the

supplier changes. The test for this filter in C++ is whether

a forward declaration of the supplier class is adequate to

allow the client module definition to be compiled:

containment and parameter passing where the client module is

modified by a referential operator are allowed in this case,

containment or passing by value or inheritance are all

dependency-creating. In Java, relationships except

inheritance are treated as non-dependency creating.

通过上述cccc 的原文,可以得知,cccc 中的扇入扇出是关于类之间的。 4 结论

计算java 语言的圈复杂度工具有很多,例如Analysis(eclipse的一个插件) 。

计算扇入扇出的主要技术点:

1.确定函数定义部分

2.确定函数调用fanout

3.确定被调次数fanin

可以通过cFlow 和Cccc 的源代码,尽量抽取出来。 CherryPick , Lachesis


相关文章

  • Excel中一些常用统计分析工具的功能_操作和注意事项
  • 第24卷第2期(总第140期) ・讲 座・ 辐射防护通讯2004年4月 ¹ 操作和注意事项Excel 中一些常用统计分析工具的功能. Funct ions, Operations and Precautions of the St atis ...查看


  • Midas单跨拱桥
  • 例题2 单跨拱桥 MIDAS/Civil 2 例题 2. 单跨拱桥 1 分析模型与荷载条件 / 2 5 7 使用节点和单元进行建模 11 建立拱肋 / 11 建立吊杆 / 12 形成拱的主梁并复制构架 / 14 建立横系梁 / 16 建立支 ...查看


  • ALGOR管道应力分析模块
  • ALGOR管道应力分析模块--PipePak 2010-05-05 23:57 ALGOR作为世界著名的大型通用工程仿真软件,被广泛应用于各个行业的设计.有限元分析以及机械运动仿真中,能够帮助设计分析人员预测和检验在真实状 态下的各种情况, ...查看


  • 软件测试面试题+测试基础知识
  • 软件测试面试题 1.测试的定义 软件测试是软件工程过程的一个重要阶段,是在软件升级发布之前对软件开发各阶段产品的最终检查,是为了保证软件开发产品的正确性.完全性和一致性而检测软件错误.修正软件错误的过程. 软件测试是: 1) 程序测试是为了 ...查看


  • 汽车举升机结构承载能力分析
  • 汽车举升机结构的承载能力研究 作 者 姓 名 专 业 指导教师姓名 专业技术职务 机械设计制造及其自动化 XX XX 目 录 摘 要 ------------------------1 第一章 绪 论-------------------- ...查看


  • 公司面试测试人员一般考什么
  • 公司面试测试人员一般考什么? 01. 为什么要在一个团队中开展软件测试工作? 02. 您是否了解以往所工作的企业的软件测试过程?如果了解,请试述在这个过程中都有哪些工作要做?分别由哪些不同的角色来完成这些工作? 03. 您是否了解以往所工作 ...查看


  • 常用嵌入式软件白盒测试工具介绍
  • 关于应用RPT在性能测试的思考谈谈嵌入式操作系统的调试问题软件测试中的性能测试的容量评估 高级性能测试LoadRunner技术课程高级软件测试技术课程[就业]先实习后上岗,入职年薪5-10万! ChinaItLab 佚名 2007-11-2 ...查看


  • EXCEL在统计学中的应用
  • <EXCEL在统计学中的应用> 第一章 EXCEL简介 在统计数据处理中,EXCEL是相对操作比较简单也比较容易得到的软件.对于一般的统计分析其功能也相对全面,因此我们想就EXCEL在统计工作中的应用显见要做一些介绍,在以后的章 ...查看


  • 软件测试工程师资料与面试题
  • 开发思想,逻辑能力 目录 测试用例....................................................................................................... ...查看


热门内容