我有一个写一个文件的函数.我需要用两个参数来分析函数,所以我可以看到差异.(不要告诉我有关Visual Studios Profiling工具的信息,我想自己做).我想申请这样的东西:
double start = getTime();
myFunction("param1");
double request = getTime() - start;
printf_s("Request time: %f", request);
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?(上面有什么只是伪代码,我不知道真正的函数名称)
我想提高我的PHP脚本的性能,因此我想安装Xdebug进行性能分析.
问题是:我找不到如何在Raspbian上安装它!我试图xdebug, xdebug-beta, pecl, pear, ...通过sudo apt-get install- >找不到安装
我还尝试手动安装pecl:
$ wget http://pear.php.net/go-pear.phar
$ php go-pear.phar
Run Code Online (Sandbox Code Playgroud)
但pecl/pear命令无法使用.
你知道我应该怎么做吗?
或者你甚至对性能改进/分析技术有更好的想法?
我正在使用valgrind在我的系统上找到内存泄漏,我收到了这个输出
==9697== Memcheck, a memory error detector
==9697== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==9697== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==9697== Command: bin/vfirewall-monitor
==9697==
==9697==
==9697== HEAP SUMMARY:
==9697== in use at exit: 0 bytes in 0 blocks
==9697== total heap usage: 1 allocs, 1 frees, 37 bytes allocated
==9697==
==9697== All heap blocks were freed -- no leaks are possible
==9697==
==9697== For counts of detected and suppressed errors, …Run Code Online (Sandbox Code Playgroud) 我是Lisp的新手,我想将时间输出打印到文件(/tmp/foo.txt)中,所以我定义了一个关于时间的包装函数,如下所示:
(defun my-time(form)
(lisp::with-open-file (*trace-output* "/tmp/foo.txt"
:direction :output
:if-exists :append
:if-does-not-exist :create)
(time(form))))
(defun test(n)
(dotimes (i n) (format t "this is test ~a.~&" i)))
Run Code Online (Sandbox Code Playgroud)
但是,当我运行时(我的时间(测试2)),出现以下错误: 错误:使用arguments()调用未定义的函数FORM.
我做这个测试时没关系:(时间(测试2))
有人能给我一些线索吗?
我试图了解Haskell程序的内存使用情况,我怀疑很多内存分配是在我导入的外部库中发生的.我知道-profGHC 的选项,但这只给我一个我自己的代码细分.我想将其扩展到导入的库,以了解如何修改我对此库或库本身的使用以减少内存使用.这是我安装的开源库cabal.
设置内容的最简单方法是什么,以便我可以对库本身进行概要分析?
我想在我的Go程序中添加命令行标志来启用/禁用cpu和内存分析.使用pprof.StartCPUProfile()显式启用CPU分析.但是未明确启用内存分析.你只需在退出时调用pprof.WriteHeapProfile().如果我从不进行这些调用,是否存在与任何一种分析形式相关的运行时成本?如果没有,这是否意味着内存分析基本上始终开启?
我跑到命令之下
MIX_ENV=prod mix profile.fprof --no-start -e "Math.prime_seq 501"
Run Code Online (Sandbox Code Playgroud)
对于以下代码
def prime_seq(n) do
prime_seq(n, 1, 3, [2,3,5,7,11,13,17,19,23])
end
def prime_seq(n, c, p, cache) when c < n do
is_it = cache |> Enum.any?(fn n -> rem(p, n) == 0 end)
if not is_it do
prime_seq(n, c+1, p+2, cache ++ [p])
else
if(is_prime(p)) do
prime_seq(n, c+1, p+2, cache ++ [p])
else
prime_seq(n, c, p+2, cache)
end
end
end
def prime_seq(n, c, p, _) when c == n do
p-2
end
Run Code Online (Sandbox Code Playgroud)
结果如下:
为什么 …
我正在分析我的Julia应用程序,特别是函数调用的执行时间和内存分配.我想自动将这些信息存储到数据库中,以便它可以在没有监督的情况下运行.
我想要存储的信息是由@time以下形式返回的:
@time some_function()
86.278909 seconds (6.94 M allocations: 383.520 MB, 0.08% gc time)
Run Code Online (Sandbox Code Playgroud)
是否可以从代码本身访问此信息,而不是仅仅打印出来?
我知道我可以使用tic()和访问时间组件toq(),但是内存分配怎么样?
我有简单的排序程序,我正在分析,以便有一个案例来研究gprof; 我后来计划分析一个更大的算法.
我编译-pg并运行./sort来生成gmon.out文件.但是,当我运行gprof ./sort gmon.out累积秒数和自秒时产生的值时,我认为不准确.
首先,跑步time(./sort)我得到:
real 0m14.352s
user 0m14.330s
sys 0m0.005s
Run Code Online (Sandbox Code Playgroud)
我的秒表准确无误.
但是,平面轮廓的gprof结果是:
Each sample counts as 0.01 seconds.
% cumulative self self total
time seconds seconds calls s/call s/call name
56.18 2.76 2.76 1 2.76 4.71 sort(std::vector<int, std::allocator<int> >&)
35.01 4.49 1.72 1870365596 0.00 0.00 std::vector<int, std::allocator<int> >::operator[](unsigned long)
8.96 4.93 0.44 100071 0.00 0.00 std::vector<int, std::allocator<int> >::size() const
0.00 4.93 0.00 50001 0.00 0.00 __gnu_cxx::new_allocator<int>::construct(int*, int const&)
0.00 4.93 …Run Code Online (Sandbox Code Playgroud) Perfiew是一个非常酷的工具.但是我使用它的调用树视图时遇到问题,因为它一次显示信息线程 - 除非你有一个非常繁忙的线程,否则它真的会失败.见下图.
相反,我想通过低于线程ID的东西看到最昂贵的堆栈,就像顶级方法一样(如ANTS和大多数其他性能分析器那样).这可能吗?如果是这样,怎么样?
见下图