Method and device for determining performance grade of application program interface and electronic equipment

By receiving and analyzing the external and internal response information of the API, building scores and frequency levels, and eliminating exception data, the problem of inaccurate API performance evaluation is solved, and comprehensive and accurate evaluation and optimization of API performance is achieved.

CN120386734APending Publication Date: 2025-07-29YGSOFT INC
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510498937.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-18
Publication Date
2025-07-29

AI Technical Summary

Technical Problem

The performance evaluation of application program interfaces in the prior art lacks comprehensiveness, ignores the quality of the internal design of the API, and is susceptible to abnormal data interference, resulting in inaccurate evaluation results and difficult to identify and optimize performance bottlenecks.

Method used

By receiving response information of external requests and instance response information, external request scores, score levels and frequency levels are constructed, combined with preset level standards, the performance level of the API is determined, abnormal data is eliminated, and the activity and quality dimensions of the API are considered to achieve a comprehensive evaluation.

Benefits of technology

It realizes refined management of API performance, and can accurately identify and optimize an API with poor performance and frequent call, improving system stability and user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120386734A_ABST
    Figure CN120386734A_ABST
Patent Text Reader

Abstract

The invention discloses a method and device for determining the performance grade of an application program interface and electronic equipment, and relates to the technical field of software engineering.The determining method comprises the steps that a plurality of external requests for calling a target application program interface within a preset time period are received, and collecting first response information of each external request in the target application program interface and second response information of an instance corresponding to each external request in the target application program interface, determining an external request score based on all the first response information and all the second response information, and determining an external request score based on the external request score and a preset score level. Determining a score level of the target application program interface, determining a frequency level of the target application program interface in a preset time period based on a preset frequency level, and determining a performance level of the target application program interface based on the score level and the frequency level. According to the method and the device, the technical problem of relatively low accuracy of performance evaluation on the application program interface in related technologies is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of software engineering, and in particular, to a method and apparatus for determining the performance level of an application programming interface, and an electronic device. Background Art

[0002] In software development, an API (Application Programming Interface) serves as a bridge for communication between systems and affects the performance of the system and the user experience. Current API quality assessment methods mainly focus on external manifestations, such as evaluating response time, availability, etc., and the API quality assessment relies on monitoring tools and log analysis tools.

[0003] Although current API quality assessment methods and tools can analyze the basic performance indicators of an API, the following problems exist: (1) Quality factors in the internal design of the API are ignored, such as database query efficiency, cache usage, asynchronous processing ability, etc. A single-dimensional assessment may lead to misjudgment of the API quality, lacking in-depth analysis of the internal operations of the API and unable to comprehensively reflect the true performance of the API; (2) Existing monitoring tools can record the response time of the API, but cannot analyze in detail the database query time, cache hit rate, etc. inside the API. This limitation makes it lack comprehensive data support when optimizing the API; (3) The API assessment process may be interfered by abnormal data, such as abnormal response times caused by network fluctuations or system failures. These abnormal data may lead to inaccurate assessment results, thereby affecting the decision-making of developers to optimize the API.

[0004] The above problems make it difficult for developers to accurately identify and solve the performance bottleneck of the API. Therefore, there is an urgent need for a method that can comprehensively evaluate the API quality to help developers more effectively optimize the API performance.

[0005] In response to the above problems, no effective solution has been proposed yet. Summary of the Invention

[0006] Embodiments of the present invention provide a method and apparatus for determining the performance level of an application programming interface, and an electronic device, so as to at least solve the technical problem of low accuracy in performance assessment of an application programming interface in related technologies.

[0007] According to one aspect of the embodiments of the present invention, a method for determining the performance level of an application programming interface is provided, including: receiving a plurality of external requests for calling a target application programming interface within a preset time period, and collecting first response information of each external request within the target application programming interface and second response information of an instance corresponding to each external request within the target application programming interface, wherein the target application programming interface calls at least one instance based on the external request, and the instance is used to execute the operation corresponding to the external request; determining an external request score based on all the first response information and all the second response information, and determining the score level of the target application programming interface based on the external request score and a preset score level; determining the frequency level of the target application programming interface within the preset time period based on a preset frequency level; determining the performance level of the target application programming interface based on the score level and the frequency level.

[0008] Further, before determining the external request score based on all the first response information and all the second response information, it further includes: dividing a preset score into multiple levels, and configuring a score level for each level; constructing a preset score level based on each level and the score level corresponding to each level; configuring multiple frequency levels, and configuring a response count range for each frequency level; constructing a preset frequency level based on each frequency level and the response count range corresponding to each frequency level.

[0009] Further, the first response information at least includes: multiple metrics, each metric corresponding to a metric value. Before determining the external request score based on all the first response information and all the second response information, it further includes: sorting the metric values corresponding to the metrics for each of all the external requests to obtain a sorted set of metrics; for each sorted set of metrics, removing the metric values in the sorted set based on a preset removal rule to obtain a target sorted set; characterizing the external requests indicated by each target metric value in the target sorted set as abnormal external requests; determining the external request score based on the abnormal external requests and all the second response information.

[0010] Further, the second response information at least includes: multiple metrics, each metric corresponding to metric data. The step of determining the external request score based on the abnormal external requests and all the second response information includes: adding other external requests to a target request set, where the other external requests are external requests other than the abnormal external requests; for each of the other external requests in the target request set, determining a preset deduction level of the metric data of the instance corresponding to the other external request; deducting points from the metric data corresponding to each preset deduction level according to a preset deduction rule to obtain deduction data for each metric data; determining the external request score based on all the preset deduction levels and all the deduction data.

[0011] Further, the metrics at least include: response time metrics, and there is response time data corresponding to the response time metrics. Before determining the score level of the target application programming interface based on the external request score and the preset score level, it further includes: adding up all the response time data to obtain the total response time; determining the number of external requests, and calculating the average response time of the external requests based on the total response time and the number of all external requests; calculating the standard deviation of the average response time based on the average response time, each response time data, and the number of external requests.

[0012] Further, after calculating the standard deviation of the average response time, it further includes: determining the fluctuation range of the response time based on the average response time and the standard deviation; deducting points from the fluctuation range according to the preset fluctuation range deduction rule to obtain the first preset score of the fluctuation range.

[0013] Further, the step of determining the score level of the target application programming interface based on the external request score and the preset score level includes: calculating the number of other external requests in the target request set, and calculating the average external request score based on the number of other external requests and the external request score; configuring a first preset weight for the first preset score and a second preset weight for the average external request score; determining the score level based on the first preset weight, the second preset weight, and the preset score level.

[0014] According to another aspect of the embodiments of the present invention, there is also provided a device for determining the performance level of an application programming interface, including: a first acquisition unit, configured to receive a plurality of external requests for calling the target application programming interface within a preset time period, and acquire the first response information of each external request within the target application programming interface and the second response information of the instance corresponding to each external request within the target application programming interface, where the target application programming interface calls at least one instance based on the external request, and the instance is used to execute the operation corresponding to the external request; a first determination unit, configured to determine the external request score based on all the first response information and all the second response information, and determine the score level of the target application programming interface based on the external request score and the preset score level; a second determination unit, configured to determine the frequency level of the target application programming interface within the preset time period based on the preset frequency level; a third determination unit, configured to determine the performance level of the target application programming interface based on the score level and the frequency level.

[0015] Furthermore, the apparatus for determining the performance level of the application programming interface includes: a first configuration module, configured to divide a preset score into multiple levels and configure a score level for each level before determining an external request score based on all the first response information and all the second response information; a first construction module, configured to construct a preset score level based on each level and the score level corresponding to each level; a second configuration module, configured to configure multiple frequency levels and configure a response count range for each frequency level; a second construction module, configured to construct a preset frequency level based on each frequency level and the response count range corresponding to each frequency level.

[0016] Furthermore, the first response information at least includes: multiple metrics, each metric corresponding to a metric value. The apparatus for determining the performance level of the application programming interface further includes: a first sorting module, configured to sort the metric values corresponding to the metrics for each of all the external requests to obtain a sorted set of metrics before determining an external request score based on all the first response information and all the second response information; a first elimination module, configured to eliminate the metric values in the sorted set of metrics based on a preset elimination rule for each sorted set of metrics to obtain a target sorted set; a first characterization module, configured to characterize the external requests indicated by each target metric value in the target sorted set as abnormal external requests; a first determination module, configured to determine an external request score based on the abnormal external requests and all the second response information.

[0017] Furthermore, the second response information at least includes: multiple metrics, each metric corresponding to metric data. The first determination module includes: a first addition sub-module, configured to add other external requests to a target request set, where the other external requests are external requests other than the abnormal external requests; a first determination sub-module, configured to determine a preset deduction level of the metric data of the instance corresponding to each of the other external requests in the target request set; a first deduction sub-module, configured to deduct points from the metric data corresponding to each preset deduction level based on a preset deduction rule to obtain deduction data for each metric data; a second determination sub-module, configured to determine an external request score based on all the preset deduction levels and all the deduction data.

[0018] Further, the metrics at least include: response duration metrics, and corresponding response duration data. The apparatus for determining the performance level of the application programming interface further includes: a first summing module, configured to sum all the response duration data to obtain a total response duration before determining the score level of the target application programming interface based on the external request score and the preset score level; a first calculation module, configured to determine the number of external requests, and calculate the average response duration of the external requests according to the total response duration and the number of all external requests; a second calculation module, configured to calculate the standard deviation of the average response duration according to the average response duration, each response duration data, and the number of external requests.

[0019] Further, the apparatus for determining the performance level of the application programming interface further includes: a second determination module, configured to determine the fluctuation range of the response duration according to the average response duration and the standard deviation after calculating the standard deviation of the average response duration; a second deduction module, configured to deduct points from the fluctuation range according to the preset fluctuation range deduction rule to obtain a first preset score of the fluctuation range.

[0020] Further, the first determination unit includes: a third calculation module, configured to calculate the number of other external requests in the target request set, and calculate the average external request score based on the number of other external requests and the external request score; a third configuration module, configured to configure a first preset weight for the first preset score and a second preset weight for the average external request score; a third determination module, configured to determine the score level according to the first preset weight, the second preset weight, and the preset score level.

[0021] According to another aspect of the embodiments of the present invention, there is also provided a computer program product, including a non-volatile computer-readable storage medium storing a computer program, where the computer program, when executed by a processor, implements the method for determining the performance level of the application programming interface according to any one of the above.

[0022] According to another aspect of the embodiments of the present invention, there is also provided an electronic device, including one or more processors and a memory, where the memory is used to store one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors implement the method for determining the performance level of the application programming interface according to any one of the above.

[0023] In the present invention, a plurality of external requests for invoking a target application programming interface within a preset time period are received, and first response information of each external request within the target application programming interface and second response information of an instance corresponding to each external request within the target application programming interface are collected. Based on all the first response information and all the second response information, an external request score is determined, and based on the external request score and a preset score level, a score level of the target application programming interface is determined. Based on a preset frequency level, a frequency level of the target application programming interface within the preset time period is determined. Based on the score level and the frequency level, a performance level of the target application programming interface is determined, thereby solving the technical problem of low accuracy in performance evaluation of application programming interfaces in the related art.

[0024] In the present invention, a plurality of external requests for invoking a target application programming interface within a preset time period are received, and first response information of each external request within the target application programming interface is collected. Then, an instance of the target application programming interface is invoked according to the external request, and second response information of each instance is collected. By combining all the first response information and all the second response information, an external request score is obtained. This score is a comprehensive evaluation of the instant response ability and internal operation standardization of the API. Then, by comparing the external request score with a preset score level, the score level of the target application programming interface is quantified. At the same time, according to a preset frequency level, the invocation frequency of the target application programming interface within the preset time period is counted, and according to the preset frequency level, the frequency level of the target application programming interface is determined. After that, according to the score level and the frequency level, the performance level of the target application programming interface is determined. The present invention takes into account both the quality dimension of the API and the API activity, and preferentially optimizes the application programming interfaces that are frequently invoked but have a low quality score, thereby enabling refined management of the performance of application programming interfaces and achieving the technical effect of accurately and comprehensively evaluating application programming interfaces. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of the present invention. The schematic embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:

[0026] Figure 1 is a flowchart of an optional method for determining the performance level of an application programming interface according to an embodiment of the present invention;

[0027] Figure 2 is a flowchart of an optional method for determining the quality level of an application programming interface according to an embodiment of the present invention;

[0028] Figure 3 is a schematic diagram of an optional device for determining the performance level of an application programming interface according to an embodiment of the present invention;

[0029] Figure 4 It is a hardware block diagram of an electronic device (or mobile device) for a method of determining a performance level of an application programming interface according to an embodiment of the present invention. Detailed implementation manners

[0030] In order to enable those skilled in the art of the present technology to better understand the solution of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.

[0031] It should be noted that the terms "first", "second", etc. in the description and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and do not necessarily need to describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device comprising a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products or devices.

[0032] It should be noted that the relevant information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) collected and involved in the present invention are all information and data authorized by the user or fully authorized by all parties. And the processing of collection, storage, use, processing, transmission, provision, disclosure and application of relevant data all comply with the relevant laws, regulations and standards in the relevant regions, take necessary confidentiality measures, do not violate public order and good customs, and provide corresponding operation entrances for users to choose to authorize or refuse. For example, an interface is set between the present system and relevant users or institutions. Before obtaining relevant information, a request for obtaining needs to be sent to the aforementioned users or institutions through the interface, and after receiving the consent information feedback from the aforementioned users or institutions, the relevant information is obtained.

[0033] In the present invention, aiming at the problem that the current evaluation method mainly focuses on the external performance of the API, lacks a comprehensive analysis of the internal design quality of the API, resulting in incomplete and inaccurate evaluation results, and lacks a comprehensive evaluation combining the usage frequency and quality of the API, leading to the inability to effectively guide developers to allocate resources reasonably. By introducing an abnormal data processing mechanism and conducting a comprehensive evaluation in combination with the API usage frequency, it is ensured that developers can prioritize optimizing the APIs with poor performance, thereby achieving the optimal allocation of resources and improving the stability of the system and the user experience.

[0034] The present invention will be described in detail below in conjunction with each embodiment.

[0035] Embodiment 1

[0036] According to an embodiment of the present invention, an embodiment of a method for determining the performance level of an application programming interface is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. And, although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than here.

[0037] Figure 1 is a flowchart of an alternative method for determining the performance level of an application programming interface according to an embodiment of the present invention, as Figure 1 shown, the method includes the following steps:

[0038] Step S101, receive a plurality of external requests for calling a target application programming interface within a preset time period, and collect first response information of each external request within the target application programming interface and second response information of an instance corresponding to each external request within the target application programming interface, where the target application programming interface calls at least one instance based on the external request, and the instance is used to execute an operation corresponding to the external request.

[0039] Optionally, the preset time period can be any set cycle, such as one day, one hour or one minute, depending on the evaluation granularity and real-time requirements, and is not limited here.

[0040] In this embodiment, receive a plurality of external requests for calling a target application programming interface within a preset time period, and collect first response information of each external request within the target application programming interface (including but not limited to: response duration, response size, status code, etc.), and at the same time collect second response information of an instance corresponding to each external request within the target application programming interface. The instance is a backend service (i.e., execute an operation corresponding to the external request) called by the target application programming interface when processing an external request, such as database query, cache operation, asynchronous thread execution, etc. The collection of the second response information goes deep into the internal operation level of the API to evaluate the efficiency and standardization of the internal design of the API.

[0041] Optionally, data collection can be implemented through different monitoring tools, which is not limited here.

[0042] Optionally, the second response information includes multiple metrics, such as response duration, response result size, repetition count, count of the same operation type, etc., and these metrics can be divided into design quality metrics (such as count of the same operation type, count of repeated calls to the same statement, etc.) and runtime quality metrics (such as response duration, response result size, etc.).

[0043] Step S102: Based on all the first response information and all the second response information, determine the external request score, and based on the external request score and the preset score levels, determine the score level of the target application programming interface.

[0044] In this embodiment, according to all the first response information and all the second response information, the external request score is determined. The first response information relates to the immediate feedback of the API for each external request, and the second response information delves into the internal operation level of the API, focusing on the instances called by the API when processing requests. This external request score is a comprehensive evaluation of the API response quality and internal operation efficiency.

[0045] In this embodiment, the external request score can be compared with the preset score levels (pre - defined deduction score intervals and corresponding level labels) to determine the score level of the target application programming interface.

[0046] Exemplarily, the preset score levels map the score intervals of the API to specific levels, such as: greater than 25 points: level 1, greater than 15 points: level 2, greater than 5 points: level 3, greater than or equal to 0 points: level 4. If the calculated external request score is 14 points, then according to the preset score levels, the score level of this API (i.e., the target application programming interface) is determined to be level 3.

[0047] Step S103: Based on the preset frequency levels, determine the frequency level of the target application programming interface within the preset time period.

[0048] Optionally, the preset frequency levels are pre - defined frequency levels, which can be set according to the number of external requests within the preset time period as: less than 1 time: level 4, 1 - 3 times: level 3, 4 - 6 times: level 2, greater than or equal to 7 times: level 1.

[0049] In this embodiment, by counting the number of calls of the API within the preset time period, it can be classified into the corresponding frequency level in the preset frequency levels. For example, if the number of calls to a certain API within one day is 8 times, then the frequency level of this API (i.e., the target application programming interface) is level 1.

[0050] Step S104: Determine the performance level of the target application programming interface (API) based on the score level and the frequency level.

[0051] In this embodiment, the performance level of the API is comprehensively judged by combining the quality of the API (score level) and the usage frequency of the API (frequency level). For example, the maximum or minimum value of the score level and the frequency level can be taken as the performance level of the API.

[0052] Optionally, in the above example, the smaller the preset score level, the larger the score, indicating the worse the performance of the API. The smaller the preset frequency level, the larger the number of times, indicating that the API is frequently called. Therefore, taking the minimum value of the score level and the frequency level indicates that when the performance of the API is poor and it is frequently called, it needs to be optimized first.

[0053] In some alternative embodiments, the larger the preset score level, the larger the score, indicating the worse the performance of the API. The larger the preset frequency level, the larger the number of times, indicating that the API is frequently called. Therefore, taking the maximum value of the score level and the frequency level indicates that when the performance of the API is poor and it is frequently called, it needs to be optimized first.

[0054] It should be noted that the above levels and values can be freely set without any restrictions here.

[0055] Exemplarily, the code for comprehensively evaluating the API performance is as follows:

[0056] def evaluate_api_quality(scores,frequency):

[0057] average_score = sum(scores) / len(scores);

[0058] frequency_level = determine_frequency_level(frequency);

[0059] return min(average_score,frequency_level).

[0060] In summary, by collecting the first response information of multiple external requests and the second response information of internal instance operations within a preset time period, comprehensively analyzing the first response information and the second response information to determine the external request score, and then according to the preset score level and the external request score, the quality of the API can be quantified into a score level. At the same time, the activity of the API is evaluated according to the preset frequency level. Finally, combining the score level and the frequency level to determine the performance level of the API can achieve a comprehensive and accurate dynamic monitoring of the API performance, thereby solving the technical problem of low accuracy in performance evaluation of application program interfaces in the related art.

[0061] In the method for determining the performance level of an application program interface provided in the first embodiment of the present application, in order to accurately construct the preset score level and the preset frequency level, the preset score is divided into multiple levels, and a score level is configured for each level; based on each level and the score level corresponding to each level, a preset score level is constructed; multiple frequency levels are configured, and a response count range is configured for each frequency level; based on each frequency level and the response count range corresponding to each frequency level, a preset frequency level is constructed.

[0062] In this embodiment, the preset score can be divided into multiple levels, such as 0-5, 6-15, 16-25, >25, and a score level is configured for each level, such as level 4, level 3, level 2, level 1. According to each level and the score level corresponding to each level, a preset score level is constructed, such as 0-5 corresponding to level 4, 6-15 corresponding to level 3, 16-25 corresponding to level 2, >25 corresponding to level 1.

[0063] In this embodiment, multiple frequency levels are configured, such as level 4, level 3, level 2, level 1, and a response count range is configured for each frequency level, such as 0, 1-2, 3-7, >7. According to each frequency level and the response count range corresponding to each frequency level, a preset frequency level is constructed, such as 0 corresponding to level 4, 1-2 corresponding to level 3, 3-7 corresponding to level 2, >7 corresponding to level 1.

[0064] The first response information at least includes: multiple metrics, each metric corresponding to a metric value. In the method for determining the performance level of an application program interface provided in the first embodiment of the present application, for each metric of all external requests, the metric values corresponding to the metrics are sorted to obtain a sorted set of metrics; for each sorted set of metrics, based on a preset elimination rule, the metric values in the sorted set of metrics are eliminated to obtain a target sorted set; the external requests indicated by each target metric value in the target sorted set are characterized as abnormal external requests; based on the abnormal external requests and all the second response information, the external request score is determined.

[0065] Optionally, the first response information includes at least multiple metrics, each metric corresponding to a metric value. For each metric of all external requests, the metric values of each metric (such as response time, response size, etc.) are sorted to form a sorted set of metrics. For example, for the metric of response time, the response times of all API requests will be sorted to form a sequence of response times from the shortest to the longest.

[0066] In this embodiment, in order to filter out abnormal data caused by objective factors such as network latency and server failures and ensure the accuracy and reliability of the final evaluation result, for the sorted set of each metric, abnormal values in the sorted set can be removed according to a preset removal rule (such as removing the top 5% and the bottom 5% of the response time distribution), that is, those metric values that are much higher or lower than other response times in the set, to obtain a target sorted set.

[0067] In this embodiment, after removing the abnormal values, the external requests corresponding to each target metric value in the target sorted set can be marked as abnormal external requests, and based on all external requests except the abnormal external requests and all second response information (i.e., the response information of API internal instance operations), the quality of the API can be comprehensively analyzed to determine its external request score.

[0068] In some optional embodiments, a machine learning algorithm (such as Isolation Forest) can be used to detect abnormal external requests.

[0069] Exemplarily, the code for abnormal data processing is as follows:

[0070] def remove_outliers(data,threshold=0.05):

[0071] sorted_data=sorted(data);

[0072] cutoff_index=int(len(sorted_data)*(1-threshold));

[0073] return sorted_data[:cutoff_index]。

[0074] The second response information at least includes: multiple metrics, each metric corresponding to metric data. In order to improve the accuracy of determining the external request score, in the method for determining the performance level of the application programming interface provided in the first embodiment of the present application, other external requests are added to the target request set, where the other external requests are external requests other than abnormal external requests; for each other external request in the target request set, determine the preset deduction level of the metric data of the instance corresponding to the other external request; according to the preset deduction rule, deduct points from the metric data corresponding to each preset deduction level to obtain the deduction data of each metric data; based on all the preset deduction levels and all the deduction data, determine the external request score.

[0075] In this embodiment, all external requests other than abnormal external requests (i.e., other external requests) are added to the target request set, that is, abnormal data has been excluded, and the target request set only contains data under normal operation, providing a pure sample for subsequent analysis.

[0076] Optionally, the second response information includes various metrics of API internal instance operations, each metric corresponding to metric data.

[0077] In this embodiment, for each other external request in the target request set, determine the preset deduction level of the metric data of the instance corresponding to the other external request. For example, for the metric of response time, a longer response time can be assigned a higher deduction level (such as level 4), and a shorter response time can be assigned a lower deduction level (such as level 1), and the same applies to other metrics.

[0078] Optionally, the preset deduction rule is a pre-set deduction rule. For example, in 3 external requests, the deduction levels of the response time metric of a certain instance are level 1, level 2, and level 3 respectively, corresponding to deductions of 5 points, 10 points, and 15 points respectively.

[0079] It should be noted that the deduction values can be freely set and are not restricted here.

[0080] In this embodiment, according to the preset deduction rule, points can be deducted from the metric data corresponding to each preset deduction level to obtain the deduction data of each metric data, and the deduction level of all metric data is multiplied by the corresponding deducted score to obtain the external request score.

[0081] The metrics at least include: the response time metric, and the response time metric corresponds to response time data. In the method for determining the performance level of the application programming interface provided in the first embodiment of the present application, in order to accurately obtain the standard deviation of the average response time, all the response time data are added up to obtain the total response time; the number of external requests is determined, and based on the total response time and the number of all external requests, the average response time of the external requests is calculated; based on the average response time, each response time data, and the number of external requests, the standard deviation of the average response time is calculated.

[0082] In this embodiment, the metrics of the first response information at least include the response time metric, and the response time metric corresponds to response time data. All the response time data can be added up to obtain the total response time, and the total response time can reflect the overall time consumption of the API for processing external requests within a preset time period.

[0083] In this embodiment, the number of all external requests within the same preset time period is determined, and based on the total response time and the number of all external requests, the average response time of the external requests is calculated (that is, the total response time is divided by the number of all external requests), and then based on the average response time, each response time data, and the number of external requests, the standard deviation of the average response time is calculated. The standard deviation can reflect the volatility of the API response time. The smaller the standard deviation, the more stable the API response time; otherwise, it indicates that the API response time fluctuates greatly.

[0084] In the method for determining the performance level of the application programming interface provided in the first embodiment of the present application, in order to accurately obtain the first preset score of the fluctuation range, based on the average response time and the standard deviation, the fluctuation range of the response time is determined; according to the preset deduction rule for the fluctuation range, the fluctuation range is deducted to obtain the first preset score of the fluctuation range.

[0085] In this embodiment, based on the average response time and the standard deviation, the fluctuation range of the response time can be determined (that is, the standard deviation is divided by the average response time).

[0086] In this embodiment, the preset fluctuation amplitude deduction rule includes the fluctuation amplitude and the corresponding deduction value. For example, if the fluctuation amplitude exceeds 20% on the basis of 100% (i.e., 1, when less than or equal to 1, it means the response time is relatively stable), 20 points will be deducted. That is, if the fluctuation amplitude is between 0% and 5%, the deduction value is 5 points; if the fluctuation amplitude is between 5% and 10%, the deduction value is 10 points; if the fluctuation amplitude is between 10% and 15%, the deduction value is 15 points; if the fluctuation amplitude is between 15% and 20%, the deduction value is 20 points, and so on. And according to this preset fluctuation amplitude deduction rule, the fluctuation amplitude is deducted to obtain the first preset score of the fluctuation amplitude. For example, if the fluctuation amplitude exceeds 15% to 20% on the basis, 20 points will be deducted (i.e., the first preset score).

[0087] It should be noted that the above deduction values can be set arbitrarily and are not limited here.

[0088] In order to accurately determine the score level, in the method for determining the performance level of the application program interface provided in the first embodiment of the present application, the number of other external requests in the target request set is calculated, and the average external request score is calculated based on the number of other external requests and the external request score; a first preset weight is configured for the first preset score, and a second preset weight is configured for the average external request score; the score level is determined according to the first preset weight, the second preset weight, and the preset score level.

[0089] In this embodiment, the number of normal external requests (i.e., other external requests) in the target request set is calculated, and the average external request score is calculated according to the number of other external requests and the external request score (i.e., average external request score = external request score / number of other external requests), which can reflect the average quality level of the API when processing normal requests.

[0090] In this embodiment, in order to comprehensively evaluate the API quality, a first preset weight and a second preset weight can be respectively configured for the first preset score and the average external request score. The setting of the weight can be determined according to specific scenarios and requirements. For example, if the stability of the response duration is particularly important, the second preset weight will be set larger.

[0091] In this embodiment, the comprehensive score can be calculated according to the first preset weight and the second preset weight. For example, comprehensive score = first preset weight * first preset score + second preset weight * average external request score. And according to the preset score level, the level of this comprehensive score (i.e., the score level) is determined.

[0092] In an embodiment of the present invention, by collecting response information and internal operation information of a target application programming interface, analyzing these metrics to remove abnormal data, then calculating a first preset score and an average external request score, and respectively configuring different weights for them, according to the weights of the two and a preset score level, a score level is obtained. After that, by combining the frequency level and the score level of the target application programming interface, the performance level of the target application programming interface is determined. By combining external response information and internal operation information, it is possible to accurately and comprehensively evaluate the performance of the target application programming interface. Developers can optimize the application programming interface according to this performance level, thereby improving the quality of the application programming interface.

[0093] Figure 2 It is a flowchart for optionally determining the quality level of an application programming interface according to an embodiment of the present invention. As Figure 2 shown, first, sum up the deductions for all monitored items (i.e., metrics) to obtain the external request score, and then deduct points according to the API specification (i.e., according to the number of other external requests and the external request score) to obtain the average external request score. At the same time, deduct points for API stability (i.e., deduct points for the fluctuation range) to obtain the first preset score for the fluctuation range. Then, assign weights to the average external request score obtained by deducting points according to the API specification and the first preset score obtained by deducting points for API stability (e.g., the deduction according to the API specification accounts for 80%, and the deduction for API stability accounts for 20%) to obtain the API health level (i.e., the score level). In addition, analyze the frequency of API requests, and determine the API request frequency level according to a preset frequency level. After that, according to the API health level and the API request frequency level, obtain the API exception level (i.e., the performance level).

[0094] The following is a detailed description in combination with another embodiment.

[0095] Embodiment 2

[0096] The device for determining the performance level of an application programming interface provided in this embodiment includes multiple implementation units, and each implementation unit corresponds to each implementation step in Embodiment 1 above.

[0097] Figure 3 It is a schematic diagram of an optional device for determining the performance level of an application programming interface according to an embodiment of the present invention. As Figure 3 shown, the device for determining the performance level of the application programming interface may include: a first collection unit 30, a first determination unit 31, a second determination unit 32, and a third determination unit 34.

[0098] Among them, the first acquisition unit 30 is configured to receive multiple external requests for invoking the target application programming interface within a preset time period, and acquire the first response information of each external request within the target application programming interface and the second response information of the instance corresponding to each external request within the target application programming interface. The target application programming interface invokes at least one instance based on the external request, and the instance is used to execute the operation corresponding to the external request;

[0099] The first determination unit 31 is configured to determine the external request score based on all the first response information and all the second response information, and determine the score level of the target application programming interface based on the external request score and the preset score level;

[0100] The second determination unit 32 is configured to determine the frequency level of the target application programming interface within the preset time period based on the preset frequency level;

[0101] The third determination unit 34 is configured to determine the performance level of the target application programming interface based on the score level and the frequency level.

[0102] The above device for determining the performance level of the application programming interface can receive multiple external requests for invoking the target application programming interface within a preset time period through the first acquisition unit 30, and acquire the first response information of each external request within the target application programming interface and the second response information of the instance corresponding to each external request within the target application programming interface. It can determine the external request score based on all the first response information and all the second response information through the first determination unit 31, and determine the score level of the target application programming interface based on the external request score and the preset score level. It can determine the frequency level of the target application programming interface within the preset time period based on the preset frequency level through the second determination unit 32, and determine the performance level of the target application programming interface based on the score level and the frequency level through the third determination unit 34.

[0103] Optionally, the device for determining the performance level of the application programming interface includes: a first configuration module, configured to divide the preset score into multiple levels and configure a score level for each level before determining the external request score based on all the first response information and all the second response information; a first construction module, configured to construct the preset score level based on each level and the score level corresponding to each level; a second configuration module, configured to configure multiple frequency levels and configure a response count range for each frequency level; a second construction module, configured to construct the preset frequency level based on each frequency level and the response count range corresponding to each frequency level.

[0104] Optionally, the first response information at least includes: multiple metrics, each metric corresponding to a metric value. The apparatus for determining the performance level of the application programming interface further includes: a first sorting module, configured to sort the metric values corresponding to the metrics for each of all external requests before determining the external request score based on all the first response information and all the second response information, to obtain a sorted set of metrics; a first elimination module, configured to eliminate the metric values in the sorted set of metrics based on a preset elimination rule for each sorted set of metrics, to obtain a target sorted set; a first characterization module, configured to characterize the external requests indicated by each target metric value in the target sorted set as abnormal external requests; and a first determination module, configured to determine the external request score based on the abnormal external requests and all the second response information.

[0105] Optionally, the second response information at least includes: multiple metrics, each metric corresponding to metric data. The first determination module includes: a first addition sub-module, configured to add other external requests to a target request set, where the other external requests are external requests other than the abnormal external requests; a first determination sub-module, configured to determine a preset deduction level of the metric data of the instance corresponding to each of the other external requests in the target request set; a first deduction sub-module, configured to deduct points from the metric data corresponding to each preset deduction level based on a preset deduction rule, to obtain deduction data for each metric data; and a second determination sub-module, configured to determine the external request score based on all the preset deduction levels and all the deduction data.

[0106] Optionally, the metrics at least include: a response duration metric, the response duration metric corresponding to response duration data. The apparatus for determining the performance level of the application programming interface further includes: a first summation module, configured to sum all the response duration data before determining the score level of the target application programming interface based on the external request score and a preset score level, to obtain a total response duration; a first calculation module, configured to determine the number of external requests, and calculate an average response duration of the external requests based on the total response duration and the number of all external requests; and a second calculation module, configured to calculate a standard deviation of the average response duration based on the average response duration, each response duration data, and the number of external requests.

[0107] Optionally, the apparatus for determining the performance level of the application programming interface further includes: a second determination module, configured to determine a fluctuation range of the response duration based on the average response duration and the standard deviation after calculating the standard deviation of the average response duration; and a second deduction module, configured to deduct points from the fluctuation range based on a preset fluctuation range deduction rule, to obtain a first preset score of the fluctuation range.

[0108] Optionally, the first determination unit includes: a third calculation module, configured to calculate the number of other external requests in the target request set, and calculate an average external request score based on the number of other external requests and the external request score; a third configuration module, configured to configure a first preset weight for the first preset score and a second preset weight for the average external request score; and a third determination module, configured to determine the score level according to the first preset weight, the second preset weight, and the preset score level.

[0109] The above-mentioned apparatus for determining the performance level of an application programming interface may further include a processor and a memory. The above-mentioned first acquisition unit 30, first determination unit 31, second determination unit 32, third determination unit 34, etc. are all stored in the memory as program units, and the processor executes the above-mentioned program units stored in the memory to implement corresponding functions.

[0110] The above-mentioned processor includes a kernel, and the kernel retrieves the corresponding program units from the memory. One or more kernels may be provided, and by adjusting the kernel parameters, the performance level of the target application programming interface is determined based on the score level and the frequency level.

[0111] The above-mentioned memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of, for example, read-only memory (ROM) or flash memory (flash RAM), and the memory includes at least one storage chip.

[0112] According to another aspect of the embodiments of the present invention, there is also provided a computer program product, including a non-volatile computer-readable storage medium, the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, it implements the method for determining the performance level of an application programming interface according to any one of the above.

[0113] When the computer program product is executed on a data processing device, it is adapted to execute a program initialized with the following method steps: receiving a plurality of external requests for invoking a target application programming interface within a preset time period, and collecting first response information of each external request within the target application programming interface and second response information of an instance corresponding to each external request within the target application programming interface; determining an external request score based on all the first response information and all the second response information, and determining the score level of the target application programming interface based on the external request score and the preset score level; determining the frequency level of the target application programming interface within the preset time period based on the preset frequency level; and determining the performance level of the target application programming interface based on the score level and the frequency level.

[0114] According to another aspect of the embodiments of the present invention, there is also provided an electronic device, including one or more processors and a memory, where the memory is used to store one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors are caused to implement the method for determining the performance level of the above application programming interface.

[0115] Figure 4 is a hardware structural block diagram of an electronic device (or mobile device) for a method for determining the performance level of an application programming interface according to an embodiment of the present invention. As Figure 4 shown, the electronic device may include one or more processors (for example, Figure 4 processor 402a, processor 402b,..., processor 402n in Figure 4 , and these processors may include, but are not limited to, processing devices such as a microprocessor MCU or a field programmable gate array FPGA), and a memory 404 for storing data. In addition, it may further include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the I / O interface), a network interface, a keyboard, a power supply, and / or a camera. Those of ordinary skill in the art can understand that Figure 4 the structure shown is only illustrative and does not limit the structure of the above electronic device. For example, the electronic device may further include more or fewer components than Figure 4 shown in Figure 4 , or have a different configuration from Figure 4 shown.

[0116] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.

[0117] The embodiments or examples of the present disclosure are not exhaustive, but only illustrative of some embodiments or examples, and do not specifically limit the protection scope of the present disclosure. Without conflict, each step in an embodiment or example can be implemented as an independent embodiment, and the steps can be combined arbitrarily. For example, the solution after removing some steps in an embodiment or example can also be implemented as an independent embodiment, and the order of the steps in an embodiment or example can be arbitrarily exchanged. In addition, the optional ways or optional examples in an embodiment or example can be combined arbitrarily; furthermore, the embodiments or examples can be combined arbitrarily. For example, some or all of the steps of different embodiments or examples can be combined arbitrarily, and an embodiment or example can be combined arbitrarily with the optional ways or optional examples of other embodiments or examples.

[0118] In the above embodiments of the present invention, the descriptions of the respective embodiments have their own emphases. For the parts not detailed in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0119] In several embodiments provided by the present invention, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are merely illustrative. For example, the division of the units can be a logical function division. In actual implementation, there can be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the couplings, direct couplings, or communication connections shown or discussed among each other can be through some interfaces. The indirect couplings or communication connections of units or modules can be in electrical or other forms.

[0120] The units described as separate components may or may not be physically separated. The components shown as units may or may not be physical units, that is, they can be located in one place or distributed to multiple units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0121] In addition, in each embodiment of the present invention, the functional units can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units.

[0122] If the above-mentioned integrated units are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: USB flash drives, read-only memories (ROMs), random access memories (RAMs), mobile hard disks, magnetic disks, or optical discs, and other various media that can store program codes.

[0123] The above are only the preferred embodiments of the present invention. It should be noted that for those of ordinary skill in the art, without departing from the principle of the present invention, several improvements and refinements can be made, and these improvements and refinements should also be regarded as the protection scope of the present invention.

Claims

1. A method for determining the performance level of an application programming interface, characterized in that including: Receiving a plurality of external requests for invoking a target application programming interface within a preset time period, and collecting first response information of each of the external requests within the target application programming interface and second response information of an instance corresponding to each of the external requests within the target application programming interface, wherein the target application programming interface invokes at least one of the instances based on the external requests, and the instance is used to execute an operation corresponding to the external request; Determining an external request score based on all of the first response information and all of the second response information, and determining a score level of the target application programming interface based on the external request score and a preset score level; Determining a frequency level of the target application programming interface within the preset time period based on a preset frequency level; Determining a performance level of the target application programming interface based on the score level and the frequency level.

2. The method for determining the performance level of an application programming interface according to claim 1, characterized in that Before determining the external request score based on all of the first response information and all of the second response information, further including: Dividing a preset score into multiple levels, and configuring a score level for each of the levels; Constructing the preset score level based on each of the levels and the score level corresponding to each of the levels; Configuring multiple frequency levels, and configuring a response count range for each of the frequency levels; Constructing the preset frequency level based on each of the frequency levels and the response count range corresponding to each of the frequency levels.

3. The method for determining the performance level of the application programming interface according to claim 1, characterized in that The first response information at least includes: multiple metrics, each of the metrics corresponding to a metric value. Before determining the external request score based on all of the first response information and all of the second response information, further including: Sorting the metric values corresponding to each of the metrics for all of the external requests to obtain a sorted set of the metrics; For each of the sorted sets, eliminating the metric values in the sorted set based on a preset elimination rule to obtain a target sorted set; Characterizing the external requests indicated by each target metric value in the target sorted set as abnormal external requests; Determining the external request score based on the abnormal external requests and all of the second response information.

4. The method for determining the performance level of the application program interface according to claim 3, characterized in that, The second response information at least includes: multiple metrics, each of the metrics corresponding to metric data. The step of determining the external request score based on the abnormal external requests and all of the second response information includes: Adding other external requests to a target request set, where the other external requests are the external requests other than the abnormal external requests; For each of the other external requests in the target request set, determining a preset deduction level of the metric data of the instance corresponding to the other external request; Deducting points from the metric data corresponding to each of the preset deduction levels according to a preset point deduction rule to obtain deduction data of each of the metric data; Determining the external request score based on all of the preset deduction levels and all of the deduction data.

5. The method for determining the performance level of an application programming interface according to claim 3, wherein The indicators at least include: response duration indicator, and corresponding response duration data. Before determining the score level of the target application programming interface based on the external request score and the preset score levels, it further includes: Adding up all the response duration data to obtain the total response duration; Determining the number of the external requests, and calculating the average response duration of the external requests based on the total response duration and the number of all the external requests; Calculating the standard deviation of the average response duration based on the average response duration, each response duration data, and the number of the external requests.

6. The method for determining the performance level of the application programming interface according to claim 5, characterized in that After calculating the standard deviation of the average response duration, it further includes: Determining the fluctuation range of the response duration based on the average response duration and the standard deviation; Deducting points from the fluctuation range according to the preset fluctuation range point deduction rule to obtain the first preset score of the fluctuation range.

7. The method for determining the performance level of an application programming interface according to claim 4, wherein The steps of determining the score level of the target application programming interface based on the external request score and the preset score levels include: Calculating the number of the other external requests in the target request set, and calculating the average external request score based on the number of the other external requests and the external request score; Configuring a first preset weight for the first preset score, and configuring a second preset weight for the average external request score; Determining the score level based on the first preset weight, the second preset weight, and the preset score levels.

8. An apparatus for determining a performance level of an application programming interface, characterized in that It includes: A first acquisition unit, configured to receive a plurality of external requests for invoking the target application programming interface within a preset time period, and acquire first response information of each of the external requests in the target application programming interface and second response information of an instance corresponding to each of the external requests in the target application programming interface. Wherein, the target application programming interface invokes at least one of the instances based on the external request, and the instance is used to execute the operation corresponding to the external request; A first determination unit, configured to determine the external request score based on all the first response information and all the second response information, and determine the score level of the target application programming interface based on the external request score and the preset score levels; A second determination unit, configured to determine the frequency level of the target application programming interface within the preset time period based on the preset frequency levels; A third determination unit, configured to determine the performance level of the target application programming interface based on the score level and the frequency level.

9. A computer program product, characterized in that, It includes a non-volatile computer-readable storage medium storing a computer program, and when the computer program is executed by a processor, it implements the method for determining the performance level of the application programming interface according to any one of claims 1 to 7.

10. An electronic device, characterized in that, It includes one or more processors and a memory, and the memory is used to store one or more programs. Wherein, when the one or more programs are executed by the one or more processors, the one or more processors implement the method for determining the performance level of the application programming interface according to any one of claims 1 to 7.