Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 48 additions & 19 deletions howto/perf_profiling.po
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) 2001-2023, Python Software Foundation
# This file is distributed under the same license as the Python package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
# Translators:
# Matt Wang <mattwang44@gmail.com>, 2023
msgid ""
msgstr ""
"Project-Id-Version: Python 3.12\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-11-16 00:03+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"PO-Revision-Date: 2023-12-09 17:39+0800\n"
"Last-Translator: Matt Wang <mattwang44@gmail.com>\n"
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
"tw)\n"
"Language: zh_TW\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

#: ../../howto/perf_profiling.rst:7
msgid "Python support for the Linux ``perf`` profiler"
msgstr ""
msgstr "Python 對 Linux ``perf`` 分析器的支援"

#: ../../howto/perf_profiling.rst:0
msgid "author"
msgstr ""
msgstr "作者"

#: ../../howto/perf_profiling.rst:9
msgid "Pablo Galindo"
msgstr ""
msgstr "Pablo Galindo"

#: ../../howto/perf_profiling.rst:11
msgid ""
Expand All @@ -36,6 +36,9 @@ msgid ""
"of your application. ``perf`` also has a very vibrant ecosystem of tools "
"that aid with the analysis of the data that it produces."
msgstr ""
"`Linux 性能分析器 (Linux perf profiler) <https://perf.wiki.kernel.org>`_ 是一"
"個非常強大的工具,可讓你分析並獲取有關應用程式的性能資訊。``perf`` 還擁有一個"
"非常活躍的工具生態系統,有助於分析其生成的資料。"

#: ../../howto/perf_profiling.rst:17
msgid ""
Expand All @@ -45,6 +48,9 @@ msgid ""
"and file names of Python functions in your code will not appear in the "
"output of ``perf``."
msgstr ""
"在 Python 應用程式中使用 ``perf`` 分析器的主要問題是 ``perf`` 僅獲取有關原生"
"符號的資訊,即用 C 編寫的函式和程式的名稱。這表示程式碼中的 Python 函式名"
"稱和檔案名稱不會出現在 ``perf`` 的輸出中。"

#: ../../howto/perf_profiling.rst:22
msgid ""
Expand All @@ -55,6 +61,10 @@ msgid ""
"will teach ``perf`` the relationship between this piece of code and the "
"associated Python function using :doc:`perf map files <../c-api/perfmaps>`."
msgstr ""
"從 Python 3.12 開始,直譯器可以在特殊模式下運行,該模式允許 Python 函式出現"
"在 ``perf`` 分析器的輸出中。啟用此模式後,直譯器將在執行每個 Python 函式之前"
"插入 (interpose) 一小段動態編譯的程式碼,並使用 :doc:`perf map 檔案 <../c-"
"api/perfmaps>`\\ 來告訴 ``perf`` 這段程式碼與相關聯的 Python 函式間的關係。"

#: ../../howto/perf_profiling.rst:31
msgid ""
Expand All @@ -63,18 +73,21 @@ msgid ""
"check the output of ``python -m sysconfig | grep HAVE_PERF_TRAMPOLINE`` to "
"see if your system is supported."
msgstr ""
"目前對 ``perf`` 分析器的支援僅適用於 Linux 的特定架構上。檢查 "
"``configure`` 建構步驟的輸出或檢查 ``python -m sysconfig | grep "
"HAVE_PERF_TRAMPOLINE`` 的輸出來查看你的系統是否支援。"

#: ../../howto/perf_profiling.rst:36
msgid "For example, consider the following script:"
msgstr ""
msgstr "例如,參考以下腳本:"

#: ../../howto/perf_profiling.rst:55
msgid "We can run ``perf`` to sample CPU stack traces at 9999 hertz::"
msgstr ""
msgstr "我們可以執行 ``perf`` 以 9999 赫茲採樣 CPU 堆疊追蹤 (stack trace): ::"

#: ../../howto/perf_profiling.rst:59
msgid "Then we can use ``perf report`` to analyze the data:"
msgstr ""
msgstr "然後我們可以使用 ``perf report`` 來分析資料:"

#: ../../howto/perf_profiling.rst:100
msgid ""
Expand All @@ -84,15 +97,20 @@ msgid ""
"functions use the same C function to evaluate bytecode so we cannot know "
"which Python function corresponds to which bytecode-evaluating function."
msgstr ""
"如你所見,Python 函式未顯示在輸出中,僅顯示 ``_Py_Eval_EvalFrameDefault`` "
"(計算 Python 位元組碼 (bytecode) 的函式)。不幸的是,這不是很有用,因為所有 "
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

這裡的 evaluate 會不會比較接近於執行的意思?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

evaluate 一詞真的是每次看到都會痛苦一下XDD
我自己是覺得中文裡面沒有很貼切的用詞,先開個 discussion 紀錄 #748

"Python 函式都使用相同的 C 函式來計算位元組碼,因此我們無法知道哪個 Python 函"
"式是對應於哪個位元組碼計算函式。"

#: ../../howto/perf_profiling.rst:105
msgid ""
"Instead, if we run the same experiment with ``perf`` support enabled we get:"
msgstr ""
"作為替代,如果我們在啟用 ``perf`` 支援的情況下執行相同的實驗,我們會得到:"

#: ../../howto/perf_profiling.rst:152
msgid "How to enable ``perf`` profiling support"
msgstr ""
msgstr "如何啟用 ``perf`` 分析支援"

#: ../../howto/perf_profiling.rst:154
msgid ""
Expand All @@ -101,32 +119,37 @@ msgid ""
"X>` option, or dynamically using :func:`sys.activate_stack_trampoline` and :"
"func:`sys.deactivate_stack_trampoline`."
msgstr ""
"要啟用 ``perf`` 分析支援,可以在一開始就使用環境變數 :envvar:"
"`PYTHONPERFSUPPORT` 或使用 :option:`-X perf <-X>` 選項,也可以使用 :func:"
"`sys.activate_stack_trampoline` 和 :func:`sys.deactivate_stack_trampoline` 來"
"動態啟用。"

#: ../../howto/perf_profiling.rst:160
msgid ""
"The :mod:`!sys` functions take precedence over the :option:`!-X` option, "
"the :option:`!-X` option takes precedence over the environment variable."
msgstr ""
":mod:`!sys` 函式優先於 :option:`!-X` 選項、:option:`!-X` 選項優先於環境變數。"

#: ../../howto/perf_profiling.rst:163
msgid "Example, using the environment variable::"
msgstr ""
msgstr "例如,使用環境變數: ::"

#: ../../howto/perf_profiling.rst:168
msgid "Example, using the :option:`!-X` option::"
msgstr ""
msgstr "例如,使用 :option:`!-X` 選項: ::"

#: ../../howto/perf_profiling.rst:173
msgid "Example, using the :mod:`sys` APIs in file :file:`example.py`:"
msgstr ""
msgstr "例如,在 :file:`example.py` 檔案中使用 :mod:`sys` API:"

#: ../../howto/perf_profiling.rst:185
msgid "...then::"
msgstr ""
msgstr "...然後: ::"

#: ../../howto/perf_profiling.rst:192
msgid "How to obtain the best results"
msgstr ""
msgstr "如何獲得最佳結果"

#: ../../howto/perf_profiling.rst:194
msgid ""
Expand All @@ -137,15 +160,21 @@ msgid ""
"dynamically generated it doesn't have any DWARF debugging information "
"available."
msgstr ""
"為了獲得最佳結果,應使用 ``CFLAGS=\"-fno-omit-frame-pointer -mno-omit-leaf-"
"frame-pointer\"`` 來進行 Python 編譯,因為這能允許分析器僅使用 frame 指標而不"
"是 DWARF 除錯資訊來解析 (unwind)。這是因為,由於插入以允許 ``perf`` 支援的程式碼是動"
"態生成的,因此它沒有任何可用的 DWARF 除錯資訊。"

#: ../../howto/perf_profiling.rst:201
msgid ""
"You can check if your system has been compiled with this flag by running::"
msgstr ""
msgstr "你可以透過執行以下指令來檢查你的系統是否已使用此旗標進行編譯: ::"

#: ../../howto/perf_profiling.rst:205
msgid ""
"If you don't see any output it means that your interpreter has not been "
"compiled with frame pointers and therefore it may not be able to show Python "
"functions in the output of ``perf``."
msgstr ""
"如果你沒有看到任何輸出,則意味著你的直譯器尚未使用 frame 指標進行編譯,因此它"
"可能無法在 ``perf`` 的輸出中顯示 Python 函式。"