日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > asp.net >内容正文

asp.net

编写高性能 .NET 代码 第一章:工具介绍 -- Performance Counters(性能计数器)

發布時間:2023/12/4 asp.net 53 豆豆
生活随笔 收集整理的這篇文章主要介紹了 编写高性能 .NET 代码 第一章:工具介绍 -- Performance Counters(性能计数器) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Performance Counters(性能計數器)

性能計數器是監視應用程序和系統性能的最簡單的方法之一。它有幾十個類別數百個計數器在,包括一些.net特有的計數器。要訪問這些可以通過系統自帶的 性能監控程序(perfmon.exe)來實現。

圖1-2。是PerfMon的主要窗口,它顯示一個小的時間段內處理器計數器。垂直線表示當前實例,默認情況下100秒鐘后圖形將換行。

圖1-3。這是很多類別里的其中一個計數器,還顯示了適用這個計數器的應用實例。

每個計數器都有一個類別和一個名稱。 很多計數器還可以選擇對應的進程。 例如,對于Process類別中的%Processor Time計數器,實例可以是各種進程。 一些計數器還具有元實例,例如_Total或 ,它實際上是所有實例上的匯總值。

后面的很多章節將詳細介紹相關主題對應的計數器。幾乎每個Windows子系統都有對應的性能計數器,這些計數器通常適用于每個程序。
但是,在繼續之前,您應該熟悉一些基本的操作系統相關的計數器:

? Physical Memory—The actual physical memory chips in a computer. Only the operating system manages physical memory directly.

? Virtual Memory—A logical organization of memory in a given process. Virtual memory size can be larger than physical memory. For example, 32-bit programs have a 4 GB address space, even if the computer itself only has 2 GB of RAM. Windows allows the program to access only 2 GB of that by default, but all 4 GB is possible if the executable is large-address aware. (On 32-bit versions of Windows, large-address aware programs are limited to 3 GB.) As of Windows 8.1 and Server 2012, 64-bit processes have a 128 TB process space, far larger than the 4 TB physical memory limit. Some of the virtual memory may be in RAM while other parts are stored on disk in a paging file. Contiguous blocks of virtual memory may not be contiguous in physical memory. All memory addresses in a process are for the virtual memory.

? Reserved Memory—A region of virtual memory address space that has been reserved for the process and thus will not be allocated to a future requester. Reserved memory cannot be used for memory allocation requests because there is nothing backing it—it is just a description of a range of memory addresses.
??Committed Memory—A region of memory that has a physical backing store. This can be RAM or disk.
??Page—An organizational unit of memory. Blocks of memory are allocated in a page, which is usually a few KB in size.

? Paging—The process of transferring pages between regions of virtual memory. The page can move to or from another process (soft paging) or the disk (hard paging). Soft paging can be accomplished very quickly by mapping the existing memory into the current process’s virtual address space. Hard paging involves a relatively slow transfer of data to or from disk. Your program must avoid this at all costs to maintain good performance.

? Page In—Transfer a page from another location to the current process.

? Page Out—Transfer a page from the current process to another location, such as disk.

? Context Switch—The process of saving and restoring the state of a thread or process. Because there are usually more running threads than available processors, there are often many context switches per second.

? Kernel Mode—A mode that allows the OS to modify low-level aspects of the hardware’s state, such as modifying certain registers or enabling/disabling interrupts. Transitioning to Kernel Mode requires an operating system call, and can be quite expensive.

? User Mode—An unprivileged mode of executing instructions. There is no ability to modify low-level aspects of the system.

以上的我翻譯過一次,感覺都不通常,所以還是不翻了,懂的看前面單詞就知道什么意思,不懂的百度一下也就知道了。

以下是我將在整本書中使用的一些計數器,特別是在第2章討論垃圾回收時。 當然如果你想了解相關主題的更多信息,請查看專門介紹操作系統的書,如Windows Internals。 (見附錄C中的參考書目)
以下的計數器內容涵蓋了進程常用的計數器,它可以詳細記錄每個進程的數據:

? % Privileged Time—Amount of time spent in executing privileged (kernel mode) code.

? % Processor Time—Percentage of a single processor the application is using. If your application is using two logical processor cores at 100% each, then this counter will read 200.

? % User Time—Amount of time spent in executing unprivileged (user mode) code.

? IO Data Bytes/sec—How much I/O your process is doing.

? Page Faults/sec—Total number of page faults in your process. A page fault occurs when a page of memory is missing from the current working set. It is important to realize that this number includes both soft and hard page faults. Soft page faults are innocuous and can be caused by the page being in memory, but outside the current process (such as for shared DLLs). Hard page faults are more serious, indicating data that is on disk but not currently in memory. Unfortunately, you cannot track hard page faults per process with performance counters, but you can see it for the entire system with the Memory\Page Reads/sec counter. You can do some correlation with a process’s total page faults plus the system’s overall page reads (hard faults). You can definitively track a process’s hard faults with ETW tracing with the Windows Kernel/Memory/Hard Fault event.

? Pool Nonpaged Bytes—Typically operating system and driver allocated memory for data structures that cannot be paged out such as operating system objects like threads and mutexes, but also custom data structures.

? Pool Paged Bytes—Also for operating system data structures, but these are allowed to be paged out.
Private Bytes—Committed virtual memory private to the specific process (not shared with any other processes).

? Virtual Bytes—Allocated memory in the process’s address space, some of which may be backed by the page file, shared with other processes, and memory private to the process.

? Working Set—The amount of virtual memory currently resident in physical memory (usually RAM).

? Working Set-Private—The amount of private bytes currently resident in physical memory.

? Thread Count—The number of threads in the process. This may or may not be equal to the number of .NET threads. See Chapter 4 (Asynchronous Programming) for a discussion of .NET thread-related counters.

根據應用還有一些有用的分類。 您可以使用PerfMon來探索在這些特別的分類。

? IPv4/IPv6—Internet Protocol-related counters for datagrams and fragments.

? Memory—System-wide memory counters such as overall paging, available bytes, committed bytes, and much more.

? Objects—Data about kernel-owned objects such as events, mutexes, processes, threads, semaphores, and sections.

? Processor—Counters for each logical processor in the system.

? System—Context switches, alignment fixes, file operations, process count, threads, and more.

? TCPv4/TCPv6—Data for TCP connections and segment transfers

還是那句話,我翻譯過一遍發現太丑陋了就不放出來了,特別是當我翻譯完下面的文字的時候。

令人驚訝的是,在互聯網里沒有找到關于性能計數器的詳細介紹,但幸運的是,PrefMon自己有完善的記錄,在PrefMon工具里的“添加計數器”對話框中,可以選中底部的“顯示描述”框以突出顯示計數器的詳細信息。

你說你不是坑爹嗎,你既然都有描述說明了,干嘛不直接開放出來,非得點勾選一個選項才出來。

PrefMon還能夠設置時間定時啟動性能計數器,并存儲在日志中供以后查看,甚至在計數器超過閾值時執行自定義操作。它不僅限于性能計數器數據的收集,還可以收集系統配置數據和ETW事件數據。

讓我們啟動性能監視器,設置一次數據收集器

  • 展開“數據收集器集”樹

  • 右鍵單擊“用戶定義”

  • 選擇“新建”

  • 選擇“數據收集器集”

  • 5.給它一個名稱,選中“手動創建(高級)”,然后單擊下一步

    6.檢查“創建數據日志”下的性能計數器框,然后單擊下一步

    7.單擊添加以選擇要包括的計數器

    8.單擊下一步設置要存儲日志的路徑,然后單擊下一步直到選擇結束

    完成后,您可以打開收集器的屬性,并設置收集計劃。也可以通過右鍵單擊作業節點并選擇開始來手動運行。 這將創建一個報表(應該是文件吧),可以通過在主樹視圖中的“報告--用戶定義”下節點來查看。

    圖1-7。 已保存的報告文件。 使用工具欄按鈕將視圖更改為收集時的計數器數據的圖形。

    要創建警報,請執行相同的過程,在向導中選擇“性能計數器警報”選項。
    使用此處描述的功能可能需要執行性能計數器所需的一切,但如果要采取控制或創建自己的計數器,請參閱第7章(性能計數器)了解詳細信息。 您應該將性能計數器分析視為應用程序的所有性能工作的基準。

    相關文章:

    • [翻譯]編寫高性能 .NET 代碼 第一章:性能測試與工具 -- 選擇什么來衡量

    • [翻譯]編寫高性能 .NET 代碼 第一章:性能測試與工具 -- 平均值 vs 百分比

    • [翻譯]編寫高性能 .NET 代碼 第一章:工具介紹 -- Visual Studio

    原文地址:http://www.cnblogs.com/yahle/p/6531297.html


    .NET社區新聞,深度好文,微信中搜索dotNET跨平臺或掃描二維碼關注

    總結

    以上是生活随笔為你收集整理的编写高性能 .NET 代码 第一章:工具介绍 -- Performance Counters(性能计数器)的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。