TWI684916B - Function selection method and server - Google Patents

Function selection method and server Download PDF

Info

Publication number
TWI684916B
TWI684916B TW108101178A TW108101178A TWI684916B TW I684916 B TWI684916 B TW I684916B TW 108101178 A TW108101178 A TW 108101178A TW 108101178 A TW108101178 A TW 108101178A TW I684916 B TWI684916 B TW I684916B
Authority
TW
Taiwan
Prior art keywords
function
identification
function call
time
application program
Prior art date
Application number
TW108101178A
Other languages
Chinese (zh)
Other versions
TW201942736A (en
Inventor
曹玉斌
Original Assignee
香港商阿里巴巴集團服務有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 香港商阿里巴巴集團服務有限公司 filed Critical 香港商阿里巴巴集團服務有限公司
Publication of TW201942736A publication Critical patent/TW201942736A/en
Application granted granted Critical
Publication of TWI684916B publication Critical patent/TWI684916B/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • G06F11/3624Software debugging by performing operations on the source code, e.g. via a compiler
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • G06F11/3636Software debugging by tracing the execution of the program
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • G06F11/3644Software debugging by instrumenting at runtime
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2201/00Indexing scheme relating to error detection, to error correction, and to monitoring
    • G06F2201/81Threshold

Abstract

本說明書實施例提供一種函式選取方法和伺服器。所述方法包括:運行原始碼中包括除錯碼的應用程式,得到所述應用程式的運行狀態資訊;所述運行狀態資訊包括執行緒識別對應的函式呼叫資訊;所述函式呼叫資訊包括函式識別以及函式識別對應的時間戳;分析預設執行緒識別對應的函式呼叫資訊,得到所述預設執行緒識別對應的至少一個函式呼叫鏈;每個所述函式呼叫鏈包括至少一個函式識別;從所述至少一個函式呼叫鏈中選取對應的運行時間大於或等於預設時間閾值的函式識別;函式識別對應的運行時間基於該函式識別對應的時間戳得到。 The embodiments of the present specification provide a function selection method and a server. The method includes: running an application program including a debug code in the source code to obtain operating state information of the application program; the operating state information includes function call information corresponding to a thread identification; and the function call information includes Function identification and the time stamp corresponding to the function identification; analyzing the function call information corresponding to the default thread identification to obtain at least one function call chain corresponding to the default thread identification; each of the function call chains At least one function identification is included; the function identification corresponding to the running time greater than or equal to the preset time threshold is selected from the at least one function call chain; the running time corresponding to the function identification is based on the time stamp corresponding to the function identification get.

Description

函式選取方法和伺服器Function selection method and server

本說明書實施例是關於電腦之技術領域,特別是關於一種函式選取方法和伺服器。The embodiments of the present specification relate to the technical field of computers, in particular to a function selection method and a server.

在應用程式的生命週期中,當一個應用程式自身發生碼升級、版本迭代或者漏洞修復等變化時,或者,與該應用程式相關聯的其它應用程式發生碼升級、版本迭代或者漏洞修復等變化時,通常需要定位出該應用程式中的耗時函式,以便對該應用程式的回應時間進行優化。所述耗時函式可以為運行時間較長的函式。所述回應時間可以包括啟動時間、執行某一功能的時間等。 在相關技術中,可以獲取應用程式的追蹤檔案(trace檔案),並可以採用人工的方式來分析所述追蹤檔案以從中識別出耗時函式。例如開發人員可以借助TraceView(一種測試應用程式性能的工具)來分析所述追蹤檔案以從中識別出耗時函式。但是,採用人工的方式來識別耗時函式,效率和準確性較低,難以滿足實際的需求。 During the life cycle of an application, when an application itself undergoes changes in code upgrades, version iterations, or bug fixes, or other applications associated with the application undergo changes in code upgrades, version iterations, or bug fixes, etc. , Usually need to locate the time-consuming function in the application, in order to optimize the response time of the application. The time-consuming function may be a function with a long running time. The response time may include startup time, time to execute a certain function, and so on. In the related art, a trace file (trace file) of an application can be obtained, and the trace file can be analyzed in a manual manner to identify a time-consuming function therefrom. For example, developers can use TraceView (a tool for testing application performance) to analyze the trace file to identify time-consuming functions. However, using manual methods to identify time-consuming functions has low efficiency and accuracy, making it difficult to meet actual needs.

本說明書實施例的目的是提供一種函式選取方法和伺服器,以提高耗時函式識別的效率和準確性。 為實現上述目的,本說明書實施例提供一種函式選取方法,包括:運行原始碼中包括除錯碼的應用程式,得到所述應用程式的運行狀態資訊;所述運行狀態資訊包括執行緒識別對應的函式呼叫資訊;所述函式呼叫資訊包括函式識別以及函式識別對應的時間戳;分析預設執行緒識別對應的函式呼叫資訊,得到所述預設執行緒識別對應的至少一個函式呼叫鏈;每個所述函式呼叫鏈包括至少一個函式識別;從所述至少一個函式呼叫鏈中選取對應的運行時間大於或等於預設時間閾值的函式識別;函式識別對應的運行時間基於該函式識別對應的時間戳得到。 為實現上述目的,本說明書實施例提供一種伺服器,包括:運行單元,用於運行原始碼中包括除錯碼的應用程式,得到所述應用程式的運行狀態資訊;所述運行狀態資訊包括執行緒識別對應的函式呼叫資訊;所述函式呼叫資訊包括函式識別以及函式識別對應的時間戳;分析單元,用於分析預設執行緒識別對應的函式呼叫資訊,得到所述預設執行緒識別對應的至少一個函式呼叫鏈;每個所述函式呼叫鏈包括至少一個函式識別;選取單元,用於從所述至少一個函式呼叫鏈中選取對應的運行時間大於或等於預設時間閾值的函式識別;函式識別對應的運行時間基於該函式識別對應的時間戳得到。 為實現上述目的,本說明書實施例提供一種伺服器,包括:記憶體,用於儲存電腦指令;處理器,用於執行所述電腦指令實現以下步驟:運行原始碼中包括除錯碼的應用程式,得到所述應用程式的運行狀態資訊;所述運行狀態資訊包括執行緒識別對應的函式呼叫資訊;所述函式呼叫資訊包括函式識別以及函式識別對應的時間戳;分析預設執行緒識別對應的函式呼叫資訊,得到所述預設執行緒識別對應的至少一個函式呼叫鏈;每個所述函式呼叫鏈包括至少一個函式識別;從所述至少一個函式呼叫鏈中選取對應的運行時間大於或等於預設時間閾值的函式識別;函式識別對應的運行時間基於該函式識別對應的時間戳得到。 由以上本說明書實施例提供的技術方案可見,本說明書實施例中,持續整合伺服器可以運行原始碼中包括除錯碼的應用程式,得到所述應用程式的運行狀態資訊;可以分析預設執行緒識別對應的函式呼叫資訊,得到所述預設執行緒識別對應的至少一個函式呼叫鏈;可以從所述至少一個函式呼叫鏈中選取對應的運行時間大於或等於預設時間閾值的函式識別。本說明書實施例中,所述持續整合伺服器可以分析應用程式中預設執行緒識別對應的函式呼叫資訊,得到至少一個函式呼叫鏈;可以基於預設時間閾值從所述至少一個函式呼叫鏈中過濾出耗時函式。這樣,所述持續整合伺服器可以提高耗時函式識別的效率和準確性。 The purpose of the embodiments of the present specification is to provide a method for selecting functions and a server to improve the efficiency and accuracy of time-consuming function identification. To achieve the above purpose, embodiments of the present specification provide a method for function selection, including: running an application program including a debug code in the source code to obtain operating state information of the application program; the operating state information includes a thread identification correspondence Function call information; the function call information includes function identification and the time stamp corresponding to the function identification; analyze the function call information corresponding to the default thread identification to obtain at least one corresponding to the default thread identification Function call chain; each of the function call chains includes at least one function identification; from the at least one function call chain, a corresponding function identification whose running time is greater than or equal to a preset time threshold is selected; function identification The corresponding running time is obtained based on the function identifying the corresponding time stamp. In order to achieve the above purpose, an embodiment of the present specification provides a server, including: a running unit for running an application program including a debug code in a source code to obtain operating state information of the application program; the operating state information includes execution Thread identification corresponding function call information; the function call information includes function identification and function identification corresponding time stamp; analysis unit is used to analyze the function call information corresponding to the default thread identification to obtain the pre-call Let the thread identify at least one corresponding function call chain; each function call chain includes at least one function identification; the selection unit is used to select the corresponding running time from the at least one function call chain to be greater than or equal to The function identification equal to the preset time threshold; the running time corresponding to the function identification is obtained based on the time stamp corresponding to the function identification. To achieve the above purpose, embodiments of the present specification provide a server, including: a memory for storing computer instructions; a processor for executing the computer instructions to achieve the following steps: running an application program including a debug code in the original code To get the running status information of the application; the running status information includes the function call information corresponding to the thread identification; the function call information includes the function identification and the time stamp corresponding to the function identification; analyze the default execution Thread identification corresponding to the function call information, to obtain at least one function call chain corresponding to the default thread identification; each function call chain includes at least one function identification; from the at least one function call chain The function identification corresponding to the operation time greater than or equal to the preset time threshold is selected; the operation time corresponding to the function identification is obtained based on the time stamp corresponding to the function identification. It can be seen from the above technical solutions provided by the embodiments of the present specification that in the embodiments of the present specification, the continuous integration server can run the application program including the debug code in the source code to obtain the running status information of the application program; the default execution can be analyzed Thread identification corresponding to the function call information, to obtain at least one function call chain corresponding to the default thread identification; the corresponding running time can be selected from the at least one function call chain is greater than or equal to a preset time threshold Function recognition. In the embodiment of the present specification, the continuous integration server can analyze the function call information corresponding to the default thread recognition in the application program to obtain at least one function call chain; it can be based on the preset time threshold from the at least one function Time-consuming functions are filtered out in the call chain. In this way, the continuous integration server can improve the efficiency and accuracy of time-consuming function recognition.

下面將結合本說明書實施例中的附圖,對本說明書實施例中的技術方案進行清楚、完整地描述,顯然,所描述的實施例僅僅是本說明書一部分實施例,而不是全部的實施例。基於本說明書中的實施例,本領域普通技術人員在沒有作出創造性勞動前提下所獲得的所有其他實施例,都應當屬於本說明書保護的範圍。 請參閱圖1。本說明書實施例提供一種函式選取系統。所述函式選取系統可以包括版本伺服器、持續整合伺服器(Continuous Integration Server)和至少一個終端設備。 在本實施例中,所述終端設備可以為開發人員所使用的終端設備,例如可以為個人電腦(PC機)、或伺服器等。開發人員可以使用所述終端設備來編輯應用程式的原始碼。所述版本伺服器可以用於儲存並管理應用程式各個版本的原始碼。例如,所述版本伺服器可以運行有SVN(Subversion)、CVS(Concurrent Version System)等應用程式版本控制系統;可以基於所述應用程式版本控制系統來管理應用程式各個版本的原始碼。所述持續整合伺服器可以用於對應用程式的原始碼進行編譯和測試。 在本實施例中,所述終端設備可以向所述版本伺服器上傳應用程式的原始碼。所述版本伺服器可以接收並儲存應用程式的原始碼。所述持續整合伺服器可以從所述版本伺服器中獲取應用程式的原始碼;可以編譯所述應用程式的原始碼,得到所述應用程式;可以對所述應用程式的性能進行測試,得到測試結果;可以向所述終端設備發送所述測試結果。所述終端設備可以接收所述測試結果。這樣,透過所述測試結果,開發人員可以從所述應用程式的原始碼中獲取影回應用程式性能的函式。這裡所述性能例如可以為啟動時間、或耗電量等;所述函式可以理解為能夠實現一定功能的電腦程式指令集合。 請參閱圖2。本說明書實施例提供一種函式選取方法。所述函式選取方法以持續整合伺服器為執行主體,可以包括以下步驟。 步驟S10:運行原始碼中包括除錯碼的應用程式,得到所述應用程式的運行狀態資訊。 在本實施例中,所述應用程式可以為用於完成一項或多項工作的電腦程式。所述應用程式具體可以為任意類型的應用程式,例如可以為支付類型的應用程式、視頻播放類型的應用程式、或圖像處理類型的應用程式等。 在本實施例中,在應用程式的開發階段,開發人員可以在所述應用程式的原始碼中插入除錯碼,以便在運行所述應用程式時能夠得到所述應用程式的運行狀態資訊。在後續過程中透過分析所述運行狀態資訊,便可以發現所述應用程式原始碼中的缺陷。所述除錯碼可以包括除錯函式。所述除錯函式可以用於產生運行狀態資訊。所述除錯函式例如可以包括Debug.startMethodTracing、和Debug.stopMethodTracing等。當然,所述除錯碼還可以包括其它的功能函式,例如檢測函式。所述檢測函式可以用於在檢測到滿足特定條件時觸發所述除錯函式,例如在檢測到根目錄存在某一檔案時觸發所述除錯函式。 在本實施例中,所述運行狀態資訊可以包括應用程式的至少一個執行緒的執行緒識別、以及執行緒識別對應的函式呼叫資訊等。所述執行緒識別可以用於識別執行緒,例如可以為執行緒的名稱、或編號等。所述函式呼叫資訊可以用於描述執行緒識別識別的執行緒所呼叫的函式。所述函式呼叫資訊具體可以包括至少一個函式識別、以及函式識別對應的時間戳等。所述函式識別可以用於識別函式,例如可以為函式的名稱、或編號等。所述時間戳可以包括進入時間戳和退出時間戳。所述進入時間戳可以用於表示函式識別識別的函式的進入時刻;所述退出時間戳可以用於表示函式識別識別的函式的退出時刻。基於所述進入時間戳和所述退出時間戳能夠計算出函式識別識別的函式的運行時間。需要說明的是,有鑒於一個執行緒可以一次或多次呼叫一個函式,所述函式呼叫資訊中的函式識別可以對應一對或多對時間戳,每對時間戳可以包括一個進入時間戳和一個退出時間戳。 在本實施例的一個場景示例中,所述持續整合伺服器可以運行原始碼中包括除錯碼的應用程式,進而得到追蹤檔案(trace檔案)。所述追蹤檔案可以包括所述應用程式的運行狀態資訊。具體地,例如,所述追蹤檔案可以包括:

Figure 02_image001
上述追蹤檔案中; threadID表示執行緒識別。例如,執行緒識別12622用於識別執行緒main;執行緒識別12693用於識別執行緒OnLineMonitor。 class.method表示函式識別。例如,android.os.Handler.dispatchMessage和android.os.MessageQueue.next分別為函式識別。 Action表示動作。例如,Action可以包括ent和xit。Ent表示進入函式;xit表示退出函式。 usecs表示時間戳。例如,16752為函式識別android.os.Handler.dispatchMessage對應的進入時間戳;18976為函式識別android.os.Handler.dispatchMessage對應的退出時間戳。 在本實施例的一個實施方式中,考慮到開發人員透過在應用程式原始碼的不同位置插入除錯碼,便可以得到所述應用程式在不同運行階段的運行狀態資訊。例如,開發人員透過在應用程式原始碼的啟動碼處插入除錯碼,便可以得到所述應用程式在啟動階段的運行狀態資訊。所述啟動碼可以為應用程式在啟動階段執行的碼。如此,所述運行狀態資訊可以包括所述應用程式在預設運行階段的運行狀態資訊。所述預設運行階段可以包括啟動階段。當然,所述預設運行階段還可以包括其它階段,例如執行某一功能的階段等。 在本實施例中,所述持續整合伺服器可以接收版本伺服器發來的應用程式的原始碼,所述應用程式的原始碼中可以包括除錯碼;可以基於所述應用程式的原始碼,產生所述應用程式;可以運行所述應用程式,得到所述應用程式的運行狀態資訊。具體地,所述持續整合伺服器可以編譯所述應用程式的原始碼,得到所述應用程式。所述版本伺服器可以每間隔預設時間週期,向所述持續整合伺服器發送自身儲存的所述應用程式最新版本的原始碼。所述預設時間週期可以根據實際需要靈活設定,例如可以為10天、25天、或30天等。或者,有鑒於所述版本伺服器通常認為接收到的原始碼為所述應用程式最新版本的原始碼,所述版本伺服器可以在接到終端設備發來的應用程式的原始碼後,儲存並向所述持續整合伺服器發送所述應用程式的原始碼。 在本實施例的一個場景示例中,所述應用程式的原始碼中可以包括除錯碼。所述除錯碼可以包括檢測函式和除錯函式。所述檢測函式可以用於在檢測到根目錄存在某一檔案後觸發所述除錯函式,所述檔案例如可以為abc.txt。所述除錯函式可以包括Debug.startMethodTracing、和Debug.stopMethodTracing。具體地,所述除錯函式Debug.startMethodTracing可以位於所述應用程式原始碼中啟動碼的起始位置;所述除錯函式Debug.stopMethodTracing可以位於所述應用程式原始碼中啟動碼的結束位置。 在本場景示例中,開發人員在編輯完成應用程式的原始碼後,可以使用終端設備向版本伺服器發送所述應用程式的原始碼。所述版本伺服器可以接收並儲存所述應用程式的原始碼;可以向所述持續整合伺服器發送所述應用程式的原始碼。所述持續整合伺服器可以接收所述應用程式的原始碼;可以編譯所述應用程式的原始碼,得到所述應用程式。所述持續整合伺服器可以在根目錄寫入預先約定的檔案(例如檔案abc.txt)以便觸發所述應用程式原始碼中的檢測函式;可以運行所述應用程式,得到追蹤檔案。所述追蹤檔案可以包括所述應用程式在啟動階段的運行狀態資訊。 步驟S12:分析預設執行緒識別對應的函式呼叫資訊,得到所述預設執行緒識別對應的至少一個函式呼叫鏈。 在本實施例中,所述預設執行緒識別的數量可以為一個或多個。所述預設執行緒識別識別的執行緒可以為所述應用程式的部分或全部執行緒。例如,所述預設執行緒識別識別的執行緒可以為所述應用程式的與啟動相關的執行緒。具體地,例如,所述預設執行緒識別可以包括執行緒識別12622和12693,執行緒識別12622可以用於識別執行緒main,執行緒識別12693可以用於識別執行緒OnLineMonitor。所述函式呼叫鏈可以包括至少一個函式識別。每個所述函式呼叫鏈中的函式識別識別的函式間可以具有逐級呼叫關係。 在本實施例的一個場景示例中,某一函式呼叫鏈可以包括16個函式識別,具體包括:
Figure 02_image003
上述函式呼叫鏈中的函式識別識別的函式間可以具有逐級呼叫關係。具體地,函式識別com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run識別的函式可以呼叫函式識別java.lang.reflect.Method.invoke識別的函式;函式識別java.lang.reflect.Method.invoke識別的函式可以呼叫函式識別android.app.ActivityThread.main識別的函式;依次類推,函式識別com.alibaba.fastjson.serializer.ListSerializer.write識別的函式可以呼叫函式識別com.alibaba.fastjson.serializer.MapSerializer.write識別的函式。 在本實施例中,針對每個預設執行緒,所述持續整合伺服器可以獲取該預設執行緒在所述運行狀態資訊中對應的函式呼叫資訊;可以以獲取的函式呼叫資訊為目標函式呼叫資訊;可以分析所述目標函式呼叫資訊中各個函式識別識別的函式間的呼叫關係,得到該執行緒識別對應的至少一個函式呼叫鏈。 步驟S14:從所述至少一個函式呼叫鏈中選取對應的運行時間大於或等於預設時間閾值的函式識別。 在本實施例中,函式識別對應的運行時間可以基於該函式識別對應的時間戳得到。具體地,如前所述,函式識別對應的時間戳可以包括進入時間戳和退出時間戳。如此,針對所述至少一個函式呼叫鏈中的每個函式識別,所述持續整合伺服器可以以該函式識別對應的退出時間戳表示的時刻為退出時刻;可以以該函式識別對應的進入時間戳表示的時刻為進入時刻;可以計算所述退出時刻和所述進入時刻之間的差值,作為該函式識別對應的運行時間。 在本實施例中,針對所述至少一個函式呼叫鏈中的每個函式呼叫鏈,所述持續整合伺服器可以查找該函式呼叫鏈中是否包括運行時間大於或等於所述預設時間閾值的函式識別;在該函式呼叫鏈中包括運行時間大於或等於預設時間閾值的函式識別時,可以從該函式呼叫鏈中選取對應的運行時間大於或等於所述預設時間閾值的函式識別。所述預設時間閾值可以根據實際需要靈活設定,例如可以為100ms、150ms、或180ms等。 需要說明的是,有鑒於一個函式識別可以對應一對或多對時間戳,一個函式識別可以對應一個或多個運行時間。在函式識別對應的一個或多個運行時間中的任意一個運行時間大於或等於所述預設時間閾值時,所述持續整合伺服器便可以認為該函式識別對應的運行時間大於或等於所述預設時間閾值。 還需要說明的是,在一個函式的運行時間大於或等於所述預設時間閾值時,逐級呼叫直至該函式的其它各個函式的運行時間也均大於或等於所述預設時間閾值。如此,針對所述至少一個函式呼叫鏈中的每個函式呼叫鏈,所述持續整合伺服器從該函式呼叫鏈中選取的函式識別能夠形成該函式呼叫鏈的一個子函式呼叫鏈。 在本實施例的一個場景示例中,所述至少一個函式呼叫鏈可以包括函式呼叫鏈CA和CB。 在本場景示例中,函式呼叫鏈CA可以包括FA、FB、FC、FD、FE等5個函式識別。函式呼叫鏈CA中的函式識別識別的函式間可以具有逐級呼叫關係。具體地,函式識別FA識別的函式可以呼叫函式識別FB識別的函式;函式識別FB識別的函式可以呼叫函式識別FC識別的函式;依次類推,函式識別FD識別的函式可以呼叫函式識別FE識別的函式。在函式呼叫鏈CA中,函式識別FA、FB、FC對應的運行時間大於所述預設時間閾值。 在本場景示例中,函式呼叫鏈CB可以包括FC、FF、FG、FH、FI、FJ等6個函式識別。函式呼叫鏈CB中的函式識別識別的函式間可以具有逐級呼叫關係。具體地,函式識別FC識別的函式可以呼叫函式識別FF識別的函式;函式識別FF識別的函式可以呼叫函式識別FG識別的函式;依次類推,函式識別FI識別的函式可以呼叫函式識別FJ識別的函式。在函式呼叫鏈CB中,函式識別FC、FF、FG、FH對應的運行時間大於所述預設時間閾值。 在本場景示例中,所述持續整合伺服器可以從函式呼叫鏈CA中選取函式識別FA、FB、FC。函式識別FA、FB、FC能夠形成函式呼叫鏈CA的一個子函式呼叫鏈。所述持續整合伺服器可以從函式呼叫鏈CB中選取函式識別FC、FF、FG、FH。函式識別FC、FF、FG、FH能夠形成函式呼叫鏈CB的一個子函式呼叫鏈。 在本實施例的一個實施方式中,所述持續整合伺服器還可以獲取選取的函式識別所對應的運行時間。 在本實施方式的一個場景示例中,所述持續整合伺服器選取的函式識別以及獲取的運行時間可以如下:
Figure 02_image005
Figure 02_image007
其中,函式識別android.os.Handler.dispatchMessage、android.os.Handler.handleCallback、com.alipay.mobile.nebulacore.bridge.H5BridgeImpl$2.run、com.alipay.mobile.nebulacore.bridge.H5BridgeImpl.access$100、com.alipay.mobile.nebulacore.bridge.H5BridgeImpl.executeWeb、com.alibaba.fastjson.JSON.toJSONString、com.alibaba.fastjson.serializer.JSONSerializer.write (783 ms)、com.alibaba.fastjson.serializer.MapSerializer.write、com.alibaba.fastjson.serializer.MapSerializer.write、com.alibaba.fastjson.serializer.ListSerializer.write、com.alibaba.fastjson.serializer.ListSerializer.write、以及com.alibaba.fastjson.serializer.MapSerializer.write能夠形成一個子函式呼叫鏈。函式識別android.os.Handler.dispatchMessage、android.os.Handler.handleCallback、com.alipay.mobile.nebulacore.bridge.H5BridgeImpl$2.run、com.alipay.mobile.nebulacore.bridge.H5BridgeImpl.access$100、com.alipay.mobile.nebulacore.bridge.H5BridgeImpl.executeWeb、com.alibaba.fastjson.JSON.toJSONString、com.alibaba.fastjson.serializer.JSONSerializer.write、com.alibaba.fastjson.serializer.MapSerializer.write、com.alibaba.fastjson.serializer.MapSerializer.write、com.alibaba.fastjson.serializer.ListSerializer.write、com.alibaba.fastjson.serializer.ListSerializer.write、以及com.alibaba.fastjson.serializer.MapSerializer.write能夠形成一個子函式呼叫鏈。 以下介紹本實施例中函式選取方法的一個具有應用場景。值得注意的是,本場景示例僅是為了更好地說明本實施例,並不構成對本實施例的不當限定。 在本場景示例中,在第一時刻,版本伺服器可以向持續整合伺服器發送應用程式第一版本的原始碼。所述持續整合伺服器可以接收所述應用程式第一版本的原始碼,所述應用程式第一版本的原始碼中可以包括除錯碼;可以編譯所述應用程式第一版本的原始碼,得到所述應用程式的第一版本;可以運行所述應用程式的第一版本,得到所述應用程式的第一版本在啟動階段的運行狀態資訊;可以分析啟動相關執行緒在所述運行狀態資訊對應的函式呼叫資訊,得到至少一個函式呼叫鏈;可以從所述至少一個函式呼叫鏈中選取對應的運行時間大於或等於預設時間閾值的函式識別;可以將選取的函式識別識別的函式作為耗時函式。 在本場景示例中,在後續的第二時刻,版本伺服器可以向持續整合伺服器發送應用程式第二版本的原始碼。所述持續整合伺服器可以接收所述應用程式第二版本的原始碼,所述應用程式第二版本的原始碼中可以包括除錯碼;可以編譯所述應用程式第二版本的原始碼,得到所述應用程式的第二版本;可以運行所述應用程式的第二版本,得到所述應用程式的第二版本在啟動階段的運行狀態資訊;可以分析啟動相關執行緒在所述運行狀態資訊對應的函式呼叫資訊,得到至少一個函式呼叫鏈;可以從所述至少一個函式呼叫鏈中選取對應的運行時間大於或等於預設時間閾值的函式識別;可以將選取的函式識別識別的函式作為耗時函式。 在本場景示例中,所述持續整合伺服器可以將所述應用程式第一版本中的耗時函式與所述應用程式第二版本中的耗時函式進行比對;可以輸出所述應用程式第二版本中新增加的耗時函式,或者,可以輸出在所述應用程式第二版本中運行時間變長的耗時函式。這樣開發人員能夠發現所述應用程式第二版本原始碼中的缺陷,便於對所述應用程式第二版本的原始碼進行優化。 在本實施例中,所述持續整合伺服器可以運行原始碼中包括除錯碼的應用程式,得到所述應用程式的運行狀態資訊;可以分析預設執行緒識別對應的函式呼叫資訊,得到所述預設執行緒識別對應的至少一個函式呼叫鏈;可以從所述至少一個函式呼叫鏈中選取對應的運行時間大於或等於預設時間閾值的函式識別。在本實施例中,所述持續整合伺服器可以分析應用程式中預設執行緒識別對應的函式呼叫資訊,得到至少一個函式呼叫鏈;可以基於預設時間閾值從所述至少一個函式呼叫鏈中過濾出耗時函式。這樣,所述持續整合伺服器可以提高耗時函式識別的效率和準確性。 請參閱圖3。本說明書實施例還提供一種伺服器。所述伺服器可以包括以下單元。 運行單元20,用於運行原始碼中包括除錯碼的應用程式,得到所述應用程式的運行狀態資訊;所述運行狀態資訊包括執行緒識別對應的函式呼叫資訊;所述函式呼叫資訊包括函式識別以及函式識別對應的時間戳; 分析單元22,用於分析預設執行緒識別對應的函式呼叫資訊,得到所述預設執行緒識別對應的至少一個函式呼叫鏈;每個所述函式呼叫鏈包括至少一個函式識別; 選取單元24,用於從所述至少一個函式呼叫鏈中選取對應的運行時間大於或等於預設時間閾值的函式識別;函式識別對應的運行時間基於該函式識別對應的時間戳得到。 請參閱圖4。本說明書實施例還提供另一種伺服器。所述伺服器可以包括記憶體和處理器。 在本實施例中,所述記憶體包括但不限於動態隨機存取記憶體(Dynamic Random Access Memory,DRAM)和靜態隨機存取記憶體(Static Random Access Memory,SRAM)等。所述記憶體可以用於儲存電腦指令。 在本實施例中,所述處理器可以按任何適當的方式實現。例如,所述處理器可以採取例如微處理器或處理器以及儲存可由該(微)處理器執行的電腦可讀程式碼(例如軟體或韌體)的電腦可讀媒體、邏輯閘、開關、專用積體電路(Application Specific Integrated Circuit,ASIC)、可程式化邏輯控制器和嵌入微控制器的形式等等。所述處理器可以用於執行所述電腦指令實現以下步驟:運行原始碼中包括除錯碼的應用程式,得到所述應用程式的運行狀態資訊;所述運行狀態資訊包括執行緒識別對應的函式呼叫資訊;所述函式呼叫資訊包括函式識別以及函式識別對應的時間戳;分析預設執行緒識別對應的函式呼叫資訊,得到所述預設執行緒識別對應的至少一個函式呼叫鏈;每個所述函式呼叫鏈包括至少一個函式識別;從所述至少一個函式呼叫鏈中選取對應的運行時間大於或等於預設時間閾值的函式識別;函式識別對應的運行時間基於該函式識別對應的時間戳得到。 需要說明的是,本申請說明書中各個實施例均採用遞進的方式描述,各個實施例之間相同相似的部分互相參見即可,每個實施例重點說明的都是與其他實施例的不同之處。尤其,對於伺服器實施例而言,由於其基本相似於函式選取方法實施例,所以描述的比較簡單,相關之處參見函式選取方法實施例的部分說明即可。 另外,本領域技術人員應當能夠理解的是,所屬領域技術人員在閱讀完本申請說明書之後,可以無需創造性勞動想到本申請檔案中列舉的部分或全部實施方式之間可以組合,這些組合也在本申請公開和保護的範圍內。 在20世紀90年代,對於一個技術的改進可以很明顯地區分是硬體上的改進(例如,對二極體、電晶體、開關等電路結構的改進)還是軟體上的改進(對於方法流程的改進)。然而,隨著技術的發展,當今的很多方法流程的改進已經可以視為硬體電路結構的直接改進。設計人員幾乎都透過將改進的方法流程程式化到硬體電路中來得到相應的硬體電路結構。因此,不能說一個方法流程的改進就不能用硬體實體模組來實現。例如,可程式化邏輯裝置(Programmable Logic Device,PLD)(例如現場可程式化閘陣列(Field Programmable Gate Array,FPGA))就是這樣一種積體電路,其邏輯功能由用戶對裝置程式化來確定。由設計人員自行程式化來把一個數位系統“整合”在一片PLD上,而不需要請晶片製造廠商來設計和製作專用的積體電路晶片。而且,如今,取代手工地製作積體電路晶片,這種程式化也多半改用“邏輯編譯器(logic compiler)”軟體來實現,它與程式開發撰寫時所用的軟體編譯器相類似,而要編譯之前的原始碼也得用特定的程式化語言來撰寫,此稱之為硬體描述語言(Hardware Description Language,HDL),而HDL 也並非僅有一種,而是有許多種,如ABEL(Advanced Boolean Expression Language)、AHDL(Altera Hardware Description Language)、Confluence、CUPL(Cornell University Programming Language)、HDCal、JHDL(Java Hardware Description Language)、Lava、Lola、MyHDL、PALASM、RHDL(Ruby Hardware Description Language)等,目前最普遍使用的是VHDL(Very-High-Speed Integrated Circuit Hardware Description Language ) 與Verilog2。本領域技術人員也應該清楚,只需要將方法流程用上述幾種硬體描述語言稍作邏輯程式化並程式化到積體電路中,就可以很容易得到實現該邏輯方法流程的硬體電路。 上述實施例闡明的系統、裝置、模組或單元,具體可以由電腦晶片或實體實現,或者由具有某種功能的產品來實現。 上述實施例闡明的系統、裝置、模組或單元,具體可以由電腦晶片或實體實現,或者由具有某種功能的產品來實現。一種典型的實現設備為電腦。具體的,電腦例如可以為個人電腦、膝上型電腦、蜂巢式電話、相機電話、智慧型電話、個人數位助理、媒體播放器、導航設備、電子郵件設備、遊戲主機、平板電腦、可穿戴設備或者這些設備中的任何設備的組合。 透過以上的實施方式的描述可知,本領域的技術人員可以清楚地瞭解到本說明書可借助軟體加必需的通用硬體平台的方式來實現。基於這樣的理解,本說明書的技術方案本質上或者說對現有技術做出貢獻的部分可以以軟體產品的形式體現出來,該電腦軟體產品可以儲存在儲存媒體中,如ROM/RAM、磁碟、光碟等,包括若干指令用以使得一台電腦設備(可以是個人電腦,伺服器,或者網路設備等)執行本說明書各個實施例或者實施例的某些部分所述的方法。 本說明書可用於眾多通用或專用的電腦系統環境或配置中。例如:個人電腦、伺服器電腦、手持設備或可攜式設備、平板型設備、多處理器系統、基於微處理器的系統、機上盒、可程式化的消費電子設備、網路PC、小型電腦、大型電腦、包括以上任何系統或設備的分散式計算環境等等。 本說明書可以在由電腦執行的電腦可執行指令的一般上下文中描述,例如程式模組。一般地,程式模組包括執行特定任務或實現特定抽象資料類型的常式、程式、物件、組件、資料結構等等。也可以在分散式計算環境中實踐本說明書,在這些分散式計算環境中,由透過通信網路而被連接的遠端處理設備來執行任務。在分散式計算環境中,程式模組可以位於包括儲存設備在內的本地和遠端電腦儲存媒體中。 雖然透過實施例描繪了本說明書,本領域普通技術人員知道,本說明書有許多變形和變化而不脫離本說明書的精神,希望所附的申請專利範圍包括這些變形和變化而不脫離本說明書的精神。 The technical solutions in the embodiments of the present specification will be described clearly and completely in the following with reference to the drawings in the embodiments of the present specification. Obviously, the described embodiments are only a part of the embodiments of the present specification, but not all the embodiments. Based on the embodiments in this specification, all other embodiments obtained by those of ordinary skill in the art without creative work shall fall within the protection scope of this specification. Please refer to Figure 1. The embodiments of the present specification provide a function selection system. The function selection system may include a version server, a continuous integration server (Continuous Integration Server) and at least one terminal device. In this embodiment, the terminal device may be a terminal device used by developers, such as a personal computer (PC), a server, or the like. The developer can use the terminal device to edit the source code of the application program. The version server can be used to store and manage the source code of each version of the application. For example, the version server may run application version control systems such as SVN (Subversion) and CVS (Concurrent Version System); the source code of each version of the application may be managed based on the application version control system. The continuous integration server can be used to compile and test the source code of the application. In this embodiment, the terminal device may upload the source code of the application program to the version server. The version server can receive and store the source code of the application. The continuous integration server can obtain the source code of the application from the version server; the source code of the application can be compiled to obtain the application; the performance of the application can be tested to obtain the test Results; the test results can be sent to the terminal device. The terminal device may receive the test result. In this way, through the test result, the developer can obtain a function that reflects the performance of the application from the source code of the application. The performance here may be, for example, startup time, or power consumption, etc.; the function may be understood as a set of computer program instructions capable of implementing certain functions. Please refer to Figure 2. The embodiments of the present specification provide a method for selecting functions. The function selection method uses the continuous integration server as an execution subject, and may include the following steps. Step S10: Run the application program including the debugging code in the original code to obtain the running state information of the application program. In this embodiment, the application program may be a computer program for performing one or more tasks. The application program may specifically be any type of application program, for example, it may be a payment type application program, a video playback type application program, or an image processing type application program. In this embodiment, in the development stage of the application program, the developer may insert a debug code in the source code of the application program, so that the running state information of the application program can be obtained when the application program is run. In the subsequent process, by analyzing the running state information, defects in the source code of the application can be found. The debugging code may include a debugging function. The debugging function can be used to generate operating status information. The debugging function may include, for example, Debug.startMethodTracing, Debug.stopMethodTracing, and so on. Of course, the debugging code may also include other functional functions, such as a detection function. The detection function may be used to trigger the debugging function when it is detected that a specific condition is satisfied, for example, when the file in the root directory is detected to be a trigger. In this embodiment, the running state information may include thread identification of at least one thread of the application program, and function call information corresponding to the thread identification. The thread identification can be used to identify the thread, for example, it can be the name or number of the thread. The function call information can be used to describe the function called by the thread identified by the thread identification. The function call information may specifically include at least one function identification, and a time stamp corresponding to the function identification. The function identification can be used to identify the function, for example, it can be the name or number of the function. The time stamp may include an entry time stamp and an exit time stamp. The entry time stamp may be used to indicate the entry time of the function identified by the function identification; the exit time stamp may be used to indicate the exit time of the function identified by the function identification. The running time of the function identified by the function identification can be calculated based on the entry timestamp and the exit timestamp. It should be noted that, given that a thread can call a function one or more times, the function identification in the function call information can correspond to one or more pairs of timestamps, and each pair of timestamps can include an entry time Stamp and an exit timestamp. In a scenario example of this embodiment, the continuous integration server can run an application program that includes a debug code in the source code, thereby obtaining a trace file (trace file). The tracking file may include the running status information of the application program. Specifically, for example, the tracking file may include:
Figure 02_image001
In the above trace file; threadID means thread identification. For example, thread identification 12622 is used to identify thread main; thread identification 12693 is used to identify thread OnLineMonitor. class.method means function recognition. For example, android.os.Handler.dispatchMessage and android.os.MessageQueue.next are function recognition respectively. Action means action. For example, Action may include ent and xit. Ent means to enter the function; xit means to exit the function. usecs means timestamp. For example, 16752 is the entry timestamp corresponding to android.os.Handler.dispatchMessage for function recognition; 18976 is the exit timestamp corresponding to android.os.Handler.dispatchMessage for function recognition. In an implementation of this embodiment, it is considered that the developer can obtain the running state information of the application in different operation stages by inserting debugging codes in different positions of the application source code. For example, the developer can obtain the running status information of the application during the startup phase by inserting a debugging code at the activation code of the source code of the application. The activation code may be a code executed by the application program during the activation phase. As such, the operating state information may include operating state information of the application program in a preset operating stage. The preset operation phase may include a startup phase. Of course, the preset operation stage may also include other stages, for example, a stage for executing a certain function. In this embodiment, the continuous integration server may receive the source code of the application program sent from the version server, and the source code of the application program may include a debug code; it may be based on the source code of the application program, Generate the application program; run the application program to obtain the running status information of the application program. Specifically, the continuous integration server may compile the source code of the application program to obtain the application program. The version server may send the source code of the latest version of the application stored by itself to the continuous integration server every preset time period. The preset time period can be flexibly set according to actual needs, for example, it can be 10 days, 25 days, or 30 days. Or, in view of that the version server generally considers the received source code to be the source code of the latest version of the application, the version server may store and receive the source code of the application from the terminal device Sending the source code of the application to the continuous integration server. In a scenario example of this embodiment, the source code of the application program may include a debugging code. The debugging code may include a detection function and a debugging function. The detection function may be used to trigger the debugging function after detecting that a certain file exists in the root directory, and the file may be, for example, abc.txt. The debugging function may include Debug.startMethodTracing and Debug.stopMethodTracing. Specifically, the debugging function Debug.startMethodTracing may be located at the start position of the startup code in the application source code; the debugging function Debug.stopMethodTracing may be located at the end of the startup code in the application source code position. In this scenario example, after editing the source code of the application, the developer can use the terminal device to send the source code of the application to the version server. The version server can receive and store the source code of the application; the source code of the application can be sent to the continuous integration server. The continuous integration server can receive the source code of the application program; the source code of the application program can be compiled to obtain the application program. The continuous integration server can write a pre-agreed file (such as the file abc.txt) in the root directory to trigger the detection function in the source code of the application; the application can be run to obtain the trace file. The trace file may include information about the running status of the application during the startup phase. Step S12: Analyze the function call information corresponding to the default thread identification to obtain at least one function call chain corresponding to the default thread identification. In this embodiment, the number of the predetermined thread recognition may be one or more. The thread identified by the default thread identification may be part or all of the threads of the application program. For example, the thread identified by the default thread identification may be a thread related to activation of the application program. Specifically, for example, the preset thread identification may include thread identifications 12622 and 12693, thread identification 12622 may be used to identify thread main, and thread identification 12693 may be used to identify thread OnLineMonitor. The function call chain may include at least one function identification. The functions identified by the function identification in each of the function call chains may have a step-by-step call relationship. In a scenario example of this embodiment, a function call chain may include 16 function identifications, specifically including:
Figure 02_image003
The functions identified in the above function call chain may have a step-by-step call relationship. Specifically, the function recognition function com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run can call the function recognition function java.lang.reflect.Method.invoke recognized function; function recognition java.lang.reflect The method identified by .Method.invoke can call the function identified by android.app.ActivityThread.main; by analogy, the function identified by com.alibaba.fastjson.serializer.ListSerializer.write can call the function Identify the function identified by com.alibaba.fastjson.serializer.MapSerializer.write. In this embodiment, for each default thread, the continuous integration server can obtain the function call information corresponding to the default thread in the running state information; the obtained function call information can be Target function call information; the call relationship between the functions identified by each function identification in the target function call information can be analyzed to obtain at least one function call chain corresponding to the thread identification. Step S14: Select, from the at least one function call chain, a function identification whose corresponding running time is greater than or equal to a preset time threshold. In this embodiment, the running time corresponding to the function identification can be obtained based on the time stamp corresponding to the function identification. Specifically, as mentioned above, the time stamp corresponding to the function identification may include an entry time stamp and an exit time stamp. In this way, for each function identification in the at least one function call chain, the continuous integration server may use the exit time stamp corresponding to the function identification as the exit time; the function may identify the corresponding time The time indicated by the entry timestamp is the entry time; the difference between the exit time and the entry time can be calculated as the function to identify the corresponding running time. In this embodiment, for each function call chain in the at least one function call chain, the continuous integration server may find whether the function call chain includes a running time greater than or equal to the preset time Function identification of the threshold; when the function call chain includes function identification whose running time is greater than or equal to the preset time threshold, the corresponding running time can be selected from the function call chain to be greater than or equal to the preset time Function identification of threshold. The preset time threshold may be flexibly set according to actual needs, for example, it may be 100 ms, 150 ms, or 180 ms. It should be noted that, given that one function identification can correspond to one or more pairs of timestamps, one function identification can correspond to one or more runtimes. When any one of the one or more runtimes corresponding to the function identification is greater than or equal to the preset time threshold, the continuous integration server may consider the corresponding runtime of the function identification to be greater than or equal to the The preset time threshold. It should also be noted that when the running time of a function is greater than or equal to the preset time threshold, the running time of each function of the function until the function is also greater than or equal to the preset time threshold . In this way, for each function call chain in the at least one function call chain, the function identification selected by the continuous integration server from the function call chain can form a sub-function of the function call chain Call chain. In a scenario example of this embodiment, the at least one function call chain may include function call chains CA and CB. In this scenario example, the function call chain CA may include five function identifications including FA, FB, FC, FD, and FE. The functions identified in the function call chain CA can have a step-by-step call relationship. Specifically, the function identified by the function identification FA can call the function identified by the function identification FB; the function identified by the function identification FB can call the function identified by the function identification FC; and so on, the function identified by the function identification FD The function can call the function identified by the function identification FE. In the function call chain CA, the running time corresponding to the function recognition FA, FB, and FC is greater than the preset time threshold. In this scenario example, the function call chain CB may include six function identifications, such as FC, FF, FG, FH, FI, and FJ. The functions identified by the function identification in the function call chain CB may have a step-by-step call relationship. Specifically, the function recognized by the function FC can call the function recognized by the function FF; the function recognized by the function FF can call the function recognized by the function FG; and so on, the function recognized by the function FI The function can call the function recognized by the function recognition FJ. In the function call chain CB, the running time corresponding to the function recognition FC, FF, FG, and FH is greater than the preset time threshold. In this scenario example, the continuous integration server can select the function identification FA, FB, FC from the function call chain CA. The function recognition FA, FB, FC can form a sub-function call chain of the function call chain CA. The continuous integration server can select the function identification FC, FF, FG, FH from the function call chain CB. The function recognition FC, FF, FG, FH can form a sub-function call chain of the function call chain CB. In one implementation of this embodiment, the continuous integration server may also obtain the running time corresponding to the selected function identification. In an example of a scenario of this embodiment, the function recognition and the obtained running time selected by the continuous integration server may be as follows:
Figure 02_image005
Figure 02_image007
Among them, function recognition android.os.Handler.dispatchMessage, android.os.Handler.handleCallback, com.alipay.mobile.nebulacore.bridge.H5BridgeImpl$2.run, com.alipay.mobile.nebulacore.bridge.H5BridgeImpl.access$100 , Com.alipay.mobile.nebulacore.bridge.H5BridgeImpl.executeWeb, com.alibaba.fastjson.JSON.toJSONString, com.alibaba.fastjson.serializer.JSONSerializer.write (783 ms), com.alibaba.fastjson.serializer.MapSerializer .write, com.alibaba.fastjson.serializer.MapSerializer.write, com.alibaba.fastjson.serializer.ListSerializer.write, com.alibaba.fastjson.serializer.ListSerializer.write, and com.alibaba.fastjson.serializer.MapSerializer. write can form a sub-function call chain. Function recognition android.os.Handler.dispatchMessage, android.os.Handler.handleCallback, com.alipay.mobile.nebulacore.bridge.H5BridgeImpl$2.run, com.alipay.mobile.nebulacore.bridge.H5BridgeImpl.access$100, com .alipay.mobile.nebulacore.bridge.H5BridgeImpl.executeWeb, com.alibaba.fastjson.JSON.toJSONString, com.alibaba.fastjson.serializer.JSONSerializer.write, com.alibaba.fastjson.serializer.MapSerializer.write, com.alibaba .fastjson.serializer.MapSerializer.write, com.alibaba.fastjson.serializer.ListSerializer.write, com.alibaba.fastjson.serializer.ListSerializer.write, and com.alibaba.fastjson.serializer.MapSerializer.write can form a sub-function Call chain. The following describes one application scenario of the function selection method in this embodiment. It is worth noting that the example of this scenario is only to better illustrate this embodiment, and does not constitute an undue limitation on this embodiment. In this scenario example, at the first moment, the version server may send the source code of the first version of the application to the continuous integration server. The continuous integration server can receive the source code of the first version of the application program, and the source code of the first version of the application program can include a debug code; the source code of the first version of the application program can be compiled to obtain The first version of the application program; the first version of the application program can be run to obtain the running state information of the first version of the application program during the startup phase; the startup-related threads can be analyzed to correspond to the running state information Function call information to obtain at least one function call chain; the corresponding function identification whose running time is greater than or equal to the preset time threshold can be selected from the at least one function call chain; the selected function identification can be identified Function as a time-consuming function. In this scenario example, at a subsequent second moment, the version server may send the source code of the second version of the application to the continuous integration server. The continuous integration server can receive the source code of the second version of the application, and the source code of the second version of the application can include a debug code; the source code of the second version of the application can be compiled to obtain The second version of the application program; can run the second version of the application program to obtain the running state information of the second version of the application program at the startup stage; can analyze the startup-related threads corresponding to the running state information Function call information to obtain at least one function call chain; the corresponding function identification whose running time is greater than or equal to the preset time threshold can be selected from the at least one function call chain; the selected function identification can be identified Function as a time-consuming function. In this scenario example, the continuous integration server can compare the time-consuming function in the first version of the application with the time-consuming function in the second version of the application; the application can be output A newly added time-consuming function in the second version of the program, or a time-consuming function whose running time becomes longer in the second version of the application program can be output. In this way, the developer can find defects in the source code of the second version of the application program, which facilitates optimization of the source code of the second version of the application program. In this embodiment, the continuous integration server can run the application program including the debug code in the source code to obtain the running state information of the application program; the function call information corresponding to the default thread identification can be analyzed to obtain The preset thread recognizes the corresponding at least one function call chain; the corresponding function recognition whose running time is greater than or equal to the preset time threshold can be selected from the at least one function call chain. In this embodiment, the continuous integration server can analyze the function call information corresponding to the default thread recognition in the application program to obtain at least one function call chain; it can be based on the preset time threshold from the at least one function Time-consuming functions are filtered out in the call chain. In this way, the continuous integration server can improve the efficiency and accuracy of time-consuming function recognition. Please refer to Figure 3. An embodiment of this specification also provides a server. The server may include the following units. The running unit 20 is used to run an application program including a debug code in the source code to obtain the running state information of the application program; the running state information includes function call information corresponding to the thread identification; the function call information Including function identification and the time stamp corresponding to the function identification; the analyzing unit 22 is used to analyze the function call information corresponding to the default thread identification to obtain at least one function call chain corresponding to the default thread identification; each Each of the function call chains includes at least one function identification; the selecting unit 24 is configured to select from the at least one function call chain a corresponding function identification whose running time is greater than or equal to a preset time threshold; function identification The corresponding running time is obtained based on the function identifying the corresponding time stamp. Please refer to Figure 4. The embodiment of this specification also provides another server. The server may include a memory and a processor. In this embodiment, the memory includes but is not limited to dynamic random access memory (Dynamic Random Access Memory, DRAM) and static random access memory (Static Random Access Memory, SRAM). The memory can be used to store computer commands. In this embodiment, the processor may be implemented in any suitable manner. For example, the processor may adopt, for example, a microprocessor or a processor and a computer-readable medium storing a computer-readable program code (such as software or firmware) executable by the (micro)processor, a logic gate, a switch, a dedicated Integrated circuit (Application Specific Integrated Circuit, ASIC), programmable logic controller and embedded microcontroller, etc. The processor may be used to execute the computer instructions to implement the following steps: run the application program including the debug code in the source code to obtain the running state information of the application program; the running state information includes a function corresponding to the thread identification Function call information; the function call information includes function identification and the time stamp corresponding to the function identification; analyze the function call information corresponding to the default thread identification to obtain at least one function corresponding to the default thread identification Call chain; each of the function call chains includes at least one function identification; from the at least one function call chain, a corresponding function identification whose running time is greater than or equal to a preset time threshold is selected; a function identification corresponds to The running time is obtained based on the timestamp corresponding to the function identification. It should be noted that the embodiments of the present application are described in a progressive manner. The same and similar parts between the embodiments can be referred to each other. Each embodiment focuses on the differences from other embodiments. Office. In particular, for the server embodiment, since it is basically similar to the function selection method embodiment, the description is relatively simple. For related parts, please refer to the description of the function selection method embodiment. In addition, those skilled in the art should understand that after reading the specification of this application, those skilled in the art may think that some or all of the embodiments listed in the file of this application can be combined without creative efforts. Within the scope of application disclosure and protection. In the 1990s, the improvement of a technology can be clearly distinguished from the improvement of hardware (for example, the improvement of the circuit structure of diodes, transistors, switches, etc.) or the improvement of software (for the process flow Improve). However, with the development of technology, the improvement of many methods and processes can be regarded as a direct improvement of the hardware circuit structure. Designers almost always get the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that the improvement of a method and process cannot be achieved with hardware physical modules. For example, a programmable logic device (Programmable Logic Device, PLD) (such as a field programmable gate array (Field Programmable Gate Array, FPGA)) is such an integrated circuit whose logic function is determined by the user programming the device. It is up to the designer to “integrate” a digital system on a PLD without having to ask a chip manufacturer to design and manufacture a dedicated integrated circuit chip. Moreover, nowadays, instead of manually manufacturing integrated circuit chips, this kind of programming is also mostly implemented using "logic compiler" software, which is similar to the software compiler used in program development and writing. The source code before compilation must also be written in a specific programming language, which is called a hardware description language (Hardware Description Language, HDL), and HDL is not only one, but there are many, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. Currently the most commonly used are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog2. Those skilled in the art should also understand that it is only necessary to logically program the method flow in the above hardware description languages and program it into the integrated circuit, and the hardware circuit that implements the logic method flow can be easily obtained. The system, device, module or unit explained in the above embodiments may be implemented by a computer chip or entity, or by a product with a certain function. The system, device, module or unit explained in the above embodiments may be implemented by a computer chip or entity, or by a product with a certain function. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, and a wearable device Or any combination of these devices. It can be known from the description of the above embodiments that those skilled in the art can clearly understand that this specification can be implemented by means of software plus a necessary general hardware platform. Based on this understanding, the technical solutions of this specification can be embodied in the form of software products in essence or part of the contribution to the existing technology. The computer software products can be stored in storage media, such as ROM/RAM, disk, An optical disc, etc., includes several instructions to enable a computer device (which may be a personal computer, a server, or a network device, etc.) to perform the methods described in the various embodiments of this specification or some parts of the embodiments. This manual can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics devices, network PCs, small Computers, mainframe computers, distributed computing environments including any of the above systems or equipment, etc. This description can be described in the general context of computer-executable instructions executed by a computer, such as a program module. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. This specification can also be practiced in distributed computing environments in which remote processing devices connected through a communication network perform tasks. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices. Although the description is described through the embodiments, those of ordinary skill in the art know that there are many variations and changes in the description without departing from the spirit of the description, and it is hoped that the scope of the attached patent application includes these variations and changes without departing from the spirit of the description .

S10:步驟 S12:步驟 S14:步驟 20:運行單元 22:分析單元 24:選取單元 S10: Step S12: Step S14: Step 20: running unit 22: Analysis unit 24: Select unit

為了更清楚地說明本說明書實施例或現有技術中的技術方案,下面將對實施例或現有技術描述中所需要使用的附圖作簡單地介紹,顯而易見地,下面描述中的附圖僅僅是本說明書中記載的一些實施例,對於本領域普通技術人員來講,在不付出創造性勞動性的前提下,還可以根據這些附圖獲得其他的附圖。 圖1為本說明書實施例一種函式選取系統的示意圖; 圖2為本說明書實施例一種函式選取方法的流程圖; 圖3為本說明書實施例一種伺服器的功能結構圖;以及 圖4為本說明書實施例一種伺服器的功能結構圖。 In order to more clearly explain the embodiments of the present specification or the technical solutions in the prior art, the following will briefly introduce the drawings required in the embodiments or the description of the prior art. Obviously, the drawings in the following description are only Some embodiments described in the specification can be obtained by those skilled in the art without any creative labor, and other drawings can be obtained based on these drawings. 1 is a schematic diagram of a function selection system according to an embodiment of the specification; 2 is a flowchart of a method for selecting a function according to an embodiment of the present specification; 3 is a functional structural diagram of a server according to an embodiment of the specification; and FIG. 4 is a functional structural diagram of a server according to an embodiment of the present specification.

Claims (10)

一種函式選取方法,包括: 運行原始碼中包括除錯碼的應用程式,得到所述應用程式的運行狀態資訊;所述運行狀態資訊包括執行緒識別對應的函式呼叫資訊;所述函式呼叫資訊包括函式識別以及函式識別對應的時間戳; 分析預設執行緒識別對應的函式呼叫資訊,得到所述預設執行緒識別對應的至少一個函式呼叫鏈;每個所述函式呼叫鏈包括至少一個函式識別;以及 從所述至少一個函式呼叫鏈中選取對應的運行時間大於或等於預設時間閾值的函式識別;函式識別對應的運行時間基於該函式識別對應的時間戳得到。 A function selection method, including: Run the application program including the debug code in the source code to obtain the running state information of the application program; the running state information includes the function call information corresponding to the thread identification; the function call information includes the function identification and function To identify the corresponding time stamp; Analyzing the function call information corresponding to the default thread identification to obtain at least one function call chain corresponding to the default thread identification; each function call chain includes at least one function identification; and A function identification corresponding to a running time greater than or equal to a preset time threshold is selected from the at least one function call chain; the running time corresponding to the function identification is obtained based on a time stamp corresponding to the function identification. 如請求項1所述的方法,函式識別對應的時間戳包括進入時間戳和退出時間戳。According to the method of claim 1, the corresponding time stamps of the function identification include entry time stamps and exit time stamps. 如請求項2所述的方法,函式識別對應的運行時間採用如下方式計算得到: 以函式識別對應的退出時間戳表示的時刻為退出時刻,以該函式識別對應的進入時間戳表示的時刻為進入時刻,計算所述退出時刻和所述進入時刻之間的差值,作為該函式識別對應的運行時間。 According to the method described in claim 2, the running time corresponding to the function identification is calculated as follows: The time indicated by the exit time stamp corresponding to the function identification is the exit time, and the time indicated by the entry time stamp corresponding to the function identification is the entry time, and the difference between the exit time and the entry time is calculated as This function identifies the corresponding runtime. 如請求項1所述的方法,所述運行狀態資訊包括所述應用程式在預設運行階段的運行狀態資訊;所述預設運行階段包括啟動階段。According to the method of claim 1, the operation state information includes operation state information of the application program in a preset operation stage; the preset operation stage includes a startup stage. 如請求項1所述的方法,所述運行原始碼中包括除錯碼的應用程式,得到所述應用程式的運行狀態資訊,包括: 接收版本伺服器發來的應用程式的原始碼;所述原始碼中包括除錯碼; 基於所述原始碼,產生所述應用程式;以及 運行所述應用程式,得到所述應用程式的運行狀態資訊。 According to the method of claim 1, the application program including the debugging code in the running source code to obtain the running state information of the application program includes: Receiving the source code of the application program sent from the version server; the source code includes a debugging code; Generating the application based on the source code; and Run the application program to obtain the running state information of the application program. 如請求項1所述的方法,所述分析預設執行緒識別對應的函式呼叫資訊,得到所述預設執行緒識別對應的至少一個函式呼叫鏈,包括: 獲取預設執行緒識別在所述運行狀態資訊中對應的函式呼叫資訊;以及 以獲取的函式呼叫資訊為目標函式呼叫資訊,分析所述目標函式呼叫資訊中各個函式識別識別的函式間的呼叫關係,得到所述預設執行緒識別對應的至少一個函式呼叫鏈。 According to the method of claim 1, the analyzing the function call information corresponding to the default thread identification to obtain at least one function call chain corresponding to the default thread identification includes: Obtaining the function call information corresponding to the default thread identification in the running state information; and Use the acquired function call information as the target function call information, analyze the call relationship between the functions identified by each function in the target function call information, and obtain at least one function corresponding to the default thread identification Call chain. 如請求項1所述的方法,所述從所述至少一個函式呼叫鏈中選取對應的運行時間大於或等於預設時間閾值的函式識別,包括: 針對所述至少一個函式呼叫鏈中的每個函式呼叫鏈,在該函式呼叫鏈包括對應的運行時間大於或等於預設時間閾值的函式識別時,從該函式呼叫鏈中選取對應的運行時間大於或等於預設時間閾值的函式識別;選取的函式識別能夠形成該函式呼叫鏈的一個子函式呼叫鏈。 According to the method of claim 1, the selection of a function identification corresponding to a running time greater than or equal to a preset time threshold from the at least one function call chain includes: For each function call chain in the at least one function call chain, when the function call chain includes a corresponding function identification whose running time is greater than or equal to a preset time threshold, select from the function call chain The corresponding function identification whose running time is greater than or equal to the preset time threshold; the selected function identification can form a sub-function call chain of the function call chain. 如請求項1所述的方法,所述方法還包括: 獲取選取的函式識別所對應的運行時間。 The method according to claim 1, further comprising: Get the running time corresponding to the selected function identification. 一種伺服器,包括: 運行單元,用於運行原始碼中包括除錯碼的應用程式,得到所述應用程式的運行狀態資訊;所述運行狀態資訊包括執行緒識別對應的函式呼叫資訊;所述函式呼叫資訊包括函式識別以及函式識別對應的時間戳; 分析單元,用於分析預設執行緒識別對應的函式呼叫資訊,得到所述預設執行緒識別對應的至少一個函式呼叫鏈;每個所述函式呼叫鏈包括至少一個函式識別;以及 選取單元,用於從所述至少一個函式呼叫鏈中選取對應的運行時間大於或等於預設時間閾值的函式識別;函式識別對應的運行時間基於該函式識別對應的時間戳得到。 A server, including: The running unit is used to run the application program including the debug code in the source code to obtain the running state information of the application program; the running state information includes the function call information corresponding to the thread identification; the function call information includes Function identification and the time stamp corresponding to function identification; An analysis unit, configured to analyze the function call information corresponding to the default thread identification to obtain at least one function call chain corresponding to the default thread identification; each function call chain includes at least one function identification; as well as The selecting unit is configured to select a function identification corresponding to a running time greater than or equal to a preset time threshold from the at least one function call chain; the corresponding operating time of the function identification is obtained based on a time stamp corresponding to the function identification. 一種伺服器,包括: 記憶體,用於儲存電腦指令;以及 處理器,用於執行所述電腦指令實現以下步驟:運行原始碼中包括除錯碼的應用程式,得到所述應用程式的運行狀態資訊;所述運行狀態資訊包括執行緒識別對應的函式呼叫資訊;所述函式呼叫資訊包括函式識別以及函式識別對應的時間戳;分析預設執行緒識別對應的函式呼叫資訊,得到所述預設執行緒識別對應的至少一個函式呼叫鏈;每個所述函式呼叫鏈包括至少一個函式識別;從所述至少一個函式呼叫鏈中選取對應的運行時間大於或等於預設時間閾值的函式識別;函式識別對應的運行時間基於該函式識別對應的時間戳得到。 A server, including: Memory for storing computer commands; and A processor, configured to execute the computer instructions to implement the following steps: run the application program including the debug code in the source code to obtain the running state information of the application program; the running state information includes a function call corresponding to the thread identification Information; the function call information includes function identification and the time stamp corresponding to the function identification; analyze the function call information corresponding to the default thread identification to obtain at least one function call chain corresponding to the default thread identification Each of the function call chains includes at least one function identification; from the at least one function call chain, a corresponding function identification whose running time is greater than or equal to a preset time threshold is selected; a function identification corresponding to the running time Based on this function, the corresponding time stamp is identified.
TW108101178A 2018-03-30 2019-01-11 Function selection method and server TWI684916B (en)

Applications Claiming Priority (3)

Application Number Priority Date Filing Date Title
CN201810278922.7A CN108595319B (en) 2018-03-30 2018-03-30 Function selection method and server
CN201810278922.7 2018-03-30
??201810278922.7 2018-03-30

Publications (2)

Publication Number Publication Date
TW201942736A TW201942736A (en) 2019-11-01
TWI684916B true TWI684916B (en) 2020-02-11

Family

ID=63624002

Family Applications (1)

Application Number Title Priority Date Filing Date
TW108101178A TWI684916B (en) 2018-03-30 2019-01-11 Function selection method and server

Country Status (3)

Country Link
CN (1) CN108595319B (en)
TW (1) TWI684916B (en)
WO (1) WO2019184597A1 (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108595319B (en) * 2018-03-30 2020-08-04 阿里巴巴集团控股有限公司 Function selection method and server
CN112052078A (en) * 2019-06-06 2020-12-08 阿里巴巴集团控股有限公司 Time-consuming determination method and device
CN113127314B (en) * 2019-12-31 2023-10-31 航天信息股份有限公司 Method and device for detecting program performance bottleneck and computer equipment
CN113448815B (en) * 2020-03-26 2022-10-18 华为技术有限公司 Method for collecting and tracking trace call chain and electronic equipment

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8850394B2 (en) * 2008-05-08 2014-09-30 Icera Inc. Debugging system and method
TWI561980B (en) * 2015-10-20 2016-12-11
TW201714085A (en) * 2015-10-02 2017-04-16 緯創資通股份有限公司 Method for monitoring server, monitoring device and monitoring system
CN106874168A (en) * 2017-01-12 2017-06-20 北京奇虎科技有限公司 Determine method, device and the mobile terminal of application program runnability
CN107145429A (en) * 2017-06-01 2017-09-08 成都通甲优博科技有限责任公司 A kind of log analysis method and system

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101482845B (en) * 2008-01-08 2011-08-10 国际商业机器公司 Method and system for calling instant debugger
US8312254B2 (en) * 2008-03-24 2012-11-13 Nvidia Corporation Indirect function call instructions in a synchronous parallel thread processor
CN106909431A (en) * 2015-12-22 2017-06-30 阿里巴巴集团控股有限公司 The method and device of mapping function performance issue
CN105844156A (en) * 2016-03-22 2016-08-10 北京金山安全软件有限公司 Process information acquisition method and device and electronic equipment
CN106649084B (en) * 2016-09-14 2019-05-24 腾讯科技(深圳)有限公司 The acquisition methods and device of function call information, test equipment
CN107480029B (en) * 2017-08-02 2019-02-15 北京深思数盾科技股份有限公司 A kind of monitoring method and device of function call time
CN108595319B (en) * 2018-03-30 2020-08-04 阿里巴巴集团控股有限公司 Function selection method and server

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8850394B2 (en) * 2008-05-08 2014-09-30 Icera Inc. Debugging system and method
TW201714085A (en) * 2015-10-02 2017-04-16 緯創資通股份有限公司 Method for monitoring server, monitoring device and monitoring system
TWI561980B (en) * 2015-10-20 2016-12-11
CN106874168A (en) * 2017-01-12 2017-06-20 北京奇虎科技有限公司 Determine method, device and the mobile terminal of application program runnability
CN107145429A (en) * 2017-06-01 2017-09-08 成都通甲优博科技有限责任公司 A kind of log analysis method and system

Also Published As

Publication number Publication date
CN108595319A (en) 2018-09-28
TW201942736A (en) 2019-11-01
CN108595319B (en) 2020-08-04
WO2019184597A1 (en) 2019-10-03

Similar Documents

Publication Publication Date Title
TWI684916B (en) Function selection method and server
US9111033B2 (en) Compiling source code for debugging with user preferred snapshot locations
WO2018072493A1 (en) Compiling method and compiling system
US8561033B2 (en) Selective branch-triggered trace generation apparatus and method
US9519495B2 (en) Timed API rules for runtime verification
CN106909498B (en) Method and system for injecting fault into Java program
CN109086193B (en) Monitoring method, device and system
CN110046479B (en) Link library file anti-debugging method and device based on android operating system
CN107832059B (en) Code static analysis method and device based on Makefile
Lin et al. Improving the accuracy of automated GUI testing for embedded systems
CN114168222B (en) Method and device for acquiring time consumption during starting, terminal equipment and storage medium
US9117020B2 (en) Determining control flow divergence due to variable value difference
US20170075789A1 (en) Method and apparatus for generating, capturing, storing, and loading debug information for failed tests scripts
Li et al. Effectively manifesting concurrency bugs in android apps
CN116627850B (en) Function debugging method and device, storage medium and electronic equipment
CN113127329B (en) Script debugging method and device and computer storage medium
CN108197005B (en) Method, medium, equipment and system for monitoring bottom layer operation performance of IOS application
US20200272555A1 (en) Automatic software behavior identification using execution record
US20220413815A1 (en) Reload ordering for executable code modules
CN109284222B (en) Software unit, project testing method, device and equipment in data processing system
CN105550575A (en) Method and device for obtaining un-exported function address and data structure offset
CN115705250A (en) Monitoring stack usage to optimize programs
CN111367796B (en) Application program debugging method and device
CN114840427A (en) Code testing and test case generating method and device
CN110275710B (en) Java local interface consistency checking method and system, storage medium and terminal