A script running result comparison method, system, device and product

By automating batch execution and cross-comparison functions, the problem of time-consuming and inefficient manual comparison is solved, enabling fast and accurate comparison of results from M-lang scripts and ensuring consistency between Mlang-compatible tools and Matlab software results.

CN119377112BActive Publication Date: 2026-02-03SHENZHEN JINGYUAN SHUYU TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411445582.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-16
Publication Date
2026-02-03
Estimated Expiration
2044-10-16

AI Technical Summary

Technical Problem

In existing technologies, manually comparing the results of M-language scripts one by one in Matlab software and Mlang-compatible tools is time-consuming and inefficient, especially when the number of scripts is large.

Method used

The system employs automated batch execution and comparison functions using scripts. It uses Matlab software and Mlang-compatible tools to automatically run the scripts to be executed in batches, obtains the results, performs cross-comparison, and generates comparison result data.

Benefits of technology

This technology enables rapid batch verification of the consistency between the output of Mlang-compatible tools and the output of Matlab software, improving verification efficiency and accuracy, and ensuring the functional correctness and performance consistency after code porting.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119377112B_ABST
    Figure CN119377112B_ABST
Patent Text Reader

Abstract

The present application belongs to the technical field of software testing, and aims to provide a script running result comparison method, system, device and product. The script running result comparison method comprises the following steps: first, creating a script automatic batch running function and an automatic comparison function; then, after obtaining a to-be-run script, calling the script automatic batch running function to automatically batch run the to-be-run script through Matlab software and obtain a first script running result and a second script running result; finally, calling the automatic comparison function to cross-compare the first script running result and the second script running result and obtain comparison result data. The present application can batch process multiple scripts through Matlab software and Mlang compatible tools respectively, and can automatically compare the running results of two scripts to obtain comparison result data, which is convenient for users to quickly confirm whether the result output by the Mlang compatible tool is accurate.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of software testing technology, specifically relating to a method, system, device, and product for comparing script execution results. Background Technology

[0002] Currently, there are numerous M-language (a scratchpad-based programming language) scripts that can run and output results in Matlab (a commercial mathematical software produced by MathWorks). Using Mlang-compatible tools (M-language compatible tools), M-language scripts originally designed for Matlab can run in Syslab (a Windows-based control system simulation software that can simulate the operation of various control systems, including PID control, fuzzy control, and neural network control). In other words, M-lang can be run and output results in Syslab using Mlang-compatible tools.

[0003] However, when porting M-lang scripts from Matlab to Syslab using Mlang-compatible tools, it's crucial to ensure consistency between the output of the M-lang-compatible tool and the output of the M-lang-compatible script in Matlab. In other words, the results obtained when running the same M-lang-compatible script in both tools should be identical or within an acceptable margin of error. Currently, this is typically done manually, comparing the outputs of the same M-lang-compatible script in Matlab and the Mlang-compatible tool one by one to verify the accuracy of the output from the Mlang-compatible tool.

[0004] However, in using the prior art, the inventors discovered at least the following problems:

[0005] In existing technologies, the method of manually comparing each script is very time-consuming and inefficient, especially when the number of M-language scripts is large.

[0006] Therefore, it is necessary to study an automated comparison scheme that can quickly and in batches verify whether the results of running M language scripts in Mlang-compatible tools are consistent with the results of running them in Matlab software. Summary of the Invention

[0007] The present invention aims to solve, at least to some extent, the technical problem of the above-mentioned method of manual comparison, which is very time-consuming and inefficient. The present invention provides a script execution result comparison method, system, device and product.

[0008] To achieve the above objectives, the present invention adopts the following technical solution:

[0009] In a first aspect, the present invention provides a method for comparing script execution results, including:

[0010] Create a function for automated batch execution of scripts and an automated comparison function; wherein, the function for automated batch execution of scripts is used to automatically run specified scripts in batches and store the script execution results obtained after the specified scripts are run; the automated comparison function is used to perform cross-comparison processing on the execution results of any two scripts;

[0011] Get the script to be run;

[0012] The script is automated in batches and the function is called so that the script to be run can be automated in batches using Matlab software to obtain the first script running result.

[0013] The script is automated in batches and the execution function is called so that the script to be run can be automated in batches using Mlang-compatible tools to obtain the execution result of the second script.

[0014] The automated comparison function is invoked to perform cross-comparison processing on the results of the first script execution and the second script execution, so as to obtain the comparison result data.

[0015] In one possible design, the automated batch execution function for scripts includes a script execution function and a script path management function; correspondingly, the automated batch execution function for scripts is called to automatically batch execute the scripts to be run using a specified script execution tool, and to obtain the script execution results, including:

[0016] The specified script execution tool receives the specified path where the script to be run is located and the script name of the script to be run;

[0017] The specified script execution tool inputs the specified path and the script name into the script path management function, and inputs the script name into the script execution function. This allows the script path management function to obtain a dependency table matching the script to be run based on the specified path, and the script execution function to automatically batch run all scripts in the script to be run based on the script name and the dependency table, thus obtaining the script execution result. The dependency table includes the specified path and all subfolder paths under the specified path that contain scripts corresponding to the script name, and the specified path and all subfolder paths are concatenated.

[0018] Wherein, the specified script execution tool is Matlab software or a Mlang-compatible tool; correspondingly, the script execution result is either a first script execution result obtained by automating the batch execution of the script to be run through the Matlab software or a second script execution result obtained by automating the batch execution of the script to be run through the Mlang-compatible tool.

[0019] In one possible design, the script path management functions include the `addpath_recursive` function and the `joinpath` function; correspondingly, the script path management functions obtain a dependency table matching the script to be run based on the specified path, including:

[0020] The addpath_recursive function iterates through all subfolders under the specified path based on the script name to obtain the subfolder paths of all target scripts in the script to be run;

[0021] The joinpath function concatenates the paths of all subfolders of the target scripts to obtain the concatenated path.

[0022] The dependency table is obtained based on the specified path and the concatenated path.

[0023] In one possible design, the script execution function is the `runscript` function; correspondingly, the script execution function automatically batch-runs all scripts in the script to be run based on the script name and the dependency table, obtaining the script execution results of the script to be run, including:

[0024] Enable the default sprof function to start the timer;

[0025] Based on the path in the dependency table, the target script that matches the script name is found, and all target scripts that match the script name are executed in the order of the path in the dependency table using the preset eval function, so as to obtain the script execution output variable that matches the script to be run;

[0026] Call the sprof function to turn off the timer in order to obtain the script runtime of the script to be run;

[0027] The script execution output variables and the script execution duration are used as the script execution result, and the script execution result is stored in a specified file path that matches the specified script execution tool through a preset save function.

[0028] In one possible design, the automated comparison function includes the loaddata function, the datashow function, and the compare function; correspondingly, the automated comparison function is called to perform cross-comparison processing on the results of the first script execution and the second script execution to obtain comparison result data, including:

[0029] The paths where the first script execution result and the second script execution result are located are obtained respectively, and the loaddata function is used to find and import the first script execution result and the second script execution result according to the paths where the first script execution result and the second script execution result are located;

[0030] The datashow function is used to convert the results of the first script execution and the second script execution into images, resulting in a first image and a second image corresponding to the results of the first script execution and the second script execution, respectively.

[0031] The first image and the second image are compared using the compare function to obtain a difference image, which is then used as the comparison result data between the first script execution result and the second script execution result.

[0032] In one possible design, after obtaining the comparison result data, the method further includes:

[0033] A comparison report is generated based on the comparison results.

[0034] In one possible design, a comparison report is generated based on the comparison result data, including:

[0035] Create report generation functions; wherein, the report generation functions include the create_table function, the add_heading function, and the generate_report function;

[0036] The report generation function is called, and table elements are added based on the create_table function, a title field is added based on the add_heading function, and a report file is generated based on the generate_report function. Then, the table elements, title field, and report file are integrated to obtain a comparison report.

[0037] Secondly, the present invention provides a script execution result comparison system for implementing the script execution result comparison method as described in any one of the above claims; the script execution result comparison system includes:

[0038] The function creation module is used to create automated batch script execution functions and automated comparison functions; wherein, the automated batch script execution function is used to automatically run specified scripts in batches and store the script execution results obtained after the specified scripts are run; the automated comparison function is used to perform cross-comparison processing on the execution results of any two scripts;

[0039] The script retrieval module is used to retrieve scripts to be run.

[0040] The script execution module is communicatively connected to the function creation module and the script acquisition module, respectively. It is used to call the script automated batch execution function so that the script to be run can be automatically batch-run using Matlab software to obtain a first script execution result; it is also used to call the script automated batch execution function so that the script to be run can be automatically batch-run using Mlang compatible tools to obtain a second script execution result.

[0041] The result comparison module is communicatively connected to the script execution module and is used to call the automated comparison function to perform cross-comparison processing on the first script execution result and the second script execution result to obtain comparison result data.

[0042] Thirdly, the present invention provides an electronic device, comprising:

[0043] Memory, used to store computer program instructions; and,

[0044] A processor is configured to execute the computer program instructions to perform the operations of the script execution result comparison method as described in any of the above.

[0045] Fourthly, the present invention provides a computer program product, including a computer program or instructions, wherein the computer program or instructions, when executed by a computer, implement the script execution result comparison method as described in any one of the above.

[0046] The beneficial effects of this invention are as follows:

[0047] This invention discloses a method, system, device, and product for comparing script execution results. It can batch process multiple scripts using both Matlab software and Mlang-compatible tools, and automatically compare the execution results of two scripts to obtain comparison result data, facilitating users to quickly verify the accuracy of the results output by the Mlang-compatible tool. Specifically, in the implementation process, this invention first creates an automated batch execution function and an automated comparison function. After obtaining the scripts to be run, the automated batch execution function is called to automatically batch run the scripts using Matlab software, obtaining a first script execution result. Then, the automated batch execution function is called again to automatically batch run the scripts using the Mlang-compatible tool, obtaining a second script execution result. Finally, the automated comparison function is called to cross-compare the first and second script execution results to obtain comparison result data. Based on this, the present invention enables automated batch execution of scripts by Matlab software and Mlang-compatible tools, and cross-compares the execution results of the two scripts using an automated comparison function, thereby quickly obtaining the comparison results data. This greatly reduces manual intervention and realizes automated testing of the scripts to be run and comparison of the script execution results. This is beneficial to improving the efficiency and accuracy of verifying whether the script execution results obtained by Mlang-compatible tools are consistent with the script execution results obtained by Matlab software, and thus can ensure the functional correctness and performance consistency after code porting.

[0048] Other beneficial effects of the present invention will be further explained in the specific embodiments. Attached Figure Description

[0049] Figure 1 This is a flowchart of a script execution result comparison method in one embodiment;

[0050] Figure 2 This is a schematic diagram of the first and second images obtained when the data type of the first script execution result or the second script execution result is an array type;

[0051] Figure 3 This is a schematic diagram of the first and second images obtained when the data type of the first script execution result or the second script execution result is a scalar type;

[0052] Figure 4 This is a schematic diagram of the difference graph obtained when the data type of the first script execution result or the second script execution result is an array type;

[0053] Figure 5This is a schematic diagram of the difference graph obtained when the data type of the first script execution result or the second script execution result is a scalar type;

[0054] Figure 6 This is a block diagram of a script execution result comparison system in one embodiment;

[0055] Figure 7 This is a block diagram of an electronic device in one embodiment. Detailed Implementation

[0056] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the present invention will be briefly introduced below in conjunction with the accompanying drawings and descriptions of the embodiments or the prior art. Obviously, the following description of the structure of the accompanying drawings is only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort. It should be noted that the description of these embodiments is for the purpose of helping to understand the present invention, but does not constitute a limitation of the present invention.

[0057] Example 1:

[0058] This embodiment discloses a method for comparing script execution results, which can be executed by, but is not limited to, a computer device or virtual machine with certain computing resources, such as a personal computer, smartphone, personal digital assistant or wearable device, or by a virtual machine.

[0059] like Figure 1 As shown, a method for comparing script execution results may include, but is not limited to, the following steps:

[0060] S1. Create a function for automated batch execution of scripts and an automated comparison function; wherein, the function for automated batch execution of scripts is used to automatically run specified scripts in batches and store the script execution results obtained after the specified scripts are run; the automated comparison function is used to perform cross-comparison processing on the execution results of any two scripts.

[0061] S2. Obtain the script to be run.

[0062] S3. Call the script automated batch execution function to automate the batch execution of the scripts to be run using Matlab software, and obtain the first script execution result. Specifically, in this embodiment, by calling the script automated batch execution function, the automated batch processing of a series of scripts to be run is realized in the Matlab environment. This facilitates the effective integration of the execution of multiple independent scripts, greatly improves the script execution efficiency, and finally obtains the execution result of the scripts to be run, namely the first script execution result, which provides convenience for subsequent data analysis.

[0063] S4. Call the script automated batch execution function to automate the batch execution of the scripts to be run using Mlang-compatible tools, and obtain the second script execution result. Specifically, in this embodiment, by calling the script automated batch execution function, the automated batch processing of a series of scripts to be run is realized in the environment where the Mlang-compatible tools are located. This can effectively integrate the execution of multiple independent scripts, greatly improve the script running efficiency, and finally obtain the execution result of the scripts to be run, that is, the second script execution result, which provides convenience for subsequent data analysis.

[0064] The automated batch execution function for scripts includes a script execution function and a script path management function; correspondingly, in step S3 or S4, the automated batch execution function for scripts is called so that the scripts to be executed are automatically batch-executed using a specified script execution tool to obtain script execution results, including:

[0065] A1. The specified script execution tool receives the specified path where the script to be run is located and the script name of the script to be run;

[0066] A2. The specified script execution tool inputs the specified path and the script name into the script path management function, and inputs the script name into the script execution function, so that the script path management function can obtain a dependency table matching the script to be run based on the specified path, and the script execution function can automatically batch run all scripts in the script to be run based on the script name and the dependency table to obtain the script execution result of the script to be run; wherein, the dependency table includes the specified path and all subfolder paths under the specified path that include scripts corresponding to the script name, and the specified path and all subfolder paths are concatenated;

[0067] Wherein, the specified script execution tool is Matlab software or a Mlang-compatible tool; correspondingly, the script execution result is either a first script execution result obtained by automating the batch execution of the script to be run through the Matlab software or a second script execution result obtained by automating the batch execution of the script to be run through the Mlang-compatible tool.

[0068] Specifically, in this embodiment, the script path management function includes the addpath_recursive function (a Matlab function for recursively adding a specified directory and its subdirectories to the search path) and the joinpath function (a Matlab function for combining multiple partial paths into a complete path). It should be noted that the addpath_recursive function and the joinpath function can be used to record and identify the location of the target file containing the script execution results, so that the script execution function can automatically run all scripts in the script to be run in batches. Correspondingly, the script path management function obtains a dependency table matching the script to be run based on the specified path, including:

[0069] A201. The addpath_recursive function is used to traverse all subfolders under the specified path according to the script name to obtain the subfolder paths of all target scripts in the script to be run; specifically, in this embodiment, the dir function (used to return a list of object properties or a list of methods) is used to return the subfolder paths under the specified path.

[0070] A202. According to the joinpath function, concatenate the paths of all subfolders of the target scripts to obtain the concatenated path;

[0071] A203. Obtain a dependency table based on the specified path and the concatenated path. It should be noted that, in this embodiment, the dependency table also includes script files in the folders corresponding to all paths in the concatenated path, so that the script execution function can directly run the scripts in the script to be run based on the dependency table.

[0072] It should be noted that in this embodiment, the addpath_recursive function recursively traverses the file directories corresponding to the specified path to find all target scripts, while the joinpath function is used to generate the correct file paths in order to obtain a dependency table of all scripts in the scripts to be run that can be automatically batch-run by the runscript function, thereby realizing the automated execution of the scripts to be run.

[0073] In this embodiment, the script execution function is the `runscript` function (a function used in programming languages ​​to execute scripts). It should be noted that the `runscript` function can directly run the script and store the script execution time and variable data, etc., as script execution results. Correspondingly, the script execution function automatically batch-runs all scripts in the script to be run based on the script name and the dependency table to obtain the script execution results of the script to be run, including:

[0074] A204. Upon receiving the script name, enable the preset sprof function (a command-line tool for reading and displaying analysis data of shared objects (shared libraries)) to start a timer; specifically, during implementation, the script execution time can be recorded through the sprof function, which can generate a start timer marker and set a breakpoint on the marker line.

[0075] A205. Based on the path in the dependency table, find the target script that matches the script name, and execute all target scripts that match the script name in the path order in the dependency table using a preset eval function (used to execute a string expression and return the value of the expression), to obtain the script execution output variables that match the script to be run; in this embodiment, the script execution output variables include the variable names and corresponding data generated in the workspace after the eval function executes the script to be run; specifically, in the implementation process, the eval function can find the corresponding target script in the dependency table by the script name, that is, the script in the script to be run, and run the script line by line in the path order in the dependency table until the end.

[0076] A206. Call the sprof function to shut down the timer in order to obtain the script runtime of the script to be run; specifically, in the implementation process, the sprof function can generate an end timer flag and set a breakpoint on the flag line to shut down the timer, and obtain the runtime of the script to be run based on the timer's timing result.

[0077] A207. The script execution output variables and the script runtime are used as the script execution result, and the script execution result is stored in a specified file path matching the specified script execution tool using a preset save function (a function used to save array objects to a file). Specifically, in this embodiment, the first script execution result obtained by automatically batch running the script to be run using the Matlab software is stored in a preset matlab_data folder, and the second script execution result obtained by automatically batch running the script to be run using the Mlang-compatible tool is stored in a preset mlang_data folder. Specifically, during implementation, the save function can scan the variable names and corresponding values ​​of the script execution output variables in the workspace, and write the script execution output variables in the form of a structure in sequence until the last variable, and finally save all data as a .mat format file (a standard binary file) for subsequent data processing.

[0078] In this embodiment, the runscript function can automatically run the scripts to be run in batches based on the script name and the dependency table and save the script running results.

[0079] S5. Call the automated comparison function to perform cross-comparison processing on the results of the first script execution and the results of the second script execution to obtain comparison result data.

[0080] Specifically, in this embodiment, the automated comparison function includes the loaddata function (a function used to load pre-stored data), the datashow function (a visualization and analysis tool), and the compare function (a public member function of the string class). Correspondingly, the automated comparison function is called to perform cross-comparison processing on the results of the first script execution and the results of the second script execution to obtain comparison result data, including:

[0081] S501. Obtain the paths where the first script execution result and the second script execution result are located, respectively, and use the loaddata function to find and import the first script execution result and the second script execution result according to the paths where the first script execution result and the second script execution result are located; specifically, the loaddata function can use the specified path information to find whether the first script execution result and the second script execution result exist, and if they exist, import the corresponding data.

[0082] S502. The datashow function is used to convert the first script execution result and the second script execution result into images to obtain a first image and a second image corresponding to the first script execution result and the second script execution result, respectively.

[0083] Specifically, in the implementation of this embodiment, the first script execution result and the second script execution result are often arrays composed of multiple scalar elements. Before performing image conversion processing on the first script execution result or the second script execution result, the data type of the first script execution result or the second script execution result is determined in advance.

[0084] If the data type of the first script execution result or the second script execution result is an array, during the image conversion process of the first script execution result and the second script execution result using the datashow function, an image is drawn using a preset plot function (two-dimensional line drawing function). Specifically, during the process of drawing the first script execution result or the second script execution result into an image using the preset plot function, an x ​​and y axis coordinate system is first generated, and the y-axis data points are used as the data in the first script execution result or the second script execution result. The x-axis data points are adaptively distributed at uniform intervals according to the length of the data in the first script execution result or the second script execution result (scalar: length is 1; array: length is greater than or equal to 1). The resulting schematic diagrams of the first image and the second image are as follows: Figure 2 As shown in Figures (a) and (b).

[0085] If the data type of the first script execution result or the second script execution result is a scalar type (not an array), then after image conversion processing, the value is printed in the drawn image to obtain the first image corresponding to the first script execution result or the second image corresponding to the second script execution result. The schematic diagrams of the first image and the second image obtained at this time are as follows: Figure 3 As shown in Figures (a) and (b).

[0086] In this embodiment, after obtaining the first image and the second image, the first image and the second image are saved using a preset saveas function (a function for saving images).

[0087] S503. The first image and the second image are compared using the compare function to obtain a difference map, and this difference map is used as the comparison result data between the first script execution result and the second script execution result. Specifically, the compare function can subtract the first image and the second image to obtain a difference map, which can help to quickly identify the differences between the first script execution result and the second script execution result, and can intuitively describe the data characteristics when recording too much data.

[0088] In this embodiment, when comparing the first and second images using the `compare` function, the corresponding data of the first and second images are directly subtracted to obtain a difference array or a difference scalar. Specifically, when the data types of the first and second script execution results are arrays, for example, if the first script execution result is 2.55 and the second script execution result is 2.54, the resulting difference is 0.01 (difference scalar). When the data types of the first and second script execution results are scalars, for example, if the first script execution result is [2.55, 2.55] and the second script execution result is [2.54, 2.54], the resulting difference is [0.01, 0.01] (difference value). Finally, the preset `plot` function is used to draw the graph corresponding to the difference data, obtaining a difference graph, and the preset `saveas` function is used to save the difference graph to the `compare_data` folder. As an example, when the data types of the first script execution result and the second script execution result are array types, the corresponding difference plot is shown in the figure below. Figure 4 As shown, when the data types of the first script execution result and the second script execution result are scalar types, the corresponding difference plot is illustrated as follows: Figure 5 As shown.

[0089] In this embodiment, after obtaining the comparison result data in step S5, the method further includes:

[0090] S6. Generate a comparison report based on the comparison results data.

[0091] Specifically, a comparison report is generated based on the comparison result data, including:

[0092] S601. Create a report generation function; wherein, the report generation function includes the create_table function (for creating a table), the add_heading function (for adding a header to a report or document), and the generate_report function (for generating a report or document); it should be noted that the create_table function, the add_heading function, and the generate_report function are all developed using the Julia language, thus enabling the direct generation of reports based on the stored comparison result data.

[0093] S602. Call the report generation function and add table elements based on the create_table function. These table elements include table frames, fields, and fonts. Adding table elements based on the create_table function generates a table in the report and selects font styles and patterns. Adding heading fields based on the add_heading function confirms the number of headings in the table and adds heading fields, such as the script name and the comparison result indicating whether the comparison passed. Then, generate a report file based on the generate_report function. Finally, integrate the table elements, heading fields, and the report file to obtain a comparison report. Specifically, generating the report file based on the generate_report function involves first confirming the report name, such as "Automatic Comparison Report.docx," and confirming the report template, such as a Word document with a company logo, to obtain the report file. This allows for the integration of the table elements, heading fields, and the report file to generate the comparison report.

[0094] It should be noted that, in this embodiment, the comparison report includes data such as script accuracy statistics, speed comparison, quantity statistics, and Mlang error message statistics. During implementation, by viewing the "script accuracy statistics," the accuracy of the results output by the Mlang compatible tool can be quickly verified; by viewing the "speed comparison," the running speed of the Mlang compatible tool and Matlab software can be quickly understood; by viewing the "quantity statistics," the number of scripts run by the Mlang compatible tool and Matlab software, and the number of successful / failed runs can be quickly understood; and by viewing the "Mlang error message statistics," the error messages corresponding to the scripts that failed to run with the Mlang compatible tool can be quickly understood. This allows users to promptly confirm the accuracy of the results output by the Mlang compatible tool.

[0095] Based on the settings of step S6 above, after obtaining the comparison result data, this embodiment can further generate a comparison report so that users can quickly grasp the script running status and verify the accuracy of the running script results in batches based on the comparison report, thereby further improving the efficiency of script testing.

[0096] This embodiment can batch process multiple scripts using both Matlab software and Mlang-compatible tools, and can automatically compare the results of two script executions to obtain comparison result data, allowing users to quickly confirm the accuracy of the results output by the Mlang-compatible tool. Specifically, in the implementation process, this embodiment first creates an automated batch script execution function and an automated comparison function. After obtaining the scripts to be run, the automated batch script execution function is called to automatically batch run the scripts using Matlab software to obtain a first script execution result. Then, the automated batch script execution function is called again to automatically batch run the scripts using the Mlang-compatible tool to obtain a second script execution result. Finally, the automated comparison function is called to cross-compare the first script execution result and the second script execution result to obtain comparison result data. Based on this, this embodiment uses an automated batch execution function to automate the batch execution of scripts by both Matlab software and Mlang-compatible tools. An automated comparison function cross-compares the execution results of the two scripts, quickly obtaining the comparison data. This significantly reduces manual intervention, enabling automated testing of the scripts and comparison of their execution results. This improves the efficiency and accuracy of verifying the consistency between the execution results obtained from Mlang-compatible tools and Matlab software, thereby ensuring the functional correctness and performance consistency after code porting.

[0097] Example 2:

[0098] This embodiment discloses a script execution result comparison system for implementing the script execution result comparison method in Embodiment 1; such as Figure 6 As shown, the script execution result comparison system includes:

[0099] The function creation module is used to create automated batch script execution functions and automated comparison functions; wherein, the automated batch script execution function is used to automatically run specified scripts in batches and store the script execution results obtained after the specified scripts are run; the automated comparison function is used to perform cross-comparison processing on the execution results of any two scripts;

[0100] The script retrieval module is used to retrieve scripts to be run.

[0101] The script execution module is communicatively connected to the function creation module and the script acquisition module, respectively. It is used to call the script automated batch execution function so that the script to be run can be automatically batch-run using Matlab software to obtain a first script execution result; it is also used to call the script automated batch execution function so that the script to be run can be automatically batch-run using Mlang compatible tools to obtain a second script execution result.

[0102] The result comparison module is communicatively connected to the script execution module and is used to call the automated comparison function to perform cross-comparison processing on the first script execution result and the second script execution result to obtain comparison result data.

[0103] It should be noted that the working process, working details and technical effects of the script execution result comparison system provided in this embodiment 2 can be found in embodiment 1, and will not be repeated here.

[0104] Example 3:

[0105] Based on Embodiment 1 or 2, this embodiment discloses an electronic device, which may be a smartphone, tablet computer, laptop computer, or desktop computer, etc. The electronic device may be referred to as a user terminal, portable terminal, desktop terminal, etc. Figure 7 As shown, the electronic device includes:

[0106] Memory, used to store computer program instructions; and,

[0107] A processor is used to execute the computer program instructions to perform the operation of the script execution result comparison method as described in any of Embodiment 1.

[0108] Specifically, processor 301 may include one or more processing cores, such as a quad-core processor or an octa-core processor. Processor 301 may be implemented using at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), or PLA (Programmable Logic Array). Processor 301 may also include a main processor and a coprocessor. The main processor, also known as a CPU (Central Processing Unit), is used to process data in the wake-up state; the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, processor 301 may integrate a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content required to be displayed on the screen.

[0109] The memory 302 may include one or more computer-readable storage media, which may be non-transitory. The memory 302 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices or flash memory devices. In some embodiments, the non-transitory computer-readable storage media in the memory 302 are used to store at least one instruction, which is executed by the processor 301 to implement the script execution result comparison method provided in Embodiment 1 of this application.

[0110] In some embodiments, the terminal may also optionally include a communication interface 303 and at least one peripheral device. The processor 301, memory 302, and communication interface 303 can be connected via a bus or signal line. Each peripheral device can be connected to the communication interface 303 via a bus, signal line, or circuit board. Specifically, the peripheral device includes at least one of a radio frequency circuit 304, a display screen 305, and a power supply 306.

[0111] The communication interface 303 can be used to connect at least one I / O (Input / Output) related peripheral device to the processor 301 and the memory 302. In some embodiments, the processor 301, the memory 302, and the communication interface 303 are integrated on the same chip or circuit board; in some other embodiments, any one or two of the processor 301, the memory 302, and the communication interface 303 can be implemented on separate chips or circuit boards, which is not limited in this embodiment.

[0112] The radio frequency (RF) circuit 304 is used to receive and transmit RF (Radio Frequency) signals, also known as electromagnetic signals. The RF circuit 304 communicates with communication networks and other communication devices via electromagnetic signals.

[0113] Display screen 305 is used to display the UI (User Interface). The UI may include graphics, text, icons, videos, and any combination thereof.

[0114] Power supply 306 is used to supply power to various components in electronic devices.

[0115] Example 4:

[0116] Based on any one of the embodiments 1 to 3, this embodiment discloses a computer program product, including a computer program or instructions, wherein when the computer program or instructions are executed by a computer, they implement the script execution result comparison method as described in any one of the embodiments 1.

[0117] Obviously, those skilled in the art will understand that the modules or steps of the present invention described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. Optionally, they can be implemented using computer-executable program code, thereby storing them in a storage device for execution by a computing device, or fabricating them separately as individual integrated circuit modules, or fabricating multiple modules or steps as a single integrated circuit module. Thus, the present invention is not limited to any particular hardware and software combination.

[0118] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. These modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for comparing script execution results, characterized in that: include: Create a function for automated batch execution of scripts and an automated comparison function; wherein, the function for automated batch execution of scripts is used to automatically run specified scripts in batches and store the script execution results obtained after the specified scripts are run; the automated comparison function is used to perform cross-comparison processing on the execution results of any two scripts; Get the script to be run; The script is automated in batches and the function is called so that the script to be run can be automated in batches using Matlab software to obtain the first script running result. The script is automated in batches and the execution function is called so that the script to be run can be automated in batches using Mlang-compatible tools to obtain the execution result of the second script. The automated batch execution function for scripts includes a script execution function and a script path management function. Correspondingly, calling the automated batch execution function allows the specified script execution tool to perform automated batch execution of the scripts to be run, obtaining the script execution results, including: The specified script execution tool receives the specified path where the script to be run is located and the script name of the script to be run; The specified script execution tool inputs the specified path and the script name into the script path management function, and inputs the script name into the script execution function. This allows the script path management function to obtain a dependency table matching the script to be run based on the specified path, and the script execution function to automatically batch run all scripts in the script to be run based on the script name and the dependency table, thus obtaining the script execution result. The dependency table includes the specified path and all subfolder paths under the specified path that contain scripts corresponding to the script name, and the specified path and all subfolder paths are concatenated. Wherein, the specified script execution tool is Matlab software or a Mlang-compatible tool; correspondingly, the script execution result is either a first script execution result obtained by automatically batch running the script to be run through the Matlab software or a second script execution result obtained by automatically batch running the script to be run through the Mlang-compatible tool; The automated comparison function is invoked to perform cross-comparison processing on the results of the first script execution and the second script execution, so as to obtain the comparison result data.

2. The script execution result comparison method according to claim 1, characterized in that: The script path management functions include the addpath_recursive function and the joinpath function; correspondingly, the script path management functions obtain a dependency table matching the script to be run based on the specified path, including: The addpath_recursive function iterates through all subfolders under the specified path based on the script name to obtain the subfolder paths of all target scripts in the script to be run; The joinpath function concatenates the paths of all subfolders of the target scripts to obtain the concatenated path. The dependency table is obtained based on the specified path and the concatenated path.

3. The script execution result comparison method according to claim 1, characterized in that: The script execution function uses the `runscript` function; correspondingly, the script execution function automatically and in batches runs all scripts in the script to be run based on the script name and the dependency table, obtaining the script execution results of the script to be run, including: Enable the default sprof function to start the timer; Based on the path in the dependency table, the target script that matches the script name is found, and all target scripts that match the script name are executed in the order of the path in the dependency table using the preset eval function, so as to obtain the script execution output variable that matches the script to be run; Call the sprof function to turn off the timer in order to obtain the script runtime of the script to be run; The script execution output variables and the script execution duration are used as the script execution result, and the script execution result is stored in a specified file path that matches the specified script execution tool through a preset save function.

4. The script execution result comparison method according to claim 1, characterized in that: The automated comparison function includes the loaddata function, the datashow function, and the compare function; correspondingly, the automated comparison function is called to perform cross-comparison processing on the results of the first script execution and the results of the second script execution to obtain comparison result data, including: The paths where the first script execution result and the second script execution result are located are obtained respectively, and the loaddata function is used to find and import the first script execution result and the second script execution result according to the paths where the first script execution result and the second script execution result are located; The datashow function is used to convert the results of the first script execution and the second script execution into images, resulting in a first image and a second image corresponding to the results of the first script execution and the second script execution, respectively. The first image and the second image are compared using the compare function to obtain a difference image, which is then used as the comparison result data between the first script execution result and the second script execution result.

5. The script execution result comparison method according to claim 1, characterized in that: After obtaining the comparison result data, the method further includes: A comparison report is generated based on the comparison results.

6. The script execution result comparison method according to claim 5, characterized in that: A comparison report is generated based on the comparison results data, including: Create report generation functions; wherein, the report generation functions include the create_table function, the add_heading function, and the generate_report function; The report generation function is called, and table elements are added based on the create_table function, a title field is added based on the add_heading function, and a report file is generated based on the generate_report function. Then, the table elements, title field, and report file are integrated to obtain a comparison report.

7. A script execution result comparison system, characterized in that: Used to implement the script execution result comparison method as described in any one of claims 1 to 6; The script execution result comparison system includes: The function creation module is used to create automated batch script execution functions and automated comparison functions; wherein, the automated batch script execution function is used to automatically run specified scripts in batches and store the script execution results obtained after the specified scripts are run; the automated comparison function is used to perform cross-comparison processing on the execution results of any two scripts; The script retrieval module is used to retrieve scripts to be run. The script execution module is communicatively connected to the function creation module and the script acquisition module, respectively. It is used to call the script automated batch execution function so that the script to be run can be automatically batch-run using Matlab software to obtain a first script execution result; it is also used to call the script automated batch execution function so that the script to be run can be automatically batch-run using Mlang compatible tools to obtain a second script execution result. The result comparison module is communicatively connected to the script execution module and is used to call the automated comparison function to perform cross-comparison processing on the first script execution result and the second script execution result to obtain comparison result data.

8. An electronic device, characterized in that: include: Memory is used to store computer program instructions; as well as, A processor is configured to execute the computer program instructions to perform the script execution result comparison method as described in any one of claims 1 to 6.

9. A computer program product, comprising a computer program or instructions, characterized in that: When the computer program or the instructions are executed by the computer, they implement the script execution result comparison method as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Automatic generation system and automatic generation method of electronic control unit (ECU) diagnosis software model of automobile

    CN102902852A

  • Automatic script testing method and device, electronic equipment and readable medium

    CN111274147A