Log output method and device of vehicle, vehicle and storage medium
By acquiring log files from vehicles and calculating memory and CPU data based on driving modes, and using multi-threaded processing and information completion strategies to generate Excel files, the problem of cumbersome log parsing is solved, analysis efficiency is improved, and maintenance costs are reduced.
Patent Information
- Application Number
- CN202310566692.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-18
- Publication Date
- 2026-02-13
- Estimated Expiration
- 2043-05-18
AI Technical Summary
In existing technologies, the standard information generated by vehicle log parsing is too complex, not intuitive, and not conducive to analysis. Furthermore, log parsing is difficult, increasing workload and maintenance costs.
By acquiring vehicle log files, calculating memory and CPU data based on driving mode type, and using multi-threaded processing and information completion strategies, the log files are split into multiple top information items, and an Excel file is generated to record program runtime.
It simplifies the log analysis process, improves work efficiency, and reduces operation and maintenance costs. It visually displays resource usage in an Excel file and is suitable for log analysis of autonomous vehicles.
Smart Images

Figure CN116610651B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of intelligent driving of vehicles, and in particular to a log output method and device for a vehicle, a vehicle and a storage medium. BACKGROUND
[0002] With the development of technology, the display of information in the monitoring industry is increasingly tending to be report information display, so the log source information needs to be encoded to a certain extent to form a specific data format for the log report display layer. Since the current system is relatively complex and has a large size, a system contains many types of devices, so the data format of the log source information is various, which increases the difficulty of log analysis.
[0003] In related technologies, patent [CN201811127059.1] proposes a log analysis template and a log analysis method based on the template. The log analysis template corresponds to the IP address of the device, and is used to analyze the logs of different devices into standardized log information with the same format. The log analysis template includes a pre-analysis template and a main analysis template. The pre-analysis template is one of empty and version analysis sub-template. The version analysis sub-template extracts characters containing the version of the log in the log, selects the main analysis template corresponding to the characters through the extracted characters, and analyzes the log into standardized log information with the same format by using the corresponding analysis sub-template in a specific order. The present application can reduce the code workload, improve the work efficiency and reduce the operation and maintenance cost in the later stage.
[0004] However, although the method can analyze the log into standard information through the preset analysis template, the generated content is very complicated and not intuitive to the naked eye, and the analysis is not convenient, which needs to be solved urgently. SUMMARY
[0005] One of the purposes of the present application is to provide a log output method for a vehicle to solve the problem that the standard information content generated by the log analysis in the prior art is too complicated and not intuitive, which is not conducive to analysis. The second purpose is to provide a log output device for a vehicle. The third purpose is to provide a vehicle. The fourth purpose is to provide a computer-readable storage medium.
[0006] In order to achieve the above-mentioned purposes, the technical solutions adopted by the present application are as follows:
[0007] A log output method for a vehicle, comprising the following steps:
[0008] obtaining a log file of the current vehicle;
[0009] According to the log file, memory data and CPU (Central Processing Unit) data in each driving mode are calculated according to the driving mode type of the current vehicle; and
[0010] The log file is split into a plurality of separate top information, and the memory data and CPU data of the log file are generated based on the plurality of separate top information, and the target excel file is generated according to the memory data and CPU data in each driving mode and the memory data and CPU data of the log file.
[0011] According to the above technical means, based on the log file of the current vehicle, the memory data and CPU data in the corresponding mode are calculated according to different driving mode types, and the entire log file is split into a plurality of separate top information, so as to generate the memory data and CPU data of the log file according to the top information, and the memory data and CPU data in different driving modes and the log file are counted and summarized in the target excel file. Therefore, the problem of difficult analysis of huge resource logs such as memory and CPU generated daily in the rapid iteration of intelligent driving vehicle software is solved, thereby reducing the workload, improving the work efficiency and reducing the cost of later operation and maintenance.
[0012] Further, according to the log file, the memory data and CPU data in each driving mode are calculated according to the driving mode type of the current vehicle, including:
[0013] Based on the preset sed method, the number of matching mode lines is found, and all the line numbers are added to the arrModeLineNum array, and the adjacent two values of the arrModeLineNum array are taken out and recorded as beginNum and endNum respectively;
[0014] The data in beginNum and endNum are counted to obtain the memory data and CPU data in each driving mode.
[0015] According to the above technical means, based on the log file, the number of matching mode lines is obtained by using the preset sed method and recorded in the array, and the two adjacent values in the array are taken out and counted, so that the memory data and CPU data in different driving modes can be obtained. Therefore, the method for calculating the memory data and CPU data of the vehicle provided by the application is suitable for various driving modes, and can avoid the problems of complicated data in multiple driving modes during testing, analysis difficulties and the like, so as to facilitate understanding of the resource occupation of the system in different driving modes.
[0016] Further, the memory data and the CPU data of the log file generated based on the plurality of individual top information includes:
[0017] Determine the process to be counted, and complete the top information of the non-existent process in the process to be counted based on the preset information completion strategy;
[0018] Based on the plurality of individual top information after completion, the data of each top information is obtained by dividing the log file according to the starting line and the ending line, and the non-existent process in the process to be counted is written into a temporary file temp.log in the form of process name and null value, and the memory data and the CPU data of the log file are generated according to the temporary file temp.log.
[0019] According to the above technical means, the process to be counted but not existing at this time is completed by the preset information completion strategy, and the data of all top information is obtained by dividing the log file according to the starting line and the ending line, and the non-existent process is recorded to the temporary file, so as to obtain the memory data and the CPU data of the log file according to the temporary file. Therefore, by completing the information, it is convenient to understand the resource occupation of the whole system and the overall load of the system.
[0020] Further, the log file of the current vehicle is obtained, including:
[0021] Based on the mkfifo function of the preset shell script, a plurality of threads are created, and the file descriptor is bound to the plurality of threads by exec;
[0022] The log file of the current vehicle is obtained by using the plurality of threads through the preset read-u file descriptor.
[0023] According to the above technical means, the log file of the current vehicle can be efficiently and accurately obtained by the shell script and other tools cooperating with the plurality of threads and the plurality of tasks, and the working efficiency is effectively improved.
[0024] Further, after the target excel file is generated according to the memory data and the CPU data under each driving mode and the memory data and the CPU data of the log file, it further includes:
[0025] Record the start time and the end time, and calculate the difference between the end time and the start time, so as to obtain the program running time according to the difference.
[0026] According to the above technical means, the program running time can be obtained by recording the start time and the end time and calculating the difference between the two, which is convenient for later recording and analysis.
[0027] A log output device of a vehicle, comprising:
[0028] An acquisition module, configured to acquire a log file of a current vehicle;
[0029] A calculation module, configured to calculate memory data and cpu data in each driving mode according to a driving mode type of the current vehicle based on the log file; and
[0030] A generation module, configured to split the log file into a plurality of individual top information, and generate memory data and cpu data of the log file based on the plurality of individual top information, and generate a target excel file according to the memory data and cpu data in each driving mode and the memory data and cpu data of the log file.
[0031] Further, the calculation module is specifically configured to:
[0032] Find a number of lines of a matching mode based on a preset sed method, add all the numbers of lines into an arrModeLineNum array, and take out two adjacent values of the arrModeLineNum array, which are respectively recorded as beginNum and endNum;
[0033] Statistical data in beginNum and endNum to obtain the memory data and cpu data in each driving mode.
[0034] Further, the generation module is specifically configured to:
[0035] Determine a process to be counted, and complete top information of a non-existing process in the process to be counted based on a preset information completion strategy;
[0036] Divide data of each top information according to a start line and an end line based on the plurality of individual top information after completion, write a non-existing process in the process to be counted into a temporary file temp.log in a process name and null value form, and generate memory data and cpu data of the log file according to the temporary file temp.log.
[0037] Further, the acquisition module is specifically configured to:
[0038] Create a plurality of threads based on an mkfifo function of a preset shell script, and bind a file descriptor to the plurality of threads by exec;
[0039] Acquire the log file of the current vehicle by using the plurality of threads through a preset read–u file descriptor.
[0040] Further, after generating the target excel file according to the memory data and cpu data in each driving mode and the memory data and cpu data in the log file, the generating module is further configured to:
[0041] record the start time and the end time, and calculate the difference between the end time and the start time to obtain the program running time according to the difference.
[0042] A vehicle, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the log output method of the vehicle as described in the above embodiments.
[0043] A computer readable storage medium having a computer program stored thereon, wherein the program is executable by a processor to implement the log output method of the vehicle as described in the above embodiments.
[0044] Advantages of the present application:
[0045] (1) The present application efficiently and accurately converts the memory, cpu and other resource information logs of the automatic driving software daily statistics into excel files through shell scripts, python scripts and other tools in cooperation with multi-threading and multi-tasking. The excel files contain the maximum value, minimum value and average value in different driving modes such as parking, ACC (Adaptive Cruise Control), IACC (Integrated Adapted Cruise Control) and nid. The entire log can be analyzed conveniently through the line chart, so as to understand the resource occupation and overall load of the system in different driving modes.
[0046] (2) The log output method of the vehicle provided by the present application is simple and easy to use. A huge log file can be converted into excel and a line chart is generated for analysis by XX through a simple one-line command. It is friendly to beginners, can reduce code workload, improve work efficiency and reduce operation and maintenance cost in the later stage. BRIEF DESCRIPTION OF DRAWINGS
[0047] Figure 1 A flowchart of a log output method of a vehicle according to an embodiment of the present application;
[0048] Figure 2 A flowchart of a log output method of a vehicle according to an embodiment of the present application;
[0049] Figure 3 A block schematic diagram of a log output device of a vehicle according to an embodiment of the present application;
[0050] Figure 4 Structure diagram of a vehicle according to an embodiment of the present application.
[0051] Wherein, 10 - vehicle log output device, 100 - acquisition module, 200 - calculation module, 300 - generation module, 401 - memory, 402 - processor, 403 - communication interface. DETAILED DESCRIPTION
[0052] Other advantages and effects of the present application can be easily understood by those skilled in the art from the disclosure of the present specification. The present application can also be implemented or applied by other different specific embodiments, and various modifications or changes can be made to the details in the present specification based on different views and applications without departing from the spirit of the present application. It should be understood that the preferred embodiments are only for illustrating the present application, and are not intended to limit the protection scope of the present application.
[0053] It should be noted that the diagrams provided in the following embodiments only schematically illustrate the basic concept of the present application, and only show the components related to the present application in the diagrams, not the number, shape and size of the components when actually implemented. The shape, number and proportion of each component when actually implemented can be arbitrarily changed, and the layout pattern of the components can also be more complex.
[0054] Specifically, Figure 1 Flow chart of a vehicle log output method provided by an embodiment of the present application.
[0055] As Figure 1 shown, the vehicle log output method includes the following steps:
[0056] In step S101, the log file of the current vehicle is acquired.
[0057] Wherein, the log file of the vehicle according to the embodiment of the present application can include memory, cpu and other resource information automatically counted by the autonomous driving software, which is not specifically limited here.
[0058] It should be noted that before acquiring the log file of the current vehicle, the program needs to first judge the log file input by the user, that is, to perform parameter verification. If it is judged that the input file does not exist, the program will directly exit and issue an error prompt, and then perform preprocessing, that is, to create a directory for storing temporary log files.
[0059] Further, in some embodiments, the log file of the current vehicle is acquired, including: creating multiple threads based on a preset mkfifo function of a shell script, and binding a file descriptor to the multiple threads by exec; and acquiring the log file of the current vehicle by using the multiple threads through a preset read-u file descriptor.
[0060] The preset shell script can be a program preset by a person skilled in the art or a computer program in the related art, and details are not described herein to avoid redundancy; the mkfifo function is a function for creating a named pipe in a Linux system, the pipe is a mechanism for inter-process communication, and can enable data transmission and sharing between different processes, so that the use of the mkfifo function can facilitate communication between multiple processes; a thread is the smallest unit of operation scheduling of an operating system, which is contained in a process and is an actual operation unit in the process; a file descriptor is a non-negative integer in form, which is an index value, and a kernel accesses a file by using the file descriptor, and the kernel can return a file descriptor to a process when a program opens an existing file or creates a new file.
[0061] It can be understood that, since the recorded log file can be relatively large, and the number of processes for statistics can be as high as dozens or even hundreds, if a process is used for execution, the running time can be as high as several minutes or even ten minutes, which undoubtedly reduces the work efficiency.
[0062] Therefore, in the embodiment of the application, the mkfifo function of the preset shell script is used to create multiple threads, and the file descriptor is bound to the multiple threads by exec; and the multiple threads are used through the preset read-u file descriptor to obtain the log file of the current vehicle, so that the running time can be compressed to several seconds or even a few seconds, and the work efficiency is greatly improved.
[0063] In step S102, based on the log file, memory data and cpu data in each driving mode are calculated according to the driving mode type of the current vehicle.
[0064] It can be understood that various driving modes can exist in the vehicle test process, and different driving modes can be switched to each other, so that, in the embodiment of the application, the driving modes are classified, resource statistics are performed in the same driving mode, and the memory data and cpu data in the corresponding driving mode can be calculated according to the driving mode type of the current vehicle.
[0065] Further, in some embodiments, based on the log file, the memory data and cpu data in each driving mode are calculated according to the driving mode type of the current vehicle, including: finding the number of matching modes based on a preset sed method, and adding all the numbers to the arrModeLineNum array, and taking out the adjacent two values of the arrModeLineNum array, respectively recorded as beginNum and endNum; the data in beginNum and endNum are counted to obtain the memory data and cpu data in each driving mode.
[0066] Wherein, the preset sed method can be pre-set by those skilled in the art, or it can be a sed method in related art, to avoid redundancy, which will not be described here.
[0067] Specifically, the embodiment of the application first finds the number of matching modes by a preset sed method, recorded as lineNum, then adds all the numbers to the arrModeLineNum array, and takes out the adjacent two values of the arrModeLineNum array, respectively recorded as beginNum and endNum, then the data in beginNum and endNum are counted, so as to obtain the memory data and cpu data in each driving mode, that is, the maximum value, minimum value, average value of each process NI (NICE, used to change the static priority of the process), cpu, mem (a kind of memory display program, used to display the occupation of all memory resident programs) and record time are redirected to temporary files.
[0068] In step S103, the log file is split into a plurality of separate top information, and the memory data and cpu data of the log file are generated based on the plurality of separate top information, and the target excel file is generated according to the memory data and cpu data in each driving mode and the memory data and cpu data of the log file.
[0069] Wherein, the top information is a dynamic display process, which can display the current process and other conditions of the system.
[0070] It can be understood that, since there is a process switching in the driving mode switching process, and there is also a process dying and a new process being created in the system, the embodiment of the application needs to split the entire log file into a plurality of separate top information, and then complete the information of the process that needs to be counted but does not exist at this time.
[0071] Further, in some embodiments, the memory data and the CPU data of the log file are generated based on the plurality of individual top information, including: determining the processes to be counted, and performing top information completion on the non-existing processes in the processes to be counted based on a preset information completion strategy; dividing the log file according to the start line and the end line to obtain the data of each top information based on the plurality of individual top information after completion, and writing the non-existing processes in the processes to be counted into a temporary file temp.log in the form of process name and null value, and generating the memory data and the CPU data of the log file according to the temporary file temp.log.
[0072] The preset information completion strategy can be a strategy preset by a person skilled in the art, or an information completion strategy in the related art, and details are not described herein to avoid redundancy.
[0073] Specifically, the embodiment of the present application can determine the processes to be counted according to actual needs, and complete the top information of the non-existing processes in the processes to be counted based on the preset information completion strategy. Based on the plurality of individual top information after completion, the start line of the matching pattern can be found according to the aforementioned sed method, then the adjacent two values of the array, i.e. beginNum and endNum, are taken out, the entire log file is divided according to the start line and the end line to obtain the data of each top information, then the non-existing processes in the processes to be counted are written into a temporary file temp.log in the form of process name and null value, and the CPU and mem values of each process are calculated according to the temporary file temp.log, and then output to the final cpu.csv file to generate the memory data and the CPU data of the log file. In addition, the table header of the finally generated file also needs to add a timestamp and a NI value, so that the memory data and the CPU data under each driving mode, i.e. the maximum value, the minimum value and the average value of each process, can be obtained and output to the final cpu.csv file.
[0074] It can be understood that when the number of processes to be counted is large, the driving mode is frequently switched, and the number of log files is too large, the time consumption problem will occur, therefore, the embodiment of the present application uses multiple threads to respectively operate each process to generate corresponding.app files, and then combines all the.app files into the final cpu.csv file, which not only can improve the work efficiency, but also can reduce the operation and maintenance cost in the later stage.
[0075] In addition, in some embodiments, after generating the target excel file according to the memory data and the CPU data under each driving mode and the memory data and the CPU data of the log file, the method further includes: recording the start time and the end time, and calculating the difference between the end time and the start time to obtain the program running time according to the difference.
[0076] Specifically, after the target excel file is generated, the starting time startTimeStamp and the ending time endTimeStamp can be recorded, and the difference between the ending time and the starting time, i.e., endTimeStamp-startTimeStamp, is calculated. The difference is divided by 3600 to obtain the number of hours, and the modulus of 3600 is divided by 60 to obtain the number of minutes, and the modulus of 60 is obtained to obtain the number of seconds. Finally, the time is converted into the format of hours, minutes and seconds to obtain the running time and record it.
[0077] In order to further enable those skilled in the art to better understand the vehicle log output method provided by the embodiments of the present application, the following further describes the embodiments of the present application with reference to the accompanying drawings. Figure 2 The embodiments of the present application are further described.
[0078] Figure 2 The flowchart of the vehicle log output method of an embodiment of the present application is shown in Figure 2 The method comprises the following steps:
[0079] In step S201, user parameter verification is performed. If the user input parameter is incorrect, the method is directly exited.
[0080] In step S202, multi-threading is started.
[0081] In step S203, the log file is classified according to different driving modes.
[0082] In step S204, the maximum value, the minimum value and the average value of the cpu and mem data of each driving mode are calculated.
[0083] In step S205, the entire log is split into single top information and the non-existing top information is completed.
[0084] In step S206, all the cpu and mem data are counted.
[0085] In step S207, an excel file is generated.
[0086] In step S208, the program running time is calculated.
[0087] Therefore, the embodiments of the present application can quickly convert the huge log file into an excel file by one command, and then generate a line graph for analysis. The method is simple to operate and friendly to beginners, and can reduce the code workload and improve the work efficiency.
[0088] According to the log output method of the vehicle provided in the embodiment of the present application, the memory data and the cpu data in each driving mode are calculated according to the driving mode type of the current vehicle by using the obtained log file of the current vehicle, the memory data and the cpu data of the log file are generated based on the plurality of separate top information split from the log file, and the target excel file is generated according to the memory data and the cpu data in each driving mode and the memory data and the cpu data of the log file. In this way, the resource log such as memory and cpu in daily statistics is converted into an excel file, the problem that the standard information content generated by the log analysis in the prior art is too complicated and not intuitive enough to analyze is solved, and thus the workload is reduced, the work efficiency is improved, and the cost of later operation and maintenance is reduced.
[0089] Secondly, the log output device of the vehicle according to the embodiment of the present application is described with reference to the accompanying drawings.
[0090] Figure 3 The block schematic diagram of the log output device of the vehicle according to the embodiment of the present application is shown.
[0091] As shown in the figure, the log output device 10 of the vehicle includes an acquisition module 100, a calculation module 200 and a generation module 300. Figure 3
[0092] The acquisition module 100 is configured to acquire the log file of the current vehicle.
[0093] The calculation module 200 is configured to calculate the memory data and the cpu data in each driving mode based on the log file and according to the driving mode type of the current vehicle.
[0094] The generation module 300 is configured to split the log file into a plurality of separate top information, generate the memory data and the cpu data of the log file based on the plurality of separate top information, and generate the target excel file according to the memory data and the cpu data in each driving mode and the memory data and the cpu data of the log file.
[0095] Further, in some embodiments, the calculation module 200 is specifically configured to:
[0096] find the number of matching modes based on the preset sed method, add all the numbers to the arrModeLineNum array, and take out the adjacent two values of the arrModeLineNum array, which are respectively recorded as beginNum and endNum;
[0097] statistically analyze the data in beginNum and endNum to obtain the memory data and the cpu data in each driving mode.
[0098] Further, in some embodiments, the generating module 300 is specifically configured to:
[0099] determine the to-be-counted processes, and perform top information completion on the non-existing processes in the to-be-counted processes based on a preset information completion strategy;
[0100] based on the completed multiple individual top information, divide data of each top information from the log file according to the start line and the end line, and write the non-existing processes in the to-be-counted processes into a temporary file temp.log in the form of process name and null value, and generate memory data and cpu data of the log file according to the temporary file temp.log.
[0101] Further, in some embodiments, the obtaining module 100 is specifically configured to:
[0102] create multiple threads based on a preset mkfifo function of a shell script, and bind a file descriptor to the multiple threads by exec;
[0103] obtain the log file of the current vehicle by using the multiple threads through a preset read-u file descriptor.
[0104] Further, in some embodiments, after generating the target excel file according to the memory data and the cpu data under each driving mode and the memory data and the cpu data of the log file, the generating module 300 is further configured to:
[0105] record a start time and an end time, and calculate a difference between the end time and the start time, so as to obtain a program running time according to the difference.
[0106] It should be noted that the foregoing explanation and description of the vehicle log output method embodiments are also applicable to the vehicle log output device of the embodiments, which will not be described herein again.
[0107] According to the vehicle log output device provided in the embodiments of the present application, the log file of the current vehicle is obtained, the memory data and the cpu data under each driving mode are calculated according to the driving mode type of the current vehicle, the memory data and the cpu data of the log file are generated based on the multiple individual top information split from the log file, and the target excel file is generated according to the memory data and the cpu data under each driving mode and the memory data and the cpu data of the log file. Thus, by converting the daily statistical memory, cpu and other resource logs into an excel file, the problem that the standard information content generated by the log analysis in the past is too complicated and not intuitive enough to be analyzed is solved, thereby reducing the workload, improving the work efficiency and reducing the cost of later operation and maintenance.
[0108] Figure 4A structural schematic diagram of a vehicle is provided for an embodiment of the present application. The vehicle can include:
[0109] The memory 401, the processor 402 and the computer program stored in the memory 401 and executable on the processor 402.
[0110] The processor 402 implements the log output method of the vehicle provided in the above embodiments when executing the program.
[0111] Further, the vehicle further includes:
[0112] The communication interface 403 is used for communication between the memory 401 and the processor 402.
[0113] The memory 401 is used for storing the computer program executable on the processor 402.
[0114] The memory 401 can include a high-speed RAM (Random Access Memory) memory, and can also include a non-volatile memory, such as at least one disk memory.
[0115] If the memory 401, the processor 402 and the communication interface 403 are independently implemented, the communication interface 403, the memory 401 and the processor 402 can be connected to each other through a bus and complete communication between each other. The bus can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component) bus or an EISA (Extended Industry Standard Architecture) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For the convenience of representation, Figure 4 Only one thick line is used in the figure, but it does not mean that there is only one bus or only one type of bus.
[0116] Optionally, in a specific implementation, if the memory 401, the processor 402 and the communication interface 403 are integrated on a chip, the memory 401, the processor 402 and the communication interface 403 can complete communication between each other through an internal interface.
[0117] The processor 402 can be a CPU (Central Processing Unit), or an ASIC (Application Specific Integrated Circuit), or one or more integrated circuits configured to implement the embodiments of the present application.
[0118] The embodiment of the present application also provides a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to realize the log output method of the vehicle.
[0119] The above embodiments are only preferred embodiments of the present application for fully illustrating the present application, and the protection scope of the present application is not limited to this. Any equivalent replacement or transformation of the present application made by those skilled in the art based on the present application is within the protection scope of the present application.
Claims
1. A log output method of a vehicle, characterized by, The method comprises the following steps: obtaining a log file of a current vehicle; calculating memory data and CPU data in each driving mode according to a driving mode type of the current vehicle based on the log file; and splitting the log file into multiple individual top information, generating memory data and CPU data of the log file based on the multiple individual top information, and generating a target Excel file according to the memory data and CPU data in each driving mode and the memory data and CPU data of the log file; the step of calculating memory data and CPU data in each driving mode according to a driving mode type of the current vehicle based on the log file comprises: finding the number of matching mode lines based on a preset sed method, adding all the line numbers to an arrModeLineNum array, and taking out the adjacent two values of the arrModeLineNum array, which are respectively recorded as beginNum and endNum; statistically obtaining the memory data and CPU data in each driving mode from the data in beginNum and endNum; the step of generating memory data and CPU data of the log file based on the multiple individual top information comprises: determining a process to be counted, and performing top information completion on a non-existing process in the process to be counted based on a preset information completion strategy; dividing data of each top information from the log file according to the start line and the end line based on the multiple individual top information after completion, writing the non-existing process in the process to be counted into a temporary file temp.log in the form of process name and null value, and generating memory data and CPU data of the log file according to the temporary file temp.log.
2. The method of claim 1, wherein, The step of obtaining a log file of a current vehicle comprises: creating multiple threads based on a preset mkfifo function of a shell script, and binding file descriptors to the multiple threads by exec; obtaining a log file of a current vehicle by using the multiple threads through a preset read–u file descriptor.
3. The method of claim 1, wherein, After generating the target Excel file according to the memory data and CPU data in each driving mode and the memory data and CPU data of the log file, the method further comprises: recording a start time and an end time, and calculating a difference between the end time and the start time to obtain a program running time according to the difference.
4. A log output device of a vehicle characterized by comprising: The method comprises: an obtaining module, configured to obtain a log file of a current vehicle; a calculating module, configured to calculate memory data and CPU data in each driving mode according to a driving mode type of the current vehicle based on the log file; and a generating module, configured to split the log file into multiple individual top information, generate memory data and CPU data of the log file based on the multiple individual top information, and generate a target Excel file according to the memory data and CPU data in each driving mode and the memory data and CPU data of the log file; the calculating module is specifically configured to: Based on the preset sed method, find the number of lines of the matching mode, and add all the line numbers to the arrModeLineNum array, and take out the adjacent two values of the arrModeLineNum array, respectively recorded as beginNum and endNum; Statistical data in beginNum and endNum to get memory data and cpu data under each driving mode; The generation module is specifically configured to: Determine the process to be counted, and complete the top information of the non-existent process in the process to be counted based on the preset information completion strategy; Based on the plurality of individual top information after completion, divide the data of each top information according to the starting line and the ending line, and write the non-existent process in the process to be counted into the temporary file temp.log according to the process name and the null value, and generate the memory data and cpu data of the log file according to the temporary file temp.log.
5. A vehicle characterized by comprising: Comprise: Memory, processor and computer program stored on the memory and executable on the processor, the processor executes the program to realize the log output method of the vehicle as claimed in any one of claims 1-3.
6. A computer-readable storage medium having stored thereon a computer program, characterized in that, The program is executed by the processor to implement the log output method of the vehicle as claimed in any one of claims 1-3.
Citation Information
Patent Citations
A log parsing template and a log parsing method based on the template
CN109308289A
Intrusion detection method based on multi-host-log correlation
CN103824069A
Log processing method, apparatus, device and medium
CN109144965A