有没有一种方法可以“映射"Visual Studio或MATLAB中的程序执行顺序? [英] Is there a way to "map" the program execution order in Visual Studio or MATLAB?

查看:71
本文介绍了有没有一种方法可以“映射"Visual Studio或MATLAB中的程序执行顺序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

"map"的意思是我有一个"main"函数,该函数在内部调用许多其他程序,并且我希望能够看到哪个文件在第一个,第二个,第三个等运行.能够查看这个大型OOP设计程序(创建者未为其创建UML类图)中的依赖关系的列表和顺序,以帮助解密代码.在流行的IDE中肯定必须存在这样的功能吗?我主要处理C ++和MATLAB,因此我更关心这两个,但是请列出所有您知道具有此功能的IDE.我更喜欢可视化的东西,而不仅仅是运行调试器和断点一千次.

解决方案

在MATLAB中,我不相信有一种可视化的内置方法,但是您可以使用<

每个函数来自的文件也可以通过 FunctionTable FileName 字段进行访问,因此,如果函数和它们来自的文件之间的区别很重要,则可以使用这些信息可以相应地为图形着色或简化图形.

What I mean by "map" is that I have a "main" function which calls many other programs inside, and I want to be able to see which file runs first, second, third, etc. Basically, I want to be able to see the list and order of dependencies in this large OOP design program (which the creator did not make a UML class diagram for) to help decipher the code. Surely such a functionality must exist in popular IDE's? I'm mostly dealing with C++ and MATLAB so I'm more concerned with these two specifically, but please list any IDE's you know of that have this functionality. I'd prefer something visual and not just running through a debugger and breakpoints a thousand times.

解决方案

In MATLAB, I don't believe there's a built-in way to do this visually, but you can get the information you need from the profiler using the FunctionTable returned by profile('info').

The parent/child relationships in the table essentially define a directed graph which you can interact with visually or otherwise in MATLAB if you convert it to a digraph object.

For example, to map the program execution of kmeans:

profile on
kmeans(rand(100,2),5);
p = profile('info');
t = struct2table(p.FunctionTable);
g = digraph(false(height(t)), t); % Create the graph with nodes and no edges

% Add the edges
for ii = 1:g.numnodes
    for jj = 1:numel(g.Nodes.Children{ii})
        g = g.addedge(ii, g.Nodes.Children{ii}(jj).Index);
    end
end

plot(g,'NodeLabel',g.Nodes.FunctionName,'Layout','layered');

Produces:

The file each function comes from is also accessible via the FileName field of the FunctionTable so if the distinction between functions and the files they came from is important you could use this information to color or simplify the graph accordingly.

这篇关于有没有一种方法可以“映射"Visual Studio或MATLAB中的程序执行顺序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆