美国是什么洲| 什么来什么去| 咽颊炎吃什么药| 宝贝疙瘩是什么意思| 水果的英文是什么| 宫颈液基细胞学检查是什么| 代销商是什么意思| 网络拒绝接入什么意思| 狐假虎威是什么意思| 老人流口水是什么原因引起的| 破伤风是什么症状| 11.4什么星座| 赤脚走路有什么好处| hpv81阳性是什么意思| 糖耐量异常是什么意思| 送什么礼物好| 什么情况下必须做胃镜| 重色轻友是什么意思| 月经期间喝什么好排毒排污血| 肉燕是什么做的| 脑震荡是什么症状| lpn什么意思| 孤独症有什么表现| 用盐刷牙有什么好处和坏处| 女人白带多什么原因| 大学什么时候开始收费| 金主是什么意思| 胃炎吃什么消炎药| 医保卡是什么样子的图| 大便干燥一粒一粒的是什么原因| 肺部炎症用什么药最好| 心脏造影是什么检查| 杭州有什么美食| 字母圈是什么| 手是什么生肖| 一什么城市| 农历七月初五是什么星座| 感冒喉咙痛吃什么药好| 割痔疮后吃什么恢复快| 水逆是什么| cm代表什么单位| 民营企业和私营企业有什么区别| 为什么做噩梦| 四川酸菜是什么菜| 吃什么东西补血| 蛇属什么五行| 脑膜炎吃什么药| 超前点映什么意思| bic是什么意思| 老掉头发是什么原因| 喝杨梅酒对身体有什么好处| 银灰色五行属什么| 垂盆草长什么样| 眼睛闪光是什么症状| 一九八四年属什么生肖| 结肠炎吃什么药好| 验光是什么意思| d什么意思| 深海鱼油有什么好处| 不知道为了什么| b型血和ab型血的孩子是什么血型| 3.22什么星座| 舌边有齿痕是什么原因| lady是什么意思啊| 反刍什么意思| 小孩晚上睡觉发梦癫什么原因| 属龙的守护神是什么菩萨| 小孩上户口需要什么材料| 杏色搭配什么颜色好看| 骨质增生是什么| 怀孕送什么礼物| 梦见在河里抓鱼是什么征兆| 想的偏旁是什么| 7月7号是什么节日| 画龙点睛是什么意思| 依托是什么意思| 双顶径和头围有什么区别| 血虚吃什么食物可以补| 吃苹果有什么好处和功效| 朝鲜人一日三餐吃什么| 炎症吃什么消炎药| 自来水养鱼为什么会死| 球镜柱镜是什么意思| 秦国是现在的什么地方| 县宣传部长是什么级别| 输液葡萄糖有什么作用| 什么是毒龙| mafia是什么意思| 妊娠什么意思| 轻度溶血是什么意思| 不好意思是什么意思| 北豆腐是什么| 生肖羊和什么生肖相冲| 什么发什么颜| barbie是什么意思| 调教是什么| 舌头发麻是什么原因引起的| 重本是什么意思| 一什么不| 生抽和老抽有什么区别| 白虎痣是什么意思| 干咳嗽喉咙痒是什么原因| 荆州是现在的什么地方| 雨后的彩虹像什么| 吃什么食物对心脏好| kda是什么意思| 大仙为什么知道你的事| 肿瘤长什么样| 两脚发热是什么原因| 便秘吃什么药好| 瑞五行属什么| 中国第一长河是什么河| 打点滴是什么意思| 什么牌子的学习机好| 鲁班是什么家| 财神叫什么名字| 什么书在书店买不到| 受益匪浅的意思是什么| 老流鼻血是什么原因| 脚趾第二个比第一个长有什么说法| 芝五行属什么| 91年属什么生肖| 才女是什么意思| 淋巴结节什么症状| 鱼休子是什么| 为什么心细的男人危险| 九门提督相当于现在什么官| 胃痛吃什么好得快| 乳和霜有什么区别| 变节是什么意思| 吹毛求疵什么意思| tv是什么意思| 中耳炎不能吃什么食物| 时光荏苒的意思是什么| 鲜牛奶和纯牛奶有什么区别| 蚕豆病不能吃什么药| bl是什么单位| 粘液阳性是什么意思| 耳鸣吃什么药效果好| 回心转意是什么意思| 口水多吃什么药好得快| 牛油果树长什么样| 女人更年期吃什么药| 甲减有什么症状| 吃金针菇有什么好处| 扔枕头有什么忌讳吗| 吃什么盐最好| 晚上十点多是什么时辰| 高回声是什么意思| 气短咳嗽是什么原因引起的| 不羁放纵是什么意思| 鲜卑族现在是什么族| 膘是什么意思| 画龙点晴是什么生肖| 茵芙莎属于什么档次| 蜂窝数据什么意思| 什么人容易高原反应| 小孩检查微量元素挂什么科| 蚂蚁代表什么生肖| s牌运动鞋是什么牌子| 体检前需要注意什么| 碧字五行属什么| 生二胎应该注意什么| 肠粉为什么叫肠粉| 现在是什么时辰| 去势是什么意思| 什么头十足| 什么是凌汛| 唐僧姓什么| 欢字五行属什么| 八月十二是什么星座| 梦到自己快要死了是什么意思| 地铁和高铁有什么区别| 什么是败血症| 男士脸黑用什么能美白| 一直发低烧是什么原因| 言字旁有什么字| 东道主是什么意思| 前列腺液是什么| 胎盘长什么样子图片| 狒狒是什么动物| 2岁什么都听懂但不说话| sga是什么意思| 难为情是什么意思| 6月出生是什么星座| 结婚的礼数都有什么| 跳蛋有什么用| 大是大非是什么意思| 撒拉族和回族有什么区别| 脚脱皮用什么药| 是什么样的| ur是什么意思| 无伤大雅是什么意思| 婚姻宫是什么意思| 牙痛什么原因引起的| 废话是什么意思| 曲马多是什么药| 盼头是什么意思| 吃稀饭配什么菜好吃| 小猫喜欢什么颜色| 左眼跳什么意思| 唯我独尊是什么意思| guess是什么品牌| 炖牛肉不放什么调料| 人生没有什么不可放下| 什么是暗网| 阿斗是什么意思| 胃不舒服想吐是什么原因| 尿为什么是黄色的| 退翳什么意思| wuli是什么意思| 三百多分能上什么大学| 来褐色分泌物是什么原因| 二月底是什么星座| 阴历七月是什么星座| 铁蛋白是什么意思| 总蛋白偏低是什么意思| 骨质增生是什么意思| 西瓜坏了是什么样| 男孩适合学什么专业| 属猴和什么属相最配| 胃镜挂什么科| 韧带拉伤吃什么药| gm是什么牌子| 咳嗽吃什么药最好| 怀疑甲亢需要做什么检查| 梦见蛇缠身是什么预兆| 脑白质缺血性改变什么意思| 长期口苦是什么原因| 飞机为什么不能说一路顺风| 早晨起来手肿是什么原因| 手术后吃什么好| 小拇指和无名指发麻是什么原因| 安乐片是什么药| 贱痣是什么意思| 木槿花的花语是什么| 无厘头是什么意思| 两败俱伤是什么意思| 腔梗是什么| 基围虾为什么叫基围虾| 吃什么增加孕酮| 符咒是什么意思| 芳菲的意思是什么| 大拇指有黑色竖纹是什么原因| 结甲是什么病| 崩塌的读音是什么| 生理期没来是什么原因| 全麦粉和小麦粉的区别是什么| 印度信仰什么教| 乳腺纤维瘤是什么原因引起的| 一戴套就软是什么原因| 孵化基地是什么意思| 桃李满天下是什么意思| 孙权和孙策是什么关系| 抗病毒什么药效果好| 梦见给别人理发是什么意思| 什么叫自然拼读| 散光跟近视有什么区别| 叶黄素是什么| 12月10号什么星座| 属猪跟什么属相最配| 重阳节送老人什么礼物| 韭菜什么人不能吃| 为什么感冒会咳嗽| 百度Jump to content

赵明昊:“竞争性共存”将成中美关系新态势

From Wikipedia, the free encyclopedia
(Redirected from Profiler (computer science))
百度   “万人计划”重点支持哪些人才  第一层次100名,为具有冲击诺贝尔奖、成长为世界级科学家潜力的杰出人才。

In software engineering, profiling (program profiling, software profiling) is a form of dynamic program analysis that measures, for example, the space (memory) or time complexity of a program, the usage of particular instructions, or the frequency and duration of function calls. Most commonly, profiling information serves to aid program optimization, and more specifically, performance engineering.

Profiling is achieved by instrumenting either the program source code or its binary executable form using a tool called a profiler (or code profiler). Profilers may use a number of different techniques, such as event-based, statistical, instrumented, and simulation methods.

Gathering program events

[edit]

Profilers use a wide variety of techniques to collect data, including hardware interrupts, code instrumentation, instruction set simulation, operating system hooks, and performance counters.

Use of profilers

[edit]
Graphical output of the CodeAnalyst profiler

Program analysis tools are extremely important for understanding program behavior. Computer architects need such tools to evaluate how well programs will perform on new architectures. Software writers need tools to analyze their programs and identify critical sections of code. Compiler writers often use such tools to find out how well their instruction scheduling or branch prediction algorithm is performing...

—?ATOM, PLDI

The output of a profiler may be:

  • A statistical summary of the events observed (a profile)
Summary profile information is often shown annotated against the source code statements where the events occur, so the size of measurement data is linear to the code size of the program.
/* ------------ source------------------------- count */             
0001            IF X = "A"                      0055
0002                THEN DO                       
0003                    ADD 1 to XCOUNT         0032
0004                ELSE
0005            IF X = "B"                      0055
  • A stream of recorded events (a trace)
For sequential programs, a summary profile is usually sufficient, but performance problems in parallel programs (waiting for messages or synchronization issues) often depend on the time relationship of events, thus requiring a full trace to get an understanding of what is happening.
The size of a (full) trace is linear to the program's instruction path length, making it somewhat impractical. A trace may therefore be initiated at one point in a program and terminated at another point to limit the output.
  • An ongoing interaction with the hypervisor (continuous or periodic monitoring via on-screen display for instance)
This provides the opportunity to switch a trace on or off at any desired point during execution in addition to viewing on-going metrics about the (still executing) program. It also provides the opportunity to suspend asynchronous processes at critical points to examine interactions with other parallel processes in more detail.

A profiler can be applied to an individual method or at the scale of a module or program, to identify performance bottlenecks by making long-running code obvious.[1] A profiler can be used to understand code from a timing point of view, with the objective of optimizing it to handle various runtime conditions[2] or various loads.[3] Profiling results can be ingested by a compiler that provides profile-guided optimization.[4] Profiling results can be used to guide the design and optimization of an individual algorithm; the Krauss matching wildcards algorithm is an example.[5] Profilers are built into some application performance management systems that aggregate profiling data to provide insight into transaction workloads in distributed applications.[6]

History

[edit]

Performance-analysis tools existed on IBM/360 and IBM/370 platforms from the early 1970s, usually based on timer interrupts which recorded the program status word (PSW) at set timer-intervals to detect "hot spots" in executing code.[citation needed] This was an early example of sampling (see below). In early 1974 instruction-set simulators permitted full trace and other performance-monitoring features.[citation needed]

Profiler-driven program analysis on Unix dates back to 1973,[7] when Unix systems included a basic tool, prof, which listed each function and how much of program execution time it used. In 1982 gprof extended the concept to a complete call graph analysis.[8]

In 1994, Amitabh Srivastava and Alan Eustace of Digital Equipment Corporation published a paper describing ATOM[9] (Analysis Tools with OM). The ATOM platform converts a program into its own profiler: at compile time, it inserts code into the program to be analyzed. That inserted code outputs analysis data. This technique - modifying a program to analyze itself - is known as "instrumentation".

In 2004 both the gprof and ATOM papers appeared on the list of the 50 most influential PLDI papers for the 20-year period ending in 1999.[10]

Profiler types based on output

[edit]

Flat profiler

[edit]

Flat profilers compute the average call times, from the calls, and do not break down the call times based on the callee or the context.

Call-graph profiler

[edit]

Call graph profilers[8] show the call times, and frequencies of the functions, and also the call-chains involved based on the callee. In some tools full context is not preserved.

Input-sensitive profiler

[edit]

Input-sensitive profilers[11][12][13] add a further dimension to flat or call-graph profilers by relating performance measures to features of the input workloads, such as input size or input values. They generate charts that characterize how an application's performance scales as a function of its input.

Data granularity in profiler types

[edit]

Profilers, which are also programs themselves, analyze target programs by collecting information on the target program's execution. Based on their data granularity, which depends upon how profilers collect information, they are classified as event-based or statistical profilers. Profilers interrupt program execution to collect information. Those interrupts can limit time measurement resolution, which implies that timing results should be taken with a grain of salt. Basic block profilers report a number of machine clock cycles devoted to executing each line of code, or timing based on adding those together; the timings reported per basic block may not reflect a difference between cache hits and misses.[14][15]

Event-based profilers

[edit]

Event-based profilers are available for the following programming languages:

  • Java: the JVMTI (JVM Tools Interface) API, formerly JVMPI (JVM Profiling Interface), provides hooks to profilers, for trapping events like calls, class-load, unload, thread enter leave.
  • .NET: Can attach a profiling agent as a COM server to the CLR using Profiling API. Like Java, the runtime then provides various callbacks into the agent, for trapping events like method JIT / enter / leave, object creation, etc. Particularly powerful in that the profiling agent can rewrite the target application's bytecode in arbitrary ways.
  • Python: Python profiling includes the profile module, hotshot (which is call-graph based), and using the 'sys.setprofile' function to trap events like c_{call,return,exception}, python_{call,return,exception}.
  • Ruby: Ruby also uses a similar interface to Python for profiling. Flat-profiler in profile.rb, module, and ruby-prof a C-extension are present.

Statistical profilers

[edit]

These profilers operate by sampling. A sampling profiler probes the target program's call stack at regular intervals using operating system interrupts. Sampling profiles are typically less numerically accurate and specific, providing only a statistical approximation, but allow the target program to run at near full speed. "The actual amount of error is usually more than one sampling period. In fact, if a value is n times the sampling period, the expected error in it is the square-root of n sampling periods."[16]

In practice, sampling profilers can often provide a more accurate picture of the target program's execution than other approaches, as they are not as intrusive to the target program and thus don't have as many side effects (such as on memory caches or instruction decoding pipelines). Also since they don't affect the execution speed as much, they can detect issues that would otherwise be hidden. They are also relatively immune to over-evaluating the cost of small, frequently called routines or 'tight' loops. They can show the relative amount of time spent in user mode versus interruptible kernel mode such as system call processing.

Unfortunately, running kernel code to handle the interrupts incurs a minor loss of CPU cycles from the target program, diverts cache usage, and cannot distinguish the various tasks occurring in uninterruptible kernel code (microsecond-range activity) from user code. Dedicated hardware can do better: ARM Cortex-M3 and some recent MIPS processors' JTAG interfaces have a PCSAMPLE register, which samples the program counter in a truly undetectable manner, allowing non-intrusive collection of a flat profile.

Some commonly used[17] statistical profilers for Java/managed code are SmartBear Software's AQtime[18] and Microsoft's CLR Profiler.[19] Those profilers also support native code profiling, along with Apple Inc.'s Shark (OSX),[20] OProfile (Linux),[21] Intel VTune and Parallel Amplifier (part of Intel Parallel Studio), and Oracle Performance Analyzer,[22] among others.

Instrumentation

[edit]

This technique effectively adds instructions to the target program to collect the required information. Note that instrumenting a program can cause performance changes, and may in some cases lead to inaccurate results and/or heisenbugs. The effect will depend on what information is being collected, on the level of timing details reported, and on whether basic block profiling is used in conjunction with instrumentation.[23] For example, adding code to count every procedure/routine call will probably have less effect than counting how many times each statement is obeyed. A few computers have special hardware to collect information; in this case the impact on the program is minimal.

Instrumentation is key to determining the level of control and amount of time resolution available to the profilers.

  • Manual: Performed by the programmer, e.g. by adding instructions to explicitly calculate runtimes, simply count events or calls to measurement APIs such as the Application Response Measurement standard.
  • Automatic source level: instrumentation added to the source code by an automatic tool according to an instrumentation policy.
  • Intermediate language: instrumentation added to assembly or decompiled bytecodes giving support for multiple higher-level source languages and avoiding (non-symbolic) binary offset re-writing issues.
  • Compiler assisted
  • Binary translation: The tool adds instrumentation to a compiled executable.
  • Runtime instrumentation: Directly before execution the code is instrumented. The program run is fully supervised and controlled by the tool.
  • Runtime injection: More lightweight than runtime instrumentation. Code is modified at runtime to have jumps to helper functions.

Interpreter instrumentation

[edit]
  • Interpreter debug options can enable the collection of performance metrics as the interpreter encounters each target statement. A bytecode, control table or JIT interpreters are three examples that usually have complete control over execution of the target code, thus enabling extremely comprehensive data collection opportunities.

Hypervisor/simulator

[edit]
  • Hypervisor: Data are collected by running the (usually) unmodified program under a hypervisor. Example: SIMMON
  • Simulator and Hypervisor: Data collected interactively and selectively by running the unmodified program under an instruction set simulator.

See also

[edit]

References

[edit]
  1. ^ "How to find the performance bottleneck in C# desktop application?". Stack Overflow. 2012.
  2. ^ Krauss, Kirk J (2017). "Performance Profiling with a Focus". Develop for Performance.
  3. ^ "What is code profiling? Learn the 3 Types of Code Profilers". Stackify Developer Tips, Tricks and Resources. Disqus. 2016.
  4. ^ Lawrence, Eric (2016). "Getting Started with Profile Guided Optimization". testslashplain. WordPress.
  5. ^ Krauss, Kirk (2018). "Matching Wildcards: An Improved Algorithm for Big Data". Develop for Performance.
  6. ^ "List of .Net Profilers: 3 Different Types and Why You Need All of Them". Stackify Developer Tips, Tricks and Resources. Disqus. 2016.
  7. ^ Unix Programmer's Manual, 4th Edition
  8. ^ a b S.L. Graham, P.B. Kessler, and M.K. McKusick, gprof: a Call Graph Execution Profiler, Proceedings of the SIGPLAN '82 Symposium on Compiler Construction, SIGPLAN Notices, Vol. 17, No 6, pp. 120-126; doi:10.1145/800230.806987
  9. ^ A. Srivastava and A. Eustace, ATOM: A system for building customized program analysis tools, Proceedings of the ACM SIGPLAN Conference on Programming language design and implementation (PLDI '94), pp. 196-205, 1994; ACM SIGPLAN Notices - Best of PLDI 1979-1999 Homepage archive, Vol. 39, No. 4, pp. 528-539; doi:10.1145/989393.989446
  10. ^ 20 Years of PLDI (1979–1999): A Selection, Kathryn S. McKinley, Editor
  11. ^ E. Coppa, C. Demetrescu, and I. Finocchi, Input-Sensitive Profiling, IEEE Trans. Software Eng. 40(12): 1185-1205 (2014); doi:10.1109/TSE.2014.2339825
  12. ^ D. Zaparanuks and M. Hauswirth, Algorithmic Profiling, Proceedings of the 33rd ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI 2012), ACM SIGPLAN Notices, Vol. 47, No. 6, pp. 67-76, 2012; doi:10.1145/2254064.2254074
  13. ^ T. Kustner, J. Weidendorfer, and T. Weinzierl, Argument Controlled Profiling, Proceedings of Euro-Par 2009 – Parallel Processing Workshops, Lecture Notes in Computer Science, Vol. 6043, pp. 177-184, 2010; doi:10.1007/978-3-642-14122-5 22
  14. ^ "Timing and Profiling - Basic Block Profilers". OpenStax CNX Archive.
  15. ^ Ball, Thomas; Larus, James R. (1994). "Optimally profiling and tracing programs" (PDF). ACM Transactions on Programming Languages and Systems. 16 (4). ACM Digital Library: 1319–1360. doi:10.1145/183432.183527. S2CID 6897138. Archived from the original (PDF) on 2025-08-07. Retrieved 2025-08-07.
  16. ^ Statistical Inaccuracy of gprof Output Archived 2025-08-07 at the Wayback Machine
  17. ^ "Popular C# Profilers". Gingtage. 2014.
  18. ^ "Sampling Profiler - Overview". AQTime 8 Reference. SmartBear Software. 2018.
  19. ^ Wenzal, Maira; et al. (2017). "Profiling Overview". Microsoft .NET Framework Unmanaged API Reference. Microsoft.
  20. ^ "Performance Tools". Apple Developer Tools. Apple, Inc. 2013.
  21. ^ Netto, Zanella; Arnold, Ryan S. (2012). "Evaluate performance for Linux on Power". IBM DeveloperWorks.
  22. ^ Schmidl, Dirk; Terboven, Christian; an Mey, Dieter; Müller, Matthias S. (2013). Suitability of Performance Tools for OpenMP Task-Parallel Programs. Proc. 7th Int'l Workshop on Parallel Tools for High Performance Computing. pp. 25–37. ISBN 9783319081441.
  23. ^ Carleton, Gary; Kirkegaard, Knud; Sehr, David (1998). "Profile-Guided Optimizations". Dr. Dobb's Journal.
[edit]
淋症是什么意思 今天忌什么宜什么 术后病人吃什么营养恢复快 小便发黄是什么症状 湿疹擦什么药
男女更年期分别在什么年龄 啼笑皆非的意思是什么 胃嗳气是什么原因 浅表性胃炎用什么药 不能吃油腻的是什么病
失聪什么意思 血小板压积偏低是什么意思 参数错误是什么意思 shuuemura是什么牌子 阑尾炎挂什么科
心率慢吃什么药 老年人脸肿是什么原因引起的 全身痒但是身上什么都没有 无可奈何什么意思 什么上树全靠一张嘴
梦到自己老公出轨是什么意思hcv9jop3ns7r.cn 打胎后要注意什么hcv8jop1ns6r.cn 血压低有什么危害hcv7jop6ns5r.cn 梦到打架是什么意思hcv8jop1ns5r.cn 流产挂什么科hcv8jop2ns4r.cn
男士睾丸疼是什么原因0297y7.com 究竟涅盘是什么意思jingluanji.com 吃鱼生后吃什么打虫药shenchushe.com 手脱皮是什么原因96micro.com 用什么挠脚心最痒youbangsi.com
炉甘石是什么hcv8jop0ns3r.cn 无花果是什么季节的水果hcv8jop1ns0r.cn 什么样的野花hcv8jop3ns8r.cn 什么叫青光眼hcv8jop0ns8r.cn 五指毛桃长什么样子hcv8jop3ns5r.cn
1991年属羊的是什么命hcv7jop5ns1r.cn 2月20日是什么星座hcv8jop4ns7r.cn 苯是什么hcv8jop3ns7r.cn 办理护照需要什么材料hcv9jop2ns8r.cn 喝牛奶胀气是什么原因hcv9jop3ns4r.cn
百度