A computing performance testing method, device, electronic device and storage medium
By generating random integers and determining whether they are prime numbers and counting the number of prime numbers within the preset time, the problem that the existing technology cannot measure the mathematical computing capabilities of electronic devices is solved, and an effective evaluation of the mathematical computing performance of electronic devices is achieved.
Patent Information
- Application Number
- CN202011519067.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-21
- Publication Date
- 2025-03-21
- Estimated Expiration
- 2040-12-21
AI Technical Summary
Existing computing performance testing methods cannot effectively measure the mathematical computing capabilities of electronic devices.
By generating a random integer, determine whether it is a prime number, and count the total number of random integers determined as prime within the preset time period to determine the results of the calculation performance test.
The performance test of electronic devices in mathematical operations is realized, and it can evaluate how many prime numbers the device can recognize over a period of time, thereby reflecting its mathematical operational capabilities.
Smart Images

Figure CN112486795B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer application technology, and in particular to a computing performance testing method, device, electronic equipment and storage medium. Background Art
[0002] With the development of technology, the functions of electronic devices such as mobile phones, laptops, and tablets are becoming increasingly powerful. At present, various application software are constantly emerging, and numerous programs and services have put forward higher requirements on the computing performance of electronic devices. The stronger the computing performance of electronic devices, the faster the electronic devices can run application software.
[0003] At present, in order to let users better understand the computing performance of electronic devices, technicians have developed evaluation software (also known as "benchmarking" software). When this evaluation software is run on an electronic device, it can test the computing performance of the electronic device through certain test methods and inform the user of the test results, thereby helping the user understand the computing performance of the electronic device.
[0004] The current computing performance testing method is to test the performance of electronic devices running application software, and the output is the performance test result of the electronic device running application software. However, in actual applications, electronic devices mainly perform mathematical operations, and the current computing performance testing method cannot measure the mathematical operation capabilities of electronic devices. Summary of the invention
[0005] The purpose of the embodiments of the present invention is to provide a computing performance testing method, device, electronic device and storage medium to implement the performance testing of electronic devices in mathematical operations. The specific technical solution is as follows:
[0006] In a first aspect, an embodiment of the present invention provides a computing performance testing method, the method comprising:
[0007] Generate random integers;
[0008] Determine whether the generated random integer is a prime number;
[0009] Count the total number of random integers that are determined to be prime numbers within a preset time period;
[0010] Based on the total number, determine the computing performance test results.
[0011] Optionally, the step of generating a random integer includes:
[0012] Get processor performance parameters;
[0013] Set the random seed value and random range according to the processor performance parameters;
[0014] Generate a random integer based on a random seed value;
[0015] If the generated random integer is within the random range, the generated random integer is retained.
[0016] Optionally, the step of determining whether the generated random integer is a prime number comprises:
[0017] Traverse all natural numbers from 2 to the target integer. If no natural number can divide the generated random integer, the random integer is determined to be a prime number, wherein the target integer is the generated random integer minus 1, or the target integer is the square root of the generated random integer.
[0018] Optionally, before the step of generating a random integer, the method further comprises:
[0019] When receiving the test start instruction, start the timer and clear the counter;
[0020] The step of counting the total number of random integers determined to be prime numbers within a preset time period includes:
[0021] After determining that the generated random integer is a prime number, the value of the counter is incremented by 1;
[0022] If the timing duration of the timer does not reach the preset duration, returning to the step of generating a random integer, wherein the preset duration is pre-set based on the processor performance parameter;
[0023] If the timing duration of the timer reaches the preset duration, the total number of random integers determined to be prime numbers within the preset duration is read from the counter.
[0024] Optionally, the step of determining the computing performance test result based on the total quantity includes:
[0025] Calculate the average judgment speed based on the total number and the preset time;
[0026] Based on the average determination speed, an operation performance test result is determined, wherein the operation performance test result is a test score, and the test score is proportional to the average determination speed.
[0027] Optionally, after the step of determining the computing performance test result based on the total number, the method further comprises:
[0028] Output the computing performance test results to the test interface.
[0029] In a second aspect, an embodiment of the present invention provides a computing performance testing device, the device comprising:
[0030] Generation module, used to generate random integers;
[0031] A determination module, used for determining whether the generated random integer is a prime number;
[0032] A statistics module is used to count the total number of random integers determined to be prime numbers within a preset time period;
[0033] The determination module is used to determine the computing performance test result based on the total quantity.
[0034] Optionally, a generation module is specifically used to obtain processor performance parameters; set a random seed value and a random range according to the processor performance parameters; generate a random integer based on the random seed value; if the generated random integer is within the random range, retain the generated random integer.
[0035] Optionally, the determination module is specifically used to traverse all natural numbers from 2 to the target integer, and if no natural number can divide the generated random integer, the random integer is determined to be a prime number, wherein the target integer is the generated random integer minus 1, or the target integer is the square root of the generated random integer.
[0036] Optionally, the device further comprises:
[0037] A start module, used to start the timer and clear the counter when receiving a test start instruction;
[0038] The statistical module is specifically used to accumulate the value of the counter by 1 after determining that the generated random integer is a prime number; if the timing duration of the timer does not reach the preset duration, return to the step of generating the random integer, wherein the preset duration is pre-set based on the processor performance parameter; if the timing duration of the timer reaches the preset duration, read the total number of random integers determined to be prime numbers within the preset duration from the counter.
[0039] Optionally, a determination module is specifically used to calculate an average determination speed based on the total number and a preset duration; based on the average determination speed, an operation performance test result is determined, wherein the operation performance test result is a test score, and the test score is proportional to the average determination speed.
[0040] Optionally, the device further comprises:
[0041] The output module is used to output the computing performance test results to the test interface.
[0042] In a third aspect, an embodiment of the present invention provides an electronic device, comprising a processor and a memory, wherein the memory is used to store a computer program; and the processor is used to implement the method provided in the first aspect of the embodiment of the present invention when executing the computer program stored in the memory.
[0043] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the method provided in the first aspect of the embodiment of the present invention is implemented.
[0044] In a fifth aspect, an embodiment of the present invention further provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute the method provided in the first aspect of the embodiment of the present invention.
[0045] Beneficial effects of the embodiments of the present invention:
[0046] In the solution provided by the embodiment of the present invention, by generating a random integer, determining whether the generated random integer is a prime number, counting the total number of random integers determined to be prime numbers within a preset time length, and determining the result of the computing performance test based on the total number. By determining the randomly generated integers and counting the total number of random integers determined to be prime numbers within a preset time length, the electronic device's ability to recognize integer data types can be tested, that is, how many prime numbers can be determined within a period of time, thereby achieving a performance test of the electronic device in mathematical operations. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other embodiments can be obtained based on these drawings without paying creative work.
[0048] Figure 1 A schematic diagram of a flow chart of a computing performance testing method according to an embodiment of the present invention;
[0049] Figure 2 A schematic diagram of a flow chart of another computing performance testing method according to an embodiment of the present invention;
[0050] Figure 3 A flowchart of another computing performance testing method according to an embodiment of the present invention;
[0051] Figure 4 A flowchart of another computing performance testing method according to an embodiment of the present invention;
[0052] Figure 5 A schematic diagram of the structure of a computing performance testing device according to an embodiment of the present invention;
[0053] Figure 6 Schematic diagram of the structure of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0054] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0055] In order to implement the performance test of electronic devices in mathematical operations, the embodiments of the present invention provide a method, device, electronic device and storage medium for computing performance testing. The computing performance testing method provided by the embodiments of the present invention is first introduced below.
[0056] The execution subject of the computing performance testing method provided in the embodiment of the present invention is: an electronic device with mathematical computing capabilities, such as a mobile phone, a laptop computer, a tablet computer, a PC (Personal Computer), etc.
[0057] like Figure 1 As shown, a computing performance testing method provided by an embodiment of the present invention may include the following steps.
[0058] S101, generate a random integer.
[0059] S102, determining whether the generated random integer is a prime number.
[0060] S103, counting the total number of random integers determined to be prime numbers within a preset time length.
[0061] S104, determining a computing performance test result based on the total number.
[0062] By applying the embodiment of the present invention, a random integer is generated, whether the generated random integer is a prime number is determined, and the total number of random integers determined to be prime numbers within a preset time length is counted, and the computing performance test result is determined based on the total number. By determining the randomly generated integers and counting the total number of random integers determined to be prime numbers within a preset time length, the electronic device's ability to recognize integer data types can be tested, that is, how many prime numbers can be determined within a period of time, thereby achieving a performance test of the electronic device in mathematical operations.
[0063] When the embodiment of the present invention performs the computing performance test, a random integer is generated. An important step of mathematical operation is to determine the data type of the integer. Therefore, after the random integer is generated, it is necessary to determine whether the generated random integer is a prime number. A prime number refers to a natural number that has no other factors except 1 and itself among the natural numbers greater than 1. It should be particularly noted that the natural number 1 is not a prime number. For example, 2, 3, 5, and 7 are prime numbers, while 4 is not a prime number.
[0064] In a specific implementation of the embodiment of the present invention, multiple random integers can be generated at one time, and each random integer can be determined in turn whether it is a prime number; or a random integer can be generated first, and then it can be determined whether it is a prime number. After the determination is completed, another random integer can be generated and determined.
[0065] Specifically, S102 may specifically be: traverse all natural numbers from 2 to the target integer, and if no natural number can divide the generated random integer, determine that the random integer is a prime number, wherein the target integer is the generated random integer minus 1, or the target integer is the square root of the generated random integer.
[0066] When determining whether an integer is prime, a round-robin method is usually used: after generating a random integer N, traverse all natural numbers from 2 to N-1. If the current value M can divide N, that is, N%M=0, then according to the definition of prime numbers, N is not a prime number. On the contrary, if all natural numbers from 2 to N-1 are traversed and no value M that can divide N is found, then N is considered to be a prime number.
[0067] For relatively small prime numbers, the electronic device can easily get the judgment result by the above-mentioned loop method. However, for relatively large prime numbers, the operation speed is relatively slow and the judgment efficiency is low because of the large number of loops. For a number N, it is not actually necessary to judge from 2 to N-1. If a natural number can be factored, then one of the two numbers obtained during the decomposition is not greater than the square root of N, and the other is not less than the square root of N. Based on this, it is only necessary to traverse to the square root of N. That is to say, in another prime number judgment method, after generating a random integer N, traverse from 2 to N-1. If the current value M can divide N, that is, N%M=0, then N is not a prime number. On the contrary, if you traverse from 2 to If all natural numbers between , and no value M that can divide N is found, then N is considered to be a prime number. Compared with the round-robin method for determining prime numbers, this method has a shorter calculation speed and higher determination efficiency.
[0068] The electronic device continuously determines whether the randomly generated integer is a prime number, and counts the number of random integers determined to be prime numbers. The mathematical operation performance of the electronic device is reflected in the total number of random integers that can be determined to be prime numbers within the working time (i.e., the preset time). The more the total number of random integers that can be determined to be prime numbers within the working time, the better the mathematical operation performance of the electronic device. In an embodiment of the present invention, it is necessary to count the total number of random integers that are determined to be prime numbers within the preset time, and the computing performance test result can be determined based on the total number obtained by statistics. The determined computing performance test result can be a specific scoring score, or it can be a result representing the performance degree such as excellent, good, medium, poor, etc., and the total number obtained by statistics can also be directly used as the computing performance test result, which is not specifically limited here.
[0069] In practical applications, the computing performance test results are generally fed back to users. In order to facilitate users to more intuitively see the quality of the computing performance of electronic devices, the computing performance test results are usually set as test scores. Accordingly, S104 can specifically be: calculating the average determination speed according to the total number and the preset time; determining the computing performance test results based on the average determination speed, wherein the computing performance test results are test scores, and the test scores are proportional to the average determination speed.
[0070] The average judgment speed refers to the number of random integers that the electronic device can judge to be prime numbers in a unit time. When the test starts, the start time can be recorded, and when the preset time is reached, the end time can be recorded. Then the average judgment speed = total number / (end time-start time), or the total number can be directly divided by the preset time to obtain the average judgment speed. There is a positive proportional relationship between the test score and the average judgment speed, that is, the faster the average judgment speed, the better the mathematical operation performance of the electronic device, and a higher test score can be assigned accordingly. In specific applications, the full score of the test score can be set to 10 points or 100 points. When the test score is assigned based on the average judgment speed, it can be assigned within the range of 0 points to the full score.
[0071] based on Figure 1 In the embodiment shown, another computing performance testing method provided by the embodiment of the present invention is as follows: Figure 2 As shown, the following steps may be included.
[0072] S201, obtaining processor performance parameters.
[0073] S202, setting a random seed value and a random range according to processor performance parameters.
[0074] S203, generating a random integer based on the random seed value.
[0075] S204: If the generated random integer is within the random range, determine whether the generated random integer is a prime number.
[0076] S205, counting the total number of random integers determined to be prime numbers within a preset time length.
[0077] S206, determining a computing performance test result based on the total number.
[0078] Generally, the random numbers of computers are pseudo-random numbers. Usually, a random seed (usually a fixed value) is obtained as the initial condition, and then a certain algorithm is used to iterate and generate random numbers. The random number sequence generated with the same random seed is the same. The random range refers to the reasonable range of values that electronic devices can process.
[0079] The random seed value and random range are generally related to the processing performance of the processor. In an embodiment of the present invention, the random seed and random range are adjustable. The specific adjustment method is to first obtain the processor performance parameters. The processor performance parameters refer to the attribute parameters that can reflect the processing power of the processor, usually including the number of CPU (Central Processing Unit) cores and frequency. The larger the processor performance parameters (for example, the larger the number of CPU cores, the larger the frequency, etc.), the stronger the ability of the processor to perform integer operations. Correspondingly, the larger the processor performance parameters, the larger the random seed value can be set, and the wider the random range can be set, and vice versa. Therefore, according to the processor performance parameters, the random seed value and random range are determined, and the adjustment of the random seed and random range can be achieved. Specifically, according to the method of setting the random seed value and random range according to the processor performance parameters, the mapping relationship between the processor performance parameters and the random seed value and the random range can be pre-set. The mapping relationship represents the positive correlation between the processor performance parameters and the random seed value and the random range. After obtaining the processor performance parameters, the corresponding random seed value and random range can be obtained based on the mapping relationship.
[0080] After determining the random seed value and the random range, a random integer can be generated based on the random seed value. Specifically, the method of generating a random integer based on the random seed value can adopt the square median method, the linear congruential method, and the like. These methods are all methods for generating random integers based on random seed values that are commonly used in the art and will not be described in detail here. If the generated random integer is within the random range, it means that the generated random integer is a reasonable integer that the electronic device can handle, and subsequent determinations can be made. If the generated random integer is not within the random range, it means that the generated random integer is not suitable, and the random integer should be discarded and a new random integer should be generated.
[0081] The embodiments of the present invention can adjust the random seed value and the random range, thereby being able to flexibly adapt to electronic devices with different performances.
[0082] based on Figure 1 In the embodiment shown, another computing performance testing method provided by the embodiment of the present invention is as follows: Figure 3 As shown, the following steps may be included.
[0083] S301, when receiving a test start instruction, start a timer and clear the counter.
[0084] S302, generate a random integer.
[0085] S303, determining whether the generated random integer is a prime number.
[0086] S304, after determining that the generated random integer is a prime number, adding 1 to the value of the counter.
[0087] S305, determining whether the timing duration of the timer reaches the preset duration, if so, executing S306, if not, returning to executing S302.
[0088] The preset duration is pre-set based on processor performance parameters.
[0089] S306, reading from the counter the total number of random integers determined to be prime numbers within a preset time length.
[0090] S307, determining a computing performance test result based on the total number.
[0091] Generally, the computing performance test of an electronic device is triggered to start, which can be triggered by the user by clicking the start button on the test interface, or by the electronic device periodically starting the test. When the test is triggered, a test start instruction is generated. When the electronic device receives the test start instruction, the timer is started and the counter is cleared. The timer is used to record the duration of the computing performance test, and the counter is used to record the number of random integers that have been judged to be prime numbers. After completing a judgment, the value recorded by the counter is accumulated by 1.
[0092] If after one determination, the timer has not reached the preset time, the process of determining whether it is a prime number should continue, and the step of generating random integers should be returned to generate a new random integer to re-determine whether it is a prime number. If the timer reaches the preset time, the random integer generation should be stopped, and the computing performance test result is determined based on the total number of random integers determined to be prime numbers within the preset time. The specific method of determining the computing performance test result is the same as Figure 1The method in the illustrated embodiment is the same and will not be described in detail here. The preset duration is pre-set based on the processor performance parameter, that is, based on the processor performance parameter, the value of the preset duration can also be flexibly adjusted to adapt to electronic devices with different performances.
[0093] based on Figure 1 In the embodiment shown, another computing performance testing method provided by the embodiment of the present invention is as follows: Figure 4 As shown, the following steps may be included.
[0094] S401, generate a random integer.
[0095] S402, determining whether the generated random integer is a prime number.
[0096] S403, counting the total number of random integers determined to be prime numbers within a preset time period.
[0097] S404, determining a computing performance test result based on the total number.
[0098] S405, outputting the computing performance test results to the test interface.
[0099] After the operation performance test result is determined by the method of the above embodiment, the obtained computing performance test result can be output to the test interface, which is a manual interaction interface. In this way, the user can intuitively see the electronic device's mathematical operation, especially the performance of prime number determination, from the test interface. Furthermore, if the computing performance test result of the electronic device is very good, the electronic device can be selected to process more complex integers.
[0100] For ease of understanding, the computing performance testing method provided by the embodiment of the present invention is introduced below in conjunction with a specific example. Taking the use of AnTuTu evaluation software to evaluate a PC as an example, the AnTuTu evaluation software uses a prime number determination performance test as a test item for performance evaluation.
[0101] First, the user manually opens the AnTuTu benchmark software and clicks the test button to start the benchmark.
[0102] Secondly, run the computing performance test method:
[0103] The first step is to enter the working hours.
[0104] The second step is to set the random seed value srand(seed).
[0105] The third step is to start the timer, record the start time, and clear the counter C=0.
[0106] The fourth step is to generate a random integer N based on the random seed value. The integer N can be large or small and is completely random.
[0107] The fifth step is to determine whether the generated random integer N is a prime number. If it is a prime number, execute the sixth step; otherwise, execute the fourth step to regenerate a random integer.
[0108] Judgment method: traverse from 2 to If the current value M can divide N, that is, N%M=0, then N is not a prime number. On the contrary, if you traverse from 2 to If there is no value M that can divide N evenly, then N is considered to be a prime number.
[0109] After the prime number determination is completed, the counter C is incremented to record the number of random integers that have completed the prime number determination.
[0110] Step 6: Determine whether the time exceeds the working hours. If not, continue to step 4. If it exceeds, end this step.
[0111] Step 7. Calculate the average judgment speed: Average judgment speed = total number / (end time - start time).
[0112] Step 8: Output the computing performance test result to the test interface, wherein the computing performance test result is a test score determined based on the average determination speed.
[0113] Finally, check out the results of the evaluation:
[0114] 1) Total processor performance score
[0115] 2) Common algorithms used by processors
[0116] 3) Processor single core performance
[0117] 4) Processor multi-core performance
[0118] Among them, the processor single-core performance test item includes the computing performance test method of the present invention.
[0119] Based on the above method embodiment, the present invention provides a computing performance testing device, such as Figure 5 As shown, the device may include:
[0120] A generating module 510, for generating a random integer;
[0121] A determination module 520 is used to determine whether the generated random integer is a prime number;
[0122] A statistics module 530 is used to count the total number of random integers determined to be prime numbers within a preset time period;
[0123] The determination module 540 is used to determine the computing performance test result based on the total number.
[0124] Optionally, the generation module 510 can be specifically used to obtain processor performance parameters; set a random seed value and a random range according to the processor performance parameters; generate a random integer based on the random seed value; if the generated random integer is within the random range, retain the generated random integer.
[0125] Optionally, the determination module 520 can be specifically used to traverse all natural numbers from 2 to the target integer. If no natural number can divide the generated random integer, the random integer is determined to be a prime number, wherein the target integer is the generated random integer minus 1, or the target integer is the square root of the generated random integer.
[0126] Optionally, the device may further include:
[0127] A start module, used to start the timer and clear the counter when receiving a test start instruction;
[0128] The statistical module 530 can be specifically used to add 1 to the value of the counter after determining that the generated random integer is a prime number; if the timing duration of the timer does not reach the preset duration, return to the step of generating a random integer, wherein the preset duration is pre-set based on the processor performance parameter; if the timing duration of the timer reaches the preset duration, read the total number of random integers determined to be prime numbers within the preset duration from the counter.
[0129] Optionally, the determination module 540 can be specifically used to calculate the average determination speed based on the total number and the preset time; based on the average determination speed, determine the computing performance test result, wherein the computing performance test result is a test score, and the test score is proportional to the average determination speed.
[0130] Optionally, the device may further include:
[0131] The output module is used to output the computing performance test results to the test interface.
[0132] By applying the embodiment of the present invention, a random integer is generated, whether the generated random integer is a prime number is determined, and the total number of random integers determined to be prime numbers within a preset time length is counted, and the computing performance test result is determined based on the total number. By determining the randomly generated integers and counting the total number of random integers determined to be prime numbers within a preset time length, the electronic device's ability to recognize integer data types can be tested, that is, how many prime numbers can be determined within a period of time, thereby achieving a performance test of the electronic device in mathematical operations.
[0133] The embodiment of the present invention further provides an electronic device, such as Figure 6As shown, it includes a processor 601 and a memory 602, wherein the memory 602 is used to store computer programs; the processor 601 is used to implement the above-mentioned computing performance testing method when executing the computer program stored in the memory 602.
[0134] The memory may include a RAM (Random Access Memory), or may include a NVM (Non-volatile Memory), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the processor.
[0135] The above-mentioned processor can be a general-purpose processor, including CPU, NP (Network Processor), etc.; it can also be DSP (Digital Signal Processing), ASIC (Application Specific Integrated Circuit), FPGA (Field-Programmable Gate Array) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0136] In this embodiment, the processor can achieve the following by reading a computer program stored in a memory and running the computer program: by generating a random integer, determining whether the generated random integer is a prime number, counting the total number of random integers determined to be prime numbers within a preset time length, and determining the result of the computing performance test based on the total number. By determining the randomly generated integers and counting the total number of random integers determined to be prime numbers within a preset time length, the electronic device's ability to recognize integer data types can be tested, that is, how many prime numbers can be determined within a period of time, thereby achieving a performance test of the electronic device in mathematical operations.
[0137] In addition, an embodiment of the present invention provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the above-mentioned computing performance testing method is implemented.
[0138] In the present embodiment, the computer-readable storage medium stores a computer program that executes the computing performance test method provided by the embodiment of the present invention at runtime, so that: by generating a random integer, determining whether the generated random integer is a prime number, counting the total number of random integers determined to be prime numbers within a preset time length, and determining the computing performance test result based on the total number. By determining the randomly generated integers, counting the total number of random integers determined to be prime numbers within a preset time length, the electronic device's ability to recognize integer data types can be tested, that is, how many prime numbers can be determined within a period of time, thereby achieving performance testing of the electronic device in mathematical operations.
[0139] In another embodiment of the present invention, a computer program product including instructions is provided, which enables the computer to execute the above-mentioned computing performance testing method when it is run on a computer.
[0140] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, DSL (Digital Subscriber Line, digital subscriber line)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrations. The available medium may be a magnetic medium (such as a floppy disk, a hard disk, a magnetic tape), an optical medium (such as a DVD (Digital Versatile Disc)), or a semiconductor medium (such as an SSD (Solid State Disk)).
[0141] As for the computing performance testing device, electronic device, computer-readable storage medium and computer program product embodiments, since the method contents involved are basically similar to the aforementioned method embodiments, the description is relatively simple and the relevant parts can be referred to the partial description of the method embodiments.
[0142] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0143] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the computing performance test device, electronic device, computer-readable storage medium, and computer program product embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.
[0144] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.
Claims
1. A computing performance testing method, characterized in that: The method comprises: Generate random integers; Determine whether the generated random integer is a prime number; Count the total number of random integers that are determined to be prime numbers within a preset time period; Based on the total number, determining a computing performance test result, wherein the total number of random integers determined to be prime numbers within the preset time period is proportional to the mathematical computing performance of the electronic device; Before the step of generating a random integer, the method further comprises: When receiving the test start instruction, start the timer and clear the counter; The step of counting the total number of random integers determined to be prime numbers within a preset time period includes: After determining that the generated random integer is a prime number, adding 1 to the value of the counter; If the timing duration of the timer does not reach the preset duration, returning to the step of generating the random integer, wherein the preset duration is pre-set based on the processor performance parameter; If the timing duration of the timer reaches the preset duration, the total number of random integers determined to be prime numbers within the preset duration is read from the counter; The step of generating a random integer comprises: Get processor performance parameters; According to the processor performance parameters, a random seed value and a random range are set based on a mapping relationship, wherein the mapping relationship is a mapping relationship between the processor performance parameters, the random seed value, and the random range that is preset, and the mapping relationship represents a positive correlation between the processor performance parameters, the random seed value, and the random range; Based on the random seed value, generate a random integer; If the generated random integer is within the random range, retain the generated random integer; If the generated random integer is not within the random range, the generated random integer is discarded and a new random integer is generated.
2. The method according to claim 1, characterized in that The step of determining whether the generated random integer is a prime number comprises: Traverse all natural numbers from 2 to the target integer. If no natural number can divide the generated random integer, the random integer is determined to be a prime number, wherein the target integer is the generated random integer minus 1, or the target integer is the square root of the generated random integer.
3. The method according to claim 1, characterized in that The step of determining the computing performance test result based on the total number includes: Calculating an average determination speed according to the total number and the preset time length; Based on the average determination speed, an operation performance test result is determined, wherein the operation performance test result is a test score, and the test score is proportional to the average determination speed.
4. The method according to claim 1 or 3, characterized in that: After the step of determining the computing performance test result based on the total number, the method further includes: The computing performance test result is output to the test interface.
5. A computing performance testing device, characterized in that: The device comprises: Generation module, used to generate random integers; A determination module, used for determining whether the generated random integer is a prime number; A statistics module is used to count the total number of random integers determined to be prime numbers within a preset time period; A determination module, configured to determine a calculation performance test result based on the total number, wherein the total number of random integers determined to be prime numbers within the preset time period is proportional to the mathematical calculation performance of the electronic device; The device also includes: A start module, used to start the timer and clear the counter when receiving a test start instruction; The statistical module is specifically used for, after determining that the generated random integer is a prime number, adding 1 to the value of the counter; if the timing duration of the timer does not reach a preset duration, returning to execute the step of generating the random integer, wherein the preset duration is pre-set based on a processor performance parameter; if the timing duration of the timer reaches the preset duration, reading from the counter the total number of random integers determined to be prime numbers within the preset duration; The generation module is specifically used to obtain processor performance parameters; according to the processor performance parameters, based on a mapping relationship, set a random seed value and a random range, wherein the mapping relationship is a mapping relationship between the processor performance parameters, the random seed value, and the random range that is preset, and the mapping relationship represents a positive correlation between the processor performance parameters, the random seed value, and the random range; based on the random seed value, generate a random integer; if the generated random integer is within the random range, retain the generated random integer; if the generated random integer is not within the random range, discard the generated random integer and regenerate a random integer.
6. The device according to claim 5, characterized in that The determination module is specifically used to traverse all natural numbers from 2 to a target integer, and if no natural number can divide the generated random integer, determine that the random integer is a prime number, wherein the target integer is the generated random integer minus 1, or the target integer is the square root of the generated random integer.
7. The device according to claim 5, characterized in that The determination module is specifically used to calculate an average determination speed according to the total number and the preset time length; and determine a computing performance test result based on the average determination speed, wherein the computing performance test result is a test score, and the test score is proportional to the average determination speed.
8. The device according to claim 5 or 7, characterized in that The device also includes: The output module is used to output the computing performance test result to the test interface.
9. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory is used to store a computer program; and the processor is used to implement the method according to any one of claims 1 to 4 when executing the computer program stored in the memory.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.
Citation Information
Patent Citations
Pseudo-random number generator and test system using it
CN1725714A