Multi-dimensional software performance measurement method and device and related medium

By setting timers and performing multi-dimensional statistical queries and analyses, the problem of not being able to summarize the performance analysis of multiple target code segments in existing technologies has been solved, achieving complete performance report output and improving development efficiency.

CN122045018APending Publication Date: 2026-05-15SHENZHEN YANYU TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SHENZHEN YANYU TECHNOLOGY CO LTD
Filing Date
2026-02-03
Publication Date
2026-05-15

AI Technical Summary

Technical Problem

Existing technologies struggle to aggregate statistical data from multiple timers in a single measurement process, making it impossible to obtain complete performance analysis results for multiple target code segments.

Method used

By setting a timer, initializing performance measurements, executing the target code segment and stopping the timer, obtaining timer statistics, performing multi-dimensional statistical queries, calculating parallelism analysis, comparing algorithm performance, and summarizing and outputting a performance report.

Benefits of technology

It enables complete performance analysis of multiple target code segments, improves development efficiency, reduces the coupling between business code and measurement logic, and supports parallelism analysis and algorithm performance comparison.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122045018A_ABST
    Figure CN122045018A_ABST
Patent Text Reader

Abstract

The invention discloses a multi-dimensional software performance measurement method and device and a related medium. The method comprises the steps that corresponding timers are set for all target code segments, performance measurement is initialized, all the timers are started, all the target code segments are executed, all the timers are stopped after execution is completed, and timer statistical data are obtained; performing multi-dimensional statistical query according to the timer statistical data, and performing parallelism analysis to calculate a parallelization factor to obtain analyzed statistical index data; performing algorithm performance comparison on each target code segment according to the analyzed statistical index data to obtain algorithm comparison analysis data; and comparing and analyzing data based on an algorithm, traversing the recorded timers, and summarizing and outputting to obtain performance report data. According to the method, algorithm performance comparison is carried out on the target code segments of the analyzed statistical index data, and then summarizing and outputting are carried out, so that the integrity performance analysis result oriented to the multiple target code segments can be obtained, and the development efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data processing technology, and in particular to a multi-dimensional software performance measurement method, apparatus, and related media. Background Technology

[0002] As software systems become larger and more concurrent, developers need to perform repeatable and summative execution time measurements on multiple target code segments. After obtaining timer statistics, they need to further perform multi-dimensional statistical queries, parallelism analysis, and algorithm performance comparisons, and output unified performance report data. However, existing technologies, whether using manual instrumentation or general performance analysis tools, can usually only provide scattered time-consuming observations or high-overhead sampling results. It is difficult to convert and summarize the timer statistics of each timer in a single measurement process, resulting in developers being unable to obtain complete performance analysis results for multiple target code segments. Summary of the Invention

[0003] This invention provides a multi-dimensional software performance measurement method, apparatus, and related medium, aiming to solve the problem in the prior art that it is difficult to automatically summarize and statistically analyze the execution time of multiple code segments, resulting in the inability to obtain complete performance analysis results for multiple target code segments.

[0004] In a first aspect, embodiments of the present invention provide a multi-dimensional software performance measurement method, including: Set a corresponding timer for each target code segment, initialize performance measurement and start each timer, execute each target code segment, and stop each timer after each target code segment has been executed to obtain timer statistics. Perform multi-dimensional statistical queries based on the timer statistics to obtain statistical indicator data; Parallelism analysis is performed using the statistical index data to calculate the parallelization factor, resulting in analyzed statistical index data. Based on the analyzed statistical index data, the algorithm performance of each target code segment is compared to obtain algorithm comparison analysis data; Based on the algorithm, the recorded timers are compared and analyzed, and the data is summarized and output to obtain the performance report data.

[0005] Secondly, embodiments of the present invention provide a multi-dimensional software performance measurement device, comprising: The timing and statistics unit is used to set corresponding timers for each target code segment, initialize performance measurement and start each timer, execute each target code segment, and stop each timer after each target code segment has been executed, so as to obtain timer statistics data. The dimension statistics unit is used to perform multi-dimensional statistical queries based on the timer statistics data to obtain statistical indicator data; Parallel analysis unit is used to perform parallelism analysis on the statistical index data to calculate the parallelization factor and obtain the analyzed statistical index data. The performance comparison unit is used to compare the algorithm performance of each target code segment based on the analyzed statistical index data to obtain algorithm comparison analysis data. The report output unit is used to compare and analyze the data based on the algorithm, traverse the recorded timers, summarize and output the data to obtain performance report data.

[0006] Thirdly, embodiments of the present invention provide a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the multi-dimensional software performance measurement method of the first aspect.

[0007] Fourthly, embodiments of the present invention provide a computer-readable storage medium, wherein a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, it implements the multi-dimensional software performance measurement method of the first aspect.

[0008] This invention provides a multi-dimensional software performance measurement method, including setting corresponding timers for each target code segment, initializing performance measurement and starting each timer, executing each target code segment, and stopping each timer after the execution of each target code segment, obtaining timer statistics; performing multi-dimensional statistical queries based on the timer statistics to obtain statistical indicator data; using the statistical indicator data to perform parallelism analysis to calculate the parallelization factor, obtaining analyzed statistical indicator data; comparing the algorithm performance of each target code segment based on the analyzed statistical indicator data, obtaining algorithm comparison analysis data; and iterating through the recorded timers based on the algorithm comparison analysis data and summarizing and outputting the results to obtain performance report data. This invention, by comparing the algorithm performance of each target code segment based on the analyzed statistical indicator data and then summarizing and outputting the results, can obtain complete performance analysis results for multiple target code segments, improving development efficiency.

[0009] This invention also provides a multi-dimensional software performance measurement device, a computer device, and a storage medium, which have the same beneficial effects as described above. Attached Figure Description

[0010] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0011] Figure 1 A flowchart illustrating a multi-dimensional software performance measurement method provided in an embodiment of the present invention; Figure 2 This is a schematic block diagram of a multi-dimensional software performance measurement device provided in an embodiment of the present invention. Detailed Implementation

[0012] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0013] It should be understood that, when used in this specification and the appended claims, the terms "comprising" and "including" indicate the presence of the described features, integrals, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or collections thereof.

[0014] It should also be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the invention. As used in this specification and the appended claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise.

[0015] It should also be further understood that the term "and / or" as used in this specification and the appended claims refers to any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.

[0016] Please see below. Figure 1 , Figure 1 The flowchart of a multi-dimensional software performance measurement method provided in an embodiment of the present invention specifically includes steps S101 to S105.

[0017] S101. Set a corresponding timer for each target code segment, initialize performance measurement and start each timer, execute each target code segment, and stop each timer after each target code segment has been executed, and obtain timer statistics. S102. Perform multi-dimensional statistical queries based on the timer statistics to obtain statistical indicator data; S103. Perform parallelism analysis using the statistical index data to calculate the parallelization factor and obtain the analyzed statistical index data. S104. Based on the analyzed statistical index data, compare the algorithm performance of each target code segment to obtain algorithm comparison analysis data; S105. Based on the algorithm, compare and analyze the data, traverse the recorded timers, summarize and output the data to obtain the performance report data.

[0018] In step S101, the program enters the initialization state during the startup phase, pre-establishes a global statistical mapping table for storing statistical information of each timer, and configures a mutex lock to support safe access to statistical data in multi-threaded scenarios. At the same time, the performance measurement switch is read to determine whether the timing function is enabled. If enabled, a timer name is configured for each target code segment to be tested, and the current high-precision time point is obtained through the timer start macro before entering the target code segment. This time point is written as the starting timestamp to the local timestamp variable associated with the timer name. During the execution phase, each target code segment is executed sequentially according to the calling order. When any target code segment finishes execution, a timer is triggered to stop the operation. The end timestamp is obtained through a timestamp reading function, and the difference between the end timestamp and the start timestamp is used to obtain the time consumption record data. Subsequently, the validity of the time consumption record data is verified, abnormal measurement values ​​are identified and filtered to obtain valid time consumption data. During the recording phase, a mutex lock is used to enter the critical section. A timer statistics entry corresponding to the timer name is found or created in the global statistics mapping table. The valid time consumption data is written to the historical record set of the statistics entry, and the accumulated time consumption value and call count counter of the statistics entry are updated synchronously. After completion, the mutex lock is released, thereby obtaining the timer statistics data.

[0019] In one embodiment, step S101 includes: Obtain the program startup event and perform performance measurement initialization processing based on the program startup event; The timer start macro is invoked to start the timer, obtain the current time point, and write the current time point as the start timestamp into the local timestamp variable to obtain the start timing data.

[0020] In this embodiment, upon receiving a program startup event, the performance measurement module enters the initialization phase. During this phase, a global static statistics mapping table is created to store the statistics of each named timer. Simultaneously, a global static mutex is created to provide thread-safe protection during subsequent reading and writing of statistics. During initialization, the value of the compile-time switch ENABLE_PERFORMANCE_TIMING (the master performance measurement switch) is read and checked to determine whether to enable the performance measurement function. When the switch is enabled, subsequent timer startup processing continues. After completing the initialization process, for each target code segment's corresponding timer, a timer startup macro is called to start the timing process. The timer startup macro can use PERF_TIMER_START(timer_name), and after macro expansion, it calls std::chrono::high_resolution_clock::now() (the system high-resolution timestamp acquisition function) to obtain the current time. The obtained current time is written as the starting timestamp to a local timestamp variable so that this starting timestamp can be read and used by subsequent stop-timing operations during the execution of the target code segment.

[0021] Furthermore, to avoid local variable naming conflicts when timer start processing of multiple target code segments is called within the same scope, PERF_TIMER_START(timer_name) automatically generates a timestamp variable with a unique suffix during expansion and associates this timestamp variable with the timer name. In this implementation, the start timestamp is stored in a local variable with the timer name as a suffix, thereby obtaining start timing data consistent with the corresponding timer name, providing a start time reference for subsequent stop timing and statistical recording.

[0022] In one embodiment, step S101 further includes: Execute the target code segment, and after the target code segment is executed, trigger the timer to stop the operation, and call the timestamp reading function to obtain the end timestamp and get the end timer data; The time consumption data is obtained by subtracting the start timestamp recorded in the start timing data from the end timestamp recorded in the end timing data. The time-consuming data is validated to identify and filter outliers, thus obtaining valid time-consuming data. Acquire a mutex lock to enter the critical section, and within the critical section, access the statistics mapping table to find or create a timer statistics entry corresponding to the timer name. Add the valid elapsed time data to the history vector of the timer statistics entry, update the elapsed time accumulation value and call count counter of the timer statistics entry, and release the mutex lock to exit the critical section, thereby obtaining the timer statistics data.

[0023] In this embodiment, after completing the timer start process and obtaining the start timing data, the execution phase of the target code segment begins, and the operation to be tested is executed according to the business logic of the target code segment. The target code segment can be business logic of arbitrary complexity, including algorithm calculation processes, data processing flows, I / O operation sequences, and network communication processes, to ensure that the execution time of different types of code segments can be uniformly measured and recorded. After the target code segment completes execution, the timer is triggered to stop, and the timestamp reading function `std::chrono::high_resolution_clock::now()` is called to obtain the end timestamp, which is then written into the end timing data. Next, the start timestamp recorded in the start timing data is read, and the difference between the end timestamp and the start timestamp is calculated to obtain the time consumption record data corresponding to this execution time. The time consumption record data can be represented in microseconds or milliseconds to adapt to different measurement accuracy requirements.

[0024] After obtaining the time-consuming data, a validity verification process is performed on the data to identify and filter outliers. Outliers include negative measurements and measurements exceeding a preset threshold. Valid time-consuming data is obtained after filtering. Then, a mutex lock acquisition operation is performed to enter the critical section. Within the critical section, the statistical mapping table is accessed to search for the timer statistical entry corresponding to the timer name. If no corresponding entry is found, the timer statistical entry is created in the statistical mapping table, and a historical record vector for storing historical measurements, a cumulative time-consuming value, and a call count counter are initialized.

[0025] After finding or creating the timer statistics entry, the valid elapsed time data is added to the historical record vector of the timer statistics entry, and the accumulated elapsed time value and call count counter of the timer statistics entry are updated synchronously. After the update is completed, the mutex lock is released and the critical section is exited, thereby obtaining the timer statistics data. In specific implementation, the timer stop and recording process can be performed through the macro definition PERF_TIMER_END_US(timer_name) (microsecond-level timer stop interface) or PERF_TIMER_END_MS(timer_name) (millisecond-level timer stop interface), and the elapsed time calculation, validity verification and statistics entry update are completed with microsecond or millisecond precision, respectively.

[0026] In step S102, during the statistical query phase, the statistical query interface is called based on the timer statistical data to obtain the cumulative number of calls and the cumulative total time consumption of each timer. The average execution time is then calculated based on this and written into the corresponding statistical entry. At the same time, extreme value information such as the minimum execution time and the maximum execution time is read, and the number of calls, total time consumption, average time consumption, and extreme value information are integrated into statistical indicator data.

[0027] In one embodiment, step S102 includes: The call count statistics interface is called according to the timer statistics data to obtain the cumulative call count of each timer, and thus obtain the call count statistics data; The total time consumption statistics interface is called based on the timer statistics data to obtain the cumulative total time consumption of each timer, and then associated and stored with the cumulative number of calls to obtain the total time consumption statistics data. Based on the total time consumption statistics, the average execution time is calculated by calling the average time consumption calculation interface, and the average execution time is written into the corresponding statistical entry to obtain the average time consumption statistics. Based on the average execution time statistics, the minimum execution time and maximum execution time are obtained by calling the extreme value execution time statistics interface, and then integrated with the total execution time statistics and the average execution time statistics to obtain statistical indicator data.

[0028] In this embodiment, based on the timer statistics call count statistics interface, a getCallCount() query operation is performed on the statistical entry corresponding to each timer to read the cumulative call count of that timer, and the cumulative call count is written into the call count statistics. Then, based on the timer statistics, the total time consumption statistics interface is called, and a getTotalDuration() query operation is performed on the statistical entry corresponding to each timer to read the cumulative total time consumption of that timer; the cumulative total time consumption and the cumulative call count are then associated and stored, ensuring a correspondence between the call count statistics and the total time consumption statistics for the same timer name, thereby obtaining the total time consumption statistics.

[0029] After reading the number of calls and total execution time, the average execution time calculation interface is called based on the total execution time statistics. The getAverageDuration() operation is executed on each timer to obtain the average execution time, and the average execution time is written into the corresponding statistical entry to obtain the average execution time statistics. The average execution time satisfies the following calculation expression: in, Let n be the execution time for the i-th execution, and n be the total number of calls. After completing the average execution time statistics, the extreme value execution time statistics interface is called based on the average execution time statistics. The getMinDuration() and getMaxDuration() query operations are executed for each timer to obtain the minimum execution time and the maximum execution time. The minimum execution time and the maximum execution time are then integrated and collected with the total execution time statistics and the average execution time statistics to output the statistical indicator data.

[0030] In step S103, during the parallelism analysis phase, all timer statistics entries are traversed, the timer with the largest total time consumption is selected as the master timer and its total time consumption is recorded; the total time consumption of all timers is accumulated to obtain the total time consumption summary data, and the total time consumption summary data is divided by the total time consumption data of the master timer to obtain the parallelization factor. The parallelization factor and the master timer information are written into the statistical index data to obtain the analyzed statistical index data.

[0031] In one embodiment, step S103 includes: Based on the statistical index data, the statistical entries of all timers are traversed to filter the timer with the largest total time consumption as the master timer, and the total time consumption of the master timer is recorded as the master timer total time consumption, thus obtaining the master timer total time consumption data. The total time spent by all timers in the statistical indicator data is summed to obtain the total time summary data. Divide the total time summation data by the total time consumption data of the main timer to obtain the parallelization factor data; The parallelization factor data is processed by parallelism measurement and encapsulation to obtain the analyzed statistical index data.

[0032] In this embodiment, after outputting the statistical index data, parallelism analysis is performed to measure the parallel execution efficiency of the program and calculate the parallelization factor P. First, based on the statistical index data, all timer entries are traversed. For each timer, its total execution time field is read. The timer with the largest total execution time is selected as the master timer, which typically represents the overall execution time. Simultaneously, the total execution time of the master timer is recorded. This yields the total elapsed time of the main timer.

[0033] After determining the master timer, the total elapsed time of all timers is summarized and accumulated based on the aforementioned statistical indicator data. Specifically, this involves reading the total elapsed time of each timer one by one. and for all Perform a summation operation to obtain the total time summary data. Where m is the number of timers. The parallelization factor P is calculated by dividing the total timeout summary by the total main timer timeout, satisfying the following formula: After obtaining the parallelization factor data, parallelism measurement and encapsulation processing is performed on the parallelization factor data. The parallelization factor P is associated with the main timer identification result, the main timer total time consumption data, and the total time consumption summary data, and written to obtain analysis results that can be read by the subsequent algorithm performance comparison and report output stages, thereby obtaining the analyzed statistical index data. Furthermore, when P is greater than 1, it indicates that parallel execution exists, and the larger the value of P, the higher the parallel execution efficiency.

[0034] In step S104, during the algorithm performance comparison stage, the set of timers to be compared is read and the name pairs of the first timer and the second timer are determined. The average execution time of the two timers is extracted from the analyzed statistical index data. The ratio of the average execution time is calculated to obtain the performance ratio data. The difference judgment and result output are performed on the performance ratio data to obtain the algorithm comparison analysis data.

[0035] In one embodiment, step S104 includes: Read the set of timers to be compared, and determine the timer names of two timers to be compared from the set of timers to be compared, to obtain a pair of timer name pairs to be compared; wherein, the pair of timer name pairs to be compared includes a first timer and a second timer; The average execution time is obtained based on the name of the timer to be compared, so as to obtain the average execution time of the first timer and the average execution time of the second timer from the analyzed statistical index data; The performance ratio is obtained by dividing the average execution time of the first timer by the average execution time of the second timer. Perform difference determination and output operations on the performance ratio data respectively to obtain algorithm comparison analysis data.

[0036] In this embodiment, after outputting the analyzed statistical index data, algorithm performance comparison processing is performed to support performance comparison between two timers. A set of timers to be compared is read, and the names of the two timers used for comparison are determined from this set, thus obtaining a pair of timer name pairs to be compared. Each pair includes a first timer and a second timer, and the timer name is used to locate the corresponding statistical entry during subsequent queries. After obtaining the pair of timer name pairs, an average execution time acquisition operation is performed based on these pairs. Specifically, statistical entries corresponding to the first timer name and the second timer name are retrieved from the analyzed statistical index data, and the average execution time T̄1 of the first timer and the average execution time T̄2 of the second timer are read from the corresponding statistical entries. The average execution time is measured in microseconds.

[0037] After completing the average execution time acquisition operation, a performance ratio calculation process is performed. The average execution time of the first timer is divided by the average execution time of the second timer to obtain the performance ratio R, and the performance ratio is recorded as performance ratio data. The performance ratio satisfies R=T̄1 / T̄2, where R represents the relative performance difference between the two algorithms, T̄1 is the average execution time of the first timer, and T̄2 is the average execution time of the second timer.

[0038] After obtaining the performance ratio data, difference determination and output operations are performed on the performance ratio data to generate algorithm comparison analysis data. Specifically, when R > 1, the target code segment corresponding to the first timer is determined to be slower than the target code segment corresponding to the second timer, and the degree of slowness is calculated as (R-1)×100%; when R < 1, the target code segment corresponding to the first timer is determined to be faster than the target code segment corresponding to the second timer, and the degree of speed is calculated as (1-R)×100%; when R = 1, the average execution time of the two is determined to be the same. The algorithm comparison analysis data includes at least the name of the first timer, the name of the second timer, T̄1, T̄2, R, and the corresponding difference determination results and difference magnitudes, and is output as comparison analysis results.

[0039] In step S105, during the report output phase, the recorded timer statistics entries are traversed based on the algorithm's comparative analysis data. The timer name, number of calls, total time consumption, average time consumption, minimum time consumption, and maximum time consumption are summarized and output. Simultaneously, the main timer identification result, total time consumption summary result, and parallelization factor are output, and the data is compiled and output as a performance report. All time data is output in milliseconds, retaining 3 decimal places of precision.

[0040] In one embodiment, after step S105, the following steps are included: Receive reset trigger information and parse the reset range identifier from the reset trigger information; Perform a mutex lock operation to enter the critical section, and access the global statistics map table within the critical section according to the reset range identifier to obtain a map table reference; Perform statistical data cleanup operations based on the mapping table references; Perform a mutex release operation to exit the critical section.

[0041] In this embodiment, a reset trigger information is first received, and a reset range identifier is parsed from the reset trigger information. The reset range identifier indicates whether a global reset or a single-point reset is to be performed, and in the single-point reset scenario, it carries the target timer name (timer_name). A mutex lock operation is performed to enter the critical section, and within the critical section, the global statistics mapping table is accessed to obtain a reference to the mapping table, thereby completing the statistical data cleanup and status update within the same protected area. When the reset range identifier indicates a global reset, a full cleanup process can be triggered by calling resetAll() (global reset method) or PERF_RESET_ALL() (global reset macro). While keeping the mutex lock in the locked state, a reference to the global statistics mapping table is obtained, and the clear() method of the mapping table is called to clear all timer statistics data, delete all key-value pairs, and release related memory. After cleanup, an empty mapping table state that is publicly available is retained so that new timer statistics entries can be recorded subsequently. This global reset is suitable for scenarios such as clearing historical data before starting a new round of performance testing, preparing for the next round of testing after completing a test cycle, clearing old data when switching test scenarios or input datasets, and periodically cleaning up long-running programs to avoid the continuous accumulation of statistical data.

[0042] When the reset range identifier indicates a single-point reset, a targeted cleanup process can be triggered by calling `reset(timer_name)` (a single-point reset method) or `PERF_RESET(timer_name)` (a single-point reset macro). Provided the mutex lock is locked and a reference to the mapping table is obtained, the timer statistics entry corresponding to the timer name is searched in the global statistics mapping table, and a conditional deletion operation is performed: if the target timer statistics entry is found, the corresponding key-value pair is deleted by calling the `erase()` method of the mapping table; if the target timer statistics entry is not found, no deletion operation is performed, and the mapping table content remains unchanged. This single-point reset is suitable for scenarios such as resetting only the statistics of a specific algorithm while retaining the results of other modules, clearing the record of a timer when abnormal data occurs, resetting only the data of one algorithm during algorithm comparison testing, and re-measuring the performance of a specific function during debugging.

[0043] After completing the statistical data cleanup operation, a mutex lock release operation is performed to exit the critical section, thereby allowing other threads to continue reading or writing statistical data. The reset operation and the timer statistical data recording operation use the same mutex lock protection mechanism to ensure that other threads cannot access the global statistical mapping table simultaneously during the reset, avoiding data races during data clearing or deletion, and ensuring the atomicity of the reset process so that the statistical data does not enter an intermediate state of partial cleanup.

[0044] In summary, this application can automatically record the execution time of the target code segment and automatically calculate statistical indicators such as the cumulative number of calls, total cumulative execution time, average execution time, minimum execution time, and maximum execution time. Developers no longer need to manually count, calculate the average, or compare extreme values ​​for multiple executions, thus reducing repetitive statistical work. At the same time, by inserting measurement points through timer start and stop macros, the amount of code required for a single measurement point can be compressed from multiple lines in the traditional way to two lines, reducing the coupling between business code and measurement logic, thereby reducing maintenance costs and improving development efficiency in multi-measurement-point scenarios. Example data shows that development efficiency can be improved by approximately 60%-80%.

[0045] Furthermore, this application implements start / stop control for the performance measurement function through a compile-time switch. In the disabled state, related macros can be expanded into empty statements, without introducing runtime overhead such as function calls, memory allocation, or conditional judgments. Example data shows that the disabled state has 0% impact on program performance, making it suitable for production environment deployment. In concurrent scenarios, the reading and writing of statistical data is protected by mutex locks, and RAII-style lock_guard can be used to ensure exception safety, allowing multiple threads to concurrently use the same or different timer names while maintaining consistency in statistical results. At the same time, this application also provides parallelization factor analysis capabilities, which can automatically identify the main timer (Wall Clock time) and calculate the parallelization factor to quantitatively reflect the parallel execution efficiency. Combined with the algorithm performance comparison function, the average execution time of the two timers is obtained, and the performance ratio and percentage difference are calculated to support algorithm selection. Moreover, the performance measurement logic can be encapsulated into a single header file and only depends on the C++ standard library, making it easy to integrate and providing cross-platform compatibility for Windows / Linux / macOS.

[0046] Combination Figure 2 As shown, Figure 2 This is a schematic block diagram of a multi-dimensional software performance measurement device provided in an embodiment of the present invention. The multi-dimensional software performance measurement device 200 includes: The timing and statistics unit 201 is used to set a corresponding timer for each target code segment, initialize performance measurement and start each timer, execute each target code segment, and stop each timer after each target code segment has been executed, so as to obtain timer statistics data. The dimension statistics unit 202 is used to perform multi-dimensional statistical queries based on the timer statistics data to obtain statistical indicator data; Parallel analysis unit 203 is used to perform parallelism analysis using the statistical index data to calculate the parallelization factor and obtain the analyzed statistical index data. The performance comparison unit 204 is used to compare the algorithm performance of each target code segment based on the analyzed statistical index data to obtain algorithm comparison analysis data. The report output unit 205 is used to compare and analyze the data based on the algorithm, traverse the recorded timers, and summarize and output the data to obtain performance report data.

[0047] In this embodiment, the timing statistics unit 201 sets a corresponding timer for each target code segment, initializes performance measurement and starts each timer, executes each target code segment, and stops each timer after the execution of each target code segment is completed, thereby obtaining timer statistics data; the dimension statistics unit 202 performs multi-dimensional statistical queries based on the timer statistics data to obtain statistical indicator data; the parallel analysis unit 203 uses the statistical indicator data to perform parallelism analysis to calculate the parallelization factor, thereby obtaining analyzed statistical indicator data; the performance comparison unit 204 compares the algorithm performance of each target code segment based on the analyzed statistical indicator data, thereby obtaining algorithm comparison analysis data; and the report output unit 205 iterates through the recorded timers based on the algorithm comparison analysis data and summarizes and outputs the results to obtain performance report data.

[0048] In one embodiment, the timing and statistics unit 201 is specifically used for: Obtain the program startup event and perform performance measurement initialization processing based on the program startup event; The timer start macro is invoked to start the timer, obtain the current time point, and write the current time point as the start timestamp into the local timestamp variable to obtain the start timing data.

[0049] In one embodiment, the timing and statistics unit 201 is further specifically used for: Execute the target code segment, and after the target code segment is executed, trigger the timer to stop the operation, and call the timestamp reading function to obtain the end timestamp and get the end timer data; The time consumption data is obtained by subtracting the start timestamp recorded in the start timing data from the end timestamp recorded in the end timing data. The time-consuming data is validated to identify and filter outliers, thus obtaining valid time-consuming data. Acquire a mutex lock to enter the critical section, and within the critical section, access the statistics mapping table to find or create a timer statistics entry corresponding to the timer name. Add the valid elapsed time data to the history vector of the timer statistics entry, update the elapsed time accumulation value and call count counter of the timer statistics entry, and release the mutex lock to exit the critical section, thereby obtaining the timer statistics data.

[0050] In one embodiment, the dimension statistics unit 202 is specifically used for: The call count statistics interface is called according to the timer statistics data to obtain the cumulative call count of each timer, and thus obtain the call count statistics data; The total time consumption statistics interface is called based on the timer statistics data to obtain the cumulative total time consumption of each timer, and then associated and stored with the cumulative number of calls to obtain the total time consumption statistics data. Based on the total time consumption statistics, the average execution time is calculated by calling the average time consumption calculation interface, and the average execution time is written into the corresponding statistical entry to obtain the average time consumption statistics. Based on the average execution time statistics, the minimum execution time and maximum execution time are obtained by calling the extreme value execution time statistics interface, and then integrated with the total execution time statistics and the average execution time statistics to obtain statistical indicator data.

[0051] In one embodiment, the parallel analysis unit 203 is specifically used for: Based on the statistical index data, the statistical entries of all timers are traversed to filter the timer with the largest total time consumption as the master timer, and the total time consumption of the master timer is recorded as the master timer total time consumption, thus obtaining the master timer total time consumption data. The total time spent by all timers in the statistical indicator data is summed to obtain the total time summary data. Divide the total time summation data by the total time consumption data of the main timer to obtain the parallelization factor data; The parallelization factor data is processed by parallelism measurement and encapsulation to obtain the analyzed statistical index data.

[0052] In one embodiment, the performance comparison unit 204 is specifically used for: Read the set of timers to be compared, and determine the timer names of two timers to be compared from the set of timers to be compared, to obtain a pair of timer name pairs to be compared; wherein, the pair of timer name pairs to be compared includes a first timer and a second timer; The average execution time is obtained based on the name of the timer to be compared, so as to obtain the average execution time of the first timer and the average execution time of the second timer from the analyzed statistical index data; The performance ratio is obtained by dividing the average execution time of the first timer by the average execution time of the second timer. Perform difference determination and output operations on the performance ratio data respectively to obtain algorithm comparison analysis data.

[0053] In one embodiment, the multi-dimensional software performance measurement device 200 is further configured to: Receive reset trigger information and parse the reset range identifier from the reset trigger information; Perform a mutex lock operation to enter the critical section, and access the global statistics map table within the critical section according to the reset range identifier to obtain a map table reference; Perform statistical data cleanup operations based on the mapping table references; Perform a mutex release operation to exit the critical section.

[0054] Since the embodiments of the apparatus and the embodiments of the method correspond to each other, please refer to the description of the embodiments of the method for the embodiments of the apparatus, which will not be repeated here.

[0055] This invention also provides a computer-readable storage medium storing a computer program thereon, which, when executed, can perform the steps provided in the above embodiments. The storage medium may include various media capable of storing program code, such as a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0056] This invention also provides a computer device, which may include a memory and a processor. The memory stores a computer program, and when the processor calls the computer program in the memory, it can implement the steps provided in the above embodiments. Of course, the computer device may also include various network interfaces, a power supply, a graphics card, etc., to utilize the graphics card's performance to operate the model, such as for inference and training.

[0057] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the systems disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple; relevant parts can be referred to in the method section. It should be noted that those skilled in the art can make various improvements and modifications to this application without departing from the principles of this application, and these improvements and modifications also fall within the protection scope of the claims of this application.

[0058] It should also be noted that, in this specification, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

Claims

1. A multi-dimensional software performance measurement method, characterized in that, include: Set a corresponding timer for each target code segment, initialize performance measurement and start each timer, execute each target code segment, and stop each timer after each target code segment has been executed to obtain timer statistics. Perform multi-dimensional statistical queries based on the timer statistics to obtain statistical indicator data; Parallelism analysis is performed using the statistical index data to calculate the parallelization factor, resulting in analyzed statistical index data. Based on the analyzed statistical index data, the algorithm performance of each target code segment is compared to obtain algorithm comparison analysis data; Based on the algorithm, the recorded timers are compared and analyzed, and the data is summarized and output to obtain the performance report data.

2. The multi-dimensional software performance measurement method according to claim 1, characterized in that, After comparing and analyzing the recorded timers based on the algorithm and summarizing the data to obtain the performance report data, the process includes: Receive reset trigger information and parse the reset range identifier from the reset trigger information; Perform a mutex lock operation to enter the critical section, and access the global statistics map table within the critical section according to the reset range identifier to obtain a map table reference; Perform statistical data cleanup operations based on the mapping table references; Perform a mutex release operation to exit the critical section.

3. The multi-dimensional software performance measurement method according to claim 1, characterized in that, The initialization of performance measurements and the starting of each timer include: Obtain the program startup event and perform performance measurement initialization processing based on the program startup event; The timer start macro is invoked to start the timer, obtain the current time point, and write the current time point as the start timestamp into the local timestamp variable to obtain the start timing data.

4. The multi-dimensional software performance measurement method according to claim 3, characterized in that, The execution of each target code segment, and the stopping of each timer after the execution of each target code segment, yields timer statistics, including: Execute the target code segment, and after the target code segment is executed, trigger the timer to stop the operation, and call the timestamp reading function to obtain the end timestamp and get the end timer data; The time consumption data is obtained by subtracting the start timestamp recorded in the start timing data from the end timestamp recorded in the end timing data. The time-consuming data is validated to identify and filter outliers, thus obtaining valid time-consuming data. Acquire a mutex lock to enter the critical section, and within the critical section, access the statistics mapping table to find or create a timer statistics entry corresponding to the timer name. Add the valid elapsed time data to the history vector of the timer statistics entry, update the elapsed time accumulation value and call count counter of the timer statistics entry, and release the mutex lock to exit the critical section, thereby obtaining the timer statistics data.

5. The multi-dimensional software performance measurement method according to claim 1, characterized in that, The step of performing multi-dimensional statistical queries based on the timer statistics to obtain statistical indicator data includes: The call count statistics interface is called according to the timer statistics data to obtain the cumulative call count of each timer, and thus obtain the call count statistics data; The total time consumption statistics interface is called based on the timer statistics data to obtain the cumulative total time consumption of each timer, and then associated and stored with the cumulative number of calls to obtain the total time consumption statistics data. Based on the total time consumption statistics, the average execution time is calculated by calling the average time consumption calculation interface, and the average execution time is written into the corresponding statistical entry to obtain the average time consumption statistics. Based on the average execution time statistics, the minimum execution time and maximum execution time are obtained by calling the extreme value execution time statistics interface, and then integrated with the total execution time statistics and the average execution time statistics to obtain statistical indicator data.

6. The multi-dimensional software performance measurement method according to claim 1, characterized in that, The step of performing parallelism analysis using the statistical index data to calculate the parallelization factor, and obtaining the analyzed statistical index data, includes: Based on the statistical index data, the statistical entries of all timers are traversed to filter the timer with the largest total time consumption as the master timer, and the total time consumption of the master timer is recorded as the master timer total time consumption, thus obtaining the master timer total time consumption data. The total time spent by all timers in the statistical indicator data is summed to obtain the total time summary data. Divide the total time summation data by the total time consumption data of the main timer to obtain the parallelization factor data; The parallelization factor data is processed by parallelism measurement and encapsulation to obtain the analyzed statistical index data.

7. The multi-dimensional software performance measurement method according to claim 1, characterized in that, The algorithm performance comparison of each target code segment is performed based on the analyzed statistical index data to obtain algorithm comparison analysis data, including: Read the set of timers to be compared, and determine the timer names of two timers to be compared from the set of timers to be compared, to obtain a pair of timer name pairs to be compared; wherein, the pair of timer name pairs to be compared includes a first timer and a second timer; The average execution time is obtained based on the name of the timer to be compared, so as to obtain the average execution time of the first timer and the average execution time of the second timer from the analyzed statistical index data; The performance ratio is obtained by dividing the average execution time of the first timer by the average execution time of the second timer. Perform difference determination and output operations on the performance ratio data respectively to obtain algorithm comparison analysis data.

8. A multi-dimensional software performance measurement device, characterized in that, include: The timing and statistics unit is used to set corresponding timers for each target code segment, initialize performance measurement and start each timer, execute each target code segment, and stop each timer after each target code segment has been executed, so as to obtain timer statistics data. The dimension statistics unit is used to perform multi-dimensional statistical queries based on the timer statistics data to obtain statistical indicator data; Parallel analysis unit is used to perform parallelism analysis on the statistical index data to calculate the parallelization factor and obtain the analyzed statistical index data. The performance comparison unit is used to compare the algorithm performance of each target code segment based on the analyzed statistical index data to obtain algorithm comparison analysis data. The report output unit is used to compare and analyze the data based on the algorithm, traverse the recorded timers, summarize and output the data to obtain performance report data.

9. A computer device, characterized in that, It includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the multi-dimensional software performance measurement method as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the multi-dimensional software performance measurement method as described in any one of claims 1 to 7.