Detailed Description
Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While certain embodiments of the present disclosure are shown in the drawings, it is to be understood that the present disclosure may be embodied in various forms and should not be construed as limited to the embodiments set forth herein, but rather are provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the disclosure are for illustration purposes only and are not intended to limit the scope of the disclosure.
It should be understood that the various steps recited in method embodiments of the present disclosure may be performed in a different order, and/or performed in parallel. Moreover, method embodiments may include additional steps and/or omit performing the illustrated steps. The scope of the present disclosure is not limited in this respect.
The term "include" and variations thereof as used herein are open-ended, i.e., "including but not limited to". The term "based on" is "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Relevant definitions for other terms will be given in the following description.
It should be noted that the terms "first", "second", and the like in the present disclosure are only used for distinguishing the devices, modules, or units, and are not used for limiting the devices, modules, or units to be determined as different devices, modules, or units, and are not used for limiting the sequence or interdependence of the functions performed by the devices, modules, or units.
It is noted that references to "a", "an", and "the" modifications in this disclosure are intended to be illustrative rather than limiting, and that those skilled in the art will recognize that "one or more" may be used unless the context clearly dictates otherwise.
The names of messages or information exchanged between devices in the embodiments of the present disclosure are for illustrative purposes only, and are not intended to limit the scope of the messages or information.
The embodiment of the present disclosure provides a method for pre-creating a view component, a flowchart of the method is shown in fig. 1, and the method includes:
s101, the creation of each view component is detected, and the number of times of creation of each view component is determined.
In the embodiment of the present disclosure, detecting creation of each view component, and determining the number of times of creation of each view component includes:
detecting byte codes related to the creation of each view component, and determining context information corresponding to each view component;
and determining the times of creation of each view component according to the context information corresponding to each view component.
In the embodiment of the present disclosure, detecting a bytecode related to creation of each view component, and determining context information corresponding to each view component includes:
reading the byte codes related to the creation of each view component, and detecting the signature related to the creation of each view component according to the byte codes;
when the signature is detected, obtaining a parameter corresponding to the parameter application instruction through a preset parameter application instruction;
and determining context information corresponding to each view component according to the parameters.
In the embodiment of the disclosure, a byte code related to creation of a view component is detected through a self-development byte code tool, call addition callback of the view component is detected, and creation callback detection is performed through the callback inserted in a compiling process during running.
In the embodiment of the present disclosure, detecting a byte code related to view invalidate, and detecting a call addition callback of view invalidate include: reading byte codes through an ASM tool, and detecting a signature of view invalidate; detecting a signature of the view invert, and acquiring a parameter corresponding to the parameter application instruction through the parameter application instruction; and inserting a callback method when the view invert is detected.
In the embodiment of the present disclosure, the runtime detecting the flap through the callback inserted in the compiling process includes: hot spot detection is started at runtime through code inserted at compile time.
S102, when the creating times of each view component is larger than a preset first threshold value, each view component is added into a first hot spot view component list, and a second hot spot view component list is obtained.
In an embodiment of the present disclosure, adding each view component to a first hotspot view component list includes:
and adding each view component and the context information corresponding to each view component into a first hot spot view component list.
In the embodiment of the present disclosure, obtaining the second hotspot view component list includes:
and updating the first hot spot view component list added with the view component to obtain a second hot spot view component list.
In the embodiment of the present disclosure, updating the first hotspot view component list added to the view component to obtain a second hotspot view component list includes:
and when a preset time condition is reached, performing persistence processing on the first hot spot view component list added with the view component to obtain a second hot spot view component list.
In the embodiment of the disclosure, a terminal App generates view info, and when the number of times of the view component view info in context is 3 or more than 3, the view and context information is added to a first hotspot view component list, namely a hotspot list, wherein a first threshold is 2.
In the embodiment of the present disclosure, detecting that App of a terminal has executed an invert view includes: detecting the call of the view update through a byte code tool, and acquiring the context information of the updated view according to the parameters.
In the embodiment of the present disclosure, the recording the number of times of instantiating a view under context includes: and recording context to which the view belongs through a mapping table of a byte code tool, and counting the view update.
In the embodiment of the present disclosure, adding the view and context information into a hotspot list includes: and when the number of times of view inventory is larger than a first threshold value, adding the view component view to a first hotspot view component list, namely a hotspot list, and performing persistence processing on the hotspot list at a proper time.
In the disclosed embodiment, the persistence process is a mechanism for transferring program data between a persistent state and a transient state; the transient data is persistent data, for example, the transient data is data in a memory, the transient data cannot be permanently stored, the data in the memory is persistent data, the persistent data is stored in a database, and the persistent data can be permanently stored.
In the embodiment of the present disclosure, the list of the second hotspot view components is output in a file or memory manner.
S103, at least one view component on the second hotspot view component list is pre-created.
In the embodiment of the present disclosure, the pre-creating at least one view component on the second hotspot view component list includes:
and pre-creating at least one view component on the second hot spot view component list according to the second hot spot view component list and the cache state of the view component on the second hot spot view component list, wherein the creation times of the at least one view component are larger than a second threshold value.
In the embodiment of the present disclosure, when there are multiple view components on the second hotspot view component list, a view component whose creation frequency of view component creation is greater than the second threshold is selected from the multiple view components to perform pre-creation.
In the embodiment of the disclosure, in an idle time, according to the second hotspot view component list, the view components on the second hotspot view component list are pre-created, for example, the idle time is a time when a cpu load of the processor is not high or all tasks of the view inventory scheduling framework have been completed.
In the embodiment of the disclosure, after the App is started, a thread is started on a background to load a view list input from the outside, and meanwhile, when the user is idle, the user does not need to pay attention to when to pre-create the view, and a view inventory scheduling framework can automatically pre-create the view when the user is idle according to a second hot view component list and the cache state of the current view.
In the embodiment of the disclosure, the creation of each view component is detected, and the number of times of creation of each view component is determined; when the creating times of each view component are larger than a preset first threshold value, adding each view component into a first hot spot view component list to obtain a second hot spot view component list; and pre-creating at least one view component on the second hotspot view component list. Therefore, the user is not required to control the pre-creation time of the view component and the pre-creation list of the view component, the creation of each view component is detected in real time, the obtained times of creation of each view component are compared with the preset first threshold value, the second hotspot view component list, namely the pre-creation list of the view component, can be obtained, and the pre-creation efficiency of the view component is improved.
Another method for pre-creating a view component is provided in the embodiments of the present disclosure, and a flowchart of the method is shown in fig. 2, where the method includes:
s201, detecting the view invert.
In the embodiment of the disclosure, the creation of view instantiates of a plurality of view components is detected, wherein the view represents the view components, and the view instantiates represents the creation of the view components.
S202, recording the frequency of view invert.
S203, judging whether the frequency of the view invert is more than 3, and if the frequency of the view invert is more than 3, turning to the step S204 for processing; when the number of view updates is not more than 3, the process goes to step S208.
In the embodiment of the present disclosure, the first threshold is 3.
S204, adding the view to a first hotspot view component list.
In an embodiment of the present disclosure, the first hotspot view component list is a hotspot list.
S205, judging whether to carry out persistence processing on the hotspot list, and when carrying out persistence processing on the hotspot list, turning to the step S206 for processing; when the persistence processing is not performed on the hotspot list, the process goes to step S208.
S206, the first hot spot view component list is subjected to persistence processing to obtain a second hot spot view component list.
In the embodiment of the disclosure, a hotspot list is subjected to persistence processing to obtain a second hotspot view component list.
And S207, automatically pre-creating the view in an idle time according to the second hotspot view component list and the caching condition of the current view.
And S208, ending the process.
The application of the embodiment of the disclosure has at least the following beneficial effects:
the method comprises the steps of detecting the creation of the view in real time, comparing the number of times of the created view with a preset first threshold value to obtain a second hot spot view component list, and automatically pre-creating the view in an idle time according to the second hot spot view component list and the cache condition of the current view, so that the efficiency of pre-creating the view is improved.
Based on the same inventive concept, the embodiment of the present disclosure further provides a pre-creation apparatus for view components, a schematic structural diagram of the apparatus is shown in fig. 3, and the pre-creation apparatus 30 for view components includes a first processing module 301, a second processing module 302, and a third processing module 303.
A first processing module 301, configured to detect creation of each view component, and determine the number of times of creation of each view component;
a second processing module 302, configured to add each view component to the first hot spot view component list to obtain a second hot spot view component list when the number of times of creation of each view component is greater than a preset first threshold;
a third processing module 303, configured to pre-create at least one view component on the second hotspot view component list.
In the embodiment of the present disclosure, the first processing module 301 is specifically configured to detect a bytecode related to creation of each view component, and determine context information corresponding to each view component; and determining the times of creation of each view component according to the context information corresponding to each view component.
In this embodiment of the present disclosure, the second processing module 302 is specifically configured to add each view component and context information corresponding to each view component to the first hotspot view component list.
In the embodiment of the present disclosure, the first processing module 301 is specifically configured to read a bytecode related to creation of each view component, and detect a signature related to creation of each view component according to the bytecode; when the signature is detected, obtaining a parameter corresponding to the parameter application instruction through a preset parameter application instruction; and determining the context information corresponding to each view component according to the parameters.
In this embodiment of the present disclosure, the second processing module 302 is specifically configured to update the first hotspot view component list added to the view component, so as to obtain a second hotspot view component list.
In this embodiment of the present disclosure, the second processing module 302 is specifically configured to perform persistence processing on the first hotspot view component list added to the view component when a preset time condition is reached, so as to obtain a second hotspot view component list.
In this embodiment of the present disclosure, the third processing module 303 is configured to pre-create at least one view component on the second hot spot view component list according to the second hot spot view component list and the cache state of the view component on the second hot spot view component list, where a number of times of creating the at least one view component is greater than a second threshold.
The application of the embodiment of the disclosure has at least the following beneficial effects:
detecting the creation of each view component, and determining the number of creation times of each view component; when the number of times of creation of each view component is larger than a preset first threshold value, adding each view component into a first hot spot view component list to obtain a second hot spot view component list; and pre-creating at least one view component on the second hotspot view component list. Therefore, the user is not required to control the pre-creation time of the view component and the pre-creation list of the view component, the creation of each view component is detected in real time, the obtained times of creation of each view component are compared with the preset first threshold value, the second hotspot view component list, namely the pre-creation list of the view component, can be obtained, and the pre-creation efficiency of the view component is improved.
For the content that is not described in detail in the pre-creation apparatus of the view component provided in the embodiment of the present disclosure, reference may be made to the pre-creation method of the view component provided in the above embodiment, and the beneficial effects that can be achieved by the pre-creation apparatus of the view component provided in the embodiment of the present disclosure are the same as the pre-creation method of the view component provided in the above embodiment, and are not described again here.
Referring now to FIG. 4, a block diagram of an electronic device 800 suitable for use in implementing embodiments of the present disclosure is shown. The terminal device in the embodiments of the present disclosure may include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a digital broadcast receiver, a PDA (personal digital assistant), a PAD (tablet computer), a PMP (portable multimedia player), a vehicle terminal (e.g., a car navigation terminal), and the like, and a stationary terminal such as a digital TV, a desktop computer, and the like. The electronic device shown in fig. 4 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
The electronic device includes: a memory and a processor, wherein the processor may be referred to as a processing device 801 described below, the memory may include at least one of a Read Only Memory (ROM) 802, a Random Access Memory (RAM) 803, and a storage device 808, as shown in fig. 4:
the electronic device 800 may include a processing means (e.g., a central processing unit, a graphics processor, etc.) 801 that may perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM) 802 or a program loaded from a storage means 808 into a Random Access Memory (RAM) 803. In the RAM 803, various programs and data necessary for the operation of the electronic apparatus 800 are also stored. The processing device 801, the ROM 802, and the RAM 803 are connected to each other by a bus 804. An input/output (I/O) interface 805 is also connected to bus 804.
Generally, the following devices may be connected to the I/O interface 805: input devices 806 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; output devices 807 including, for example, a Liquid Crystal Display (LCD), speakers, vibrators, and the like; storage 808 including, for example, magnetic tape, hard disk, etc.; and a communication device 809. The communication means 809 may allow the electronic device 800 to communicate wirelessly or by wire with other devices to exchange data. While fig. 4 illustrates an electronic device 800 having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may be alternatively implemented or provided.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program carried on a non-transitory computer readable medium, the computer program containing program code for performing the method illustrated by the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication means 809, or installed from the storage means 808, or installed from the ROM 802. The computer program, when executed by the processing apparatus 801, performs the above-described functions defined in the methods of the embodiments of the present disclosure.
It should be noted that the computer readable medium of the present disclosure may be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In contrast, in the present disclosure, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
In some embodiments, the clients, servers may communicate using any currently known or future developed network Protocol, such as HTTP (HyperText Transfer Protocol), and may interconnect with any form or medium of digital data communication (e.g., a communications network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), the Internet (e.g., the Internet), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future developed network.
The computer readable medium may be embodied in the electronic device; or may exist separately without being assembled into the electronic device.
The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: detecting the creation of each view component, and determining the creation times of each view component; when the creating times of each view component are larger than a preset first threshold value, adding each view component into a first hot spot view component list to obtain a second hot spot view component list; and pre-creating at least one view component on the second hotspot view component list.
Computer program code for carrying out operations for aspects of the present disclosure may be written in any combination of one or more programming languages, including but not limited to an object oriented programming language such as Java, smalltalk, C + +, including conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules or units described in the embodiments of the present disclosure may be implemented by software or hardware. Wherein the designation of a module or unit does not in some cases constitute a limitation on the unit itself.
The functions described herein above may be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), systems on a chip (SOCs), complex Programmable Logic Devices (CPLDs), and the like.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
According to one or more embodiments of the present disclosure, an embodiment provides a method for pre-creating a view component, including:
detecting the creation of each view component, and determining the creation times of each view component;
when the creating times of each view component are larger than a preset first threshold value, adding each view component into a first hot spot view component list to obtain a second hot spot view component list;
and pre-creating at least one view component on the second hotspot view component list.
In the embodiment of the present disclosure, detecting creation of each view component, and determining the number of times of creation of each view component includes:
detecting byte codes related to the creation of each view component, and determining context information corresponding to each view component;
determining the times of creation of each view component according to the context information corresponding to each view component;
adding each view component to a first hotspot view component list, comprising:
and adding each view component and the context information corresponding to each view component into a first hotspot view component list.
In the embodiment of the present disclosure, detecting the bytecode related to the creation of each view component, and determining the context information corresponding to each view component includes:
reading the byte codes related to the creation of each view component, and detecting the signature related to the creation of each view component according to the byte codes;
when the signature is detected, obtaining a parameter corresponding to the parameter application instruction through a preset parameter application instruction;
and determining context information corresponding to each view component according to the parameters.
In an embodiment of the present disclosure, obtaining the list of the second hotspot view components includes:
and updating the first hotspot view component list added with the view component to obtain a second hotspot view component list.
In the embodiment of the present disclosure, updating the first hotspot view component list added to the view component to obtain a second hotspot view component list includes:
and when a preset time condition is reached, performing persistence processing on the first hot spot view component list added with the view component to obtain a second hot spot view component list.
In the embodiment of the present disclosure, the pre-creating at least one view component on the second hotspot view component list includes:
and pre-creating at least one view component on the second hot spot view component list according to the second hot spot view component list and the cache state of the view component on the second hot spot view component list, wherein the creation times of the at least one view component are greater than a second threshold value.
According to one or more embodiments of the present disclosure, an embodiment provides a pre-creation apparatus of a view component, including:
the first processing module is used for detecting the creation of each view component and determining the creation times of each view component;
the second processing module is used for adding each view component into the first hot spot view component list to obtain a second hot spot view component list when the creation times of each view component are larger than a preset first threshold;
and the third processing module is used for pre-creating at least one view component on the second hotspot view component list.
In an embodiment of the present disclosure, the first processing module is specifically configured to detect a bytecode related to creation of each view component, and determine context information corresponding to each view component; and determining the times of creation of each view component according to the context information corresponding to each view component.
In an embodiment of the present disclosure, the second processing module is specifically configured to add each view component and context information corresponding to each view component to the first hotspot view component list.
In an embodiment of the present disclosure, the first processing module is specifically configured to read a bytecode related to creation of each view component, and detect a signature related to creation of each view component according to the bytecode; when the signature is detected, obtaining a parameter corresponding to the parameter application instruction through a preset parameter application instruction; and determining the context information corresponding to each view component according to the parameters.
In an embodiment of the present disclosure, the second processing module is specifically configured to update the first hot spot view component list added to the view component to obtain a second hot spot view component list.
In an embodiment of the present disclosure, the second processing module is specifically configured to, when a preset time condition is reached, perform persistence processing on the first hotspot view component list added to the view component, to obtain a second hotspot view component list.
In this embodiment of the disclosure, the third processing module is configured to pre-create at least one view component on the second hot spot view component list according to the second hot spot view component list and the cache state of the view component on the second hot spot view component list, where the number of times of creating the at least one view component is greater than a second threshold.
The foregoing description is only exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the disclosure herein is not limited to the particular combination of features described above, but also encompasses other embodiments in which any combination of the features described above or their equivalents does not depart from the spirit of the disclosure. For example, the above features and (but not limited to) the features disclosed in this disclosure having similar functions are replaced with each other to form the technical solution.
Further, while operations are depicted in a particular order, this should not be understood as requiring that such operations be performed in the particular order shown or in sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Likewise, while several specific implementation details are included in the above discussion, these should not be construed as limitations on the scope of the disclosure. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable subcombination.
Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are disclosed as example forms of implementing the claims.