分析与日志记录有何不同? [英] How is profiling different from logging?

查看:72
本文介绍了分析与日志记录有何不同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

分析与日志记录有何不同?

How is profiling different from logging?

是否仅将性能分析用于性能测量以查看每个功能需要花费多长时间?还是我要离开?

Is it just that profiling is used for performance measurements to see how long each function takes? Or am I off?

通常情况下,如何使用分析库?

Typically, how are profiling libraries used?

通过分析可以获得哪些类型的统计信息?

What types of stats are obtained by profiling?

推荐答案

日志记录告诉您发生了什么.这对于取证和调试非常有用.

Logging tells you what happened. It's great for forensics and debugging.

配置文件可以量化:它告诉您代码在每个区域中花费了多少时间,或代码主体被执行了多少次.它可以帮助您提高代码的性能.

Profiling quantifies that: it tells you how much time your code spent in each area, or how many times a body of code was executed. It helps you improve your code's performance.

分析通常在代码行,函数调用或有时在文件级进行.对于每个级别,它通常可以告诉您:

Profiling typically operates at the level of a line of code, a function call, or sometimes a file. For each level, it can typically tell you:

  • 该单元执行了多少次.与执行数百万次的代码相比,优化很少使用的代码通常没有那么重要.一个例外是使用户(或另一个进程)等待其完成的代码.

  • How many times the unit was executed. It's generally less important to optimize rarely-used code than code that executes millions of times. One exception is code that makes a user (or another process) wait for it to complete.

ifswitch语句中说出分支的次数.同样,您通常最关心的是优化常用代码.

How many times a branch was taken, say in an if or switch statement. Again, you typically care most about optimizing often-used code.

在特定功能中花费了多少时间 . 警告:即使是经验丰富的开发人员也常常会对这些结果感到惊讶.很难预测您的时间消耗"在哪里.

How much time was spent in a particular function. Warning: even experienced developers are often surprised by these results. It's very difficult to predict where your "time sinks" are.

一个函数以及在该函数中调用的所有函数花费了多少时间.也许不是函数本身,而是子函数需要优化.

How much time was spent in a function and all functions called within that function. Maybe it's not the function itself, but its children, that need optimizing.

每个呼叫者呼叫该设备多少次 .您可能会发现某个特定的函数主要是从意外的地方调用的.

How many times the unit was called by each caller. You may find that a particular function is called primarily from an unexpected place.

借助良好的探查器中的数据,您通常可以在不费吹灰之力的情况下获得显着的性能改善.

Armed with the data from a good profiler, you can often gain significant improvements in performance with relatively little effort.

这篇关于分析与日志记录有何不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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