C++ & Embed

C++博客 首页 新随笔 联系 聚合 管理
  6 Posts :: 1 Stories :: 17 Comments :: 0 Trackbacks
代码度量(Code Metric)属于软件度量(Soft Metric)的范畴。很多人希望能够统计自己源码工程中的代码行数,实际上这就是Code Metric的初级形式。在很多开发标准中,都定义了Metric相关内容。如IEEE、CMM/CMMI。
Code Metric有若干重要指标。一款开源的Metric分析软件C and C++ Code Counter的分析报告书中阐述了如下指标:

    NOM = Number of modules
    LOC = Lines of Code
    COM = Lines of Comments
    MVG = McCabe's Cyclomatic Complexity
    L_C = Lines of code per line of comment
    M_C = Cyclomatic Complexity per line of comment
    IF4 = Information Flow measure

顾名思义,NOM是模块数量,即源码工程中包含多少模块。LOC是代码行数,这里不包括空行和注释。COM是注释行数。MVG是复杂度。L_C是每行注释代码行数,M_C是每行注释复杂度。IF4,信息流测定。(由于没有找到中文的翻译和释义,仅凭个人理解罗列翻译)
微软的VSTS2008提供Metric功能,但无法针对C++使用。CCCC(C and C++ Code Counter)似乎已经停止维护,命令行模式,不易使用。一些商用工具功能强大但过于昂贵。
SourceMonitor是一个不错的选择:
※免费使用
※Windows下GUI界面
※功能较为强大,可保存用于比较的基线(Baseline)

http://www.campwoodsw.com/index.html


参考资料:
http://blogs.msdn.com/fxcop/archive/2007/02/28/announcing-visual-studio-code-metrics.aspx  C# Code Metrics
http://en.wikipedia.org/wiki/Software_metric 维基百科Software Metric
http://blog.csdn.net/summerfang/archive/2006/09/04/1176916.aspx 使用source monitor帮助进行代码重构 

追记:
1.UTF编码的文件将不被识别和读取。CCCC和SouceMonitor都存在这个问题。SourceMonitor有相关的选项,可能是我操作问题,失败了……
2.SouceMonitor统计出来的代码行数偏低。主要原因可能是没有计算大括号…… 在我目前开发的项目中,根据现有的编码规范,是否计算大括号的统计差异为40%。
3.适当的使用CCCC也是不错的。有些统计值CCCC较为完整。
posted on 2009-09-26 13:08 眩晕:C++ & Embed 阅读(2196) 评论(9)  编辑 收藏 引用 所属分类: Soft Metric

评论

# re: SourceMonitor 可用于C++开发的免费代码度量工具 2009-11-29 07:38
"一些商用工具功能强大但过于昂贵。"

我很想知道博主说的商业工具都有哪些,我非常想用一下。。。  回复  更多评论
  

# re: SourceMonitor 可用于C++开发的免费代码度量工具 2009-11-29 11:05 眩晕
商业工具有Borland的相关工具,也有Parasoft的相关工具。不光是有Metric功能,还有很多静态检查、MemoryLeak、SourceReview等机能。
  回复  更多评论
  

# re: SourceMonitor 可用于C++开发的免费代码度量工具 2009-11-30 09:30
谢谢博主了~~~  回复  更多评论
  

# re: SourceMonitor 可用于C++开发的免费代码度量工具 2010-05-24 16:11 RAE32Phillips
All people deserve very good life time and <a href="http://lowest-rate-loans.com/topics/home-loans">home loans</a> or just college loan would make it better. Because people's freedom depends on money.   回复  更多评论
  

# re: SourceMonitor 可用于C++开发的免费代码度量工具 2010-05-28 02:37 thesis writing
It is really great that you are doing such superb article referring to this good topic. Thus we think that it will be very good when scholars buy the legal dissertation and thesis writing with you help.   回复  更多评论
  

# re: SourceMonitor 可用于C++开发的免费代码度量工具 2010-05-28 09:29 buy essays
A lot of research paper writing services propose useful information about this good post, thus buy an essay or custom written essays to see more just about this good topic.   回复  更多评论
  

# re: SourceMonitor 可用于C++开发的免费代码度量工具 2010-09-07 09:12 article submit
I see that you are real expert in your release just about this good post accomplishing. Thus, some submit article service will use your good enough article for various projects.   回复  更多评论
  

# re: SourceMonitor 可用于C++开发的免费代码度量工具 2014-08-01 21:52 memleak.in
文章挺久远  回复  更多评论
  


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理