
1 yangff 2014-05-29 16:38:05 +08:00 不存在。 |
2 misaka 2014-05-29 16:53:20 +08:00 目测算法。。。 |
3 zhoulujue 2014-05-29 17:24:23 +08:00 静态分析工具,多的是。 |
4 binux 2014-05-29 17:33:04 +08:00 |
5 imxz 2014-05-29 17:40:06 +08:00 是想问 大O 吗 ? |
6 Mutoo 2014-05-29 17:48:37 +08:00 大O表示法,在 Mark Allen Weiss 的《数据结构与算法分析》里面有专门一章节介绍,而且有好几章节的案例分析。 |
8 karlxu OP @Mutoo 我想问的是圈复杂度计算,网上都是说数有多少if,while,for。。。。但感觉不是很严谨 |
12 akfish 2014-05-29 20:24:08 +08:00 |
13 akfish 2014-05-29 20:25:25 +08:00 Mathematically, the cyclomatic complexity of a structured program[a] is defined with reference to the control flow graph of the program, a directed graph containing the basic blocks of the program, with an edge between two basic blocks if control may pass from the first to the second. The complexity M is then defined as[2] M = E N + 2P, where E = the number of edges of the graph. N = the number of nodes of the graph. P = the number of connected components (exit nodes). 够严谨了吧。 |
14 keniusahdu 2014-05-29 20:27:45 +08:00 Sonar 有计算复杂度的。但是没有什么算法,都是针对循环,判断之类的识别。以及空引用高危判断。 ps:我说的是java ,其他不知道 |
15 fzss 2014-05-29 21:19:59 +08:00 ORDER OF GROWTH |
16 dorentus 2014-05-29 21:32:54 +08:00 |
17 soundbbg 2014-05-29 21:42:13 +08:00 一开始不需要过度优化,后面针对具体的瓶颈优化就好了。 拿循环做复杂度其实也挺逗的,谁知道函数嵌套了多少个函数,更不要说大部分不间断的程序都是死循环,你没看到只是因为别人都封装好了。 代码里不推荐多个嵌套循环这是必然的,但纯拿循环来说性能就和拿代码行数算KPI一个道理,况且计算机就是一个大循环。 |
18 ruandao 2014-05-29 23:21:14 +08:00 时间复杂度? 空间复杂度? 还是逻辑复杂度? |
19 lijinma 2014-05-29 23:29:18 +08:00 @soundbbg 拿循环说性能挺逗?大哥,那你觉得纯研究算法的是靠什么来做标准?还不是靠循环,你这是藐视算法分析; 一个算法在数据很小的时候没多大作用,但是在数据很大的时候,n^2 和 n 那得有多大差距啊; 敢问兄弟,不靠循环,你靠什么来评判一个算法的时间复杂度? |
21 66450146 2014-05-30 02:17:43 +08:00 via Android @lijinma 算法的时间复杂度跟代码本身没有任何关系,也不是由循环数量决定的。。。简单的可以数循环,复杂的就数不出来了 |
22 karlxu OP @akfish 我们要用python做个统计代码复杂度的工具,难道就数if,while,for,try,catch,switch?会不会太简单了? |
23 karlxu OP @soundbbg 我们要用python做个统计代码复杂度的工具,难道就数if,while,for,try,catch,switch?会不会太简单了? |
24 akfish 2014-05-30 10:23:29 +08:00 @karlxu 正经的方法是把编译器前端部分做出来,解析源代码生成AST(抽象语法树),剩下的事情就是一堆图算法去撸而已。 这部分的研究很成熟了,各种IDE高上洋的代码自动完成、重构、分析工具都是这样实现的。 |
26 akfish 2014-05-30 11:28:15 +08:00 |
27 wecing 2014-06-01 04:04:22 +08:00 我只知道停机问题。 |
28 lijinma 2014-06-01 23:32:50 +08:00 |