Summary of the invention
For addressing the above problem, the object of the present invention is to provide a kind of method and system of assessing the packaging file readwrite performance, assess the readwrite performance of packaging file by file identification, it is objective and accurate to make to assess.
The present invention solves the technical scheme that its problem adopts:
The present invention adopts a kind of method and system of assessing the packaging file readwrite performance, at first generate a sequential file, this sequential file includes the file identification described packaging file is described according to certain logical order, because some sign in file identification possibly can't find in packaging file, some signs or repetition, therefore, the file identification that need to comprise sequential file is arranged, when arranging, delete the file identification that those can't find in packaging file, delete the file identification of those repetitions simultaneously, when deleting the file identification repeated, in deleted file sign sequence after sign.
After the file identification comprised in sequential file is arranged, need to assess the readwrite performance of packaging file, include many files in packaging file, file reading identifies successively, find out corresponding file simultaneously in packaging file, if the off-set value of current found out file in packaging file equals off-set value and the big or small sum thereof of the previous file found out in packaging file, illustrate that the corresponding file identification of current file is for desirable sign; For first file identification read, judge by the mode that initial value is set whether it is desirable sign, if the off-set value of the corresponding file of this file identification in packaging file equals initial value, illustrate that it is desirable sign.File identification wherein can be unduplicated filename, file relative path, file absolute path or file path cryptographic hash etc.
Finally, calculate the ratio that desirable sign accounts for sequential file All Files sign, weigh the readwrite performance of packaging file with this ratio.
The invention has the beneficial effects as follows:
The present invention adopts a kind of method and system of assessing the packaging file readwrite performance, by the readwrite performance of the judgement of the file identification in sequential file packaging file, more objective during calculating, can not be subject to the impact of computing power; Simultaneously, whole method is simple, relatively saves time, and because file identification is to generate in advance, therefore, the accuracy of result of calculation is also higher.
Embodiment
Embodiment 1:
Process flow diagram with reference to the method for the invention shown in Fig. 1, the invention provides a kind of method of assessing the packaging file readwrite performance, at first spanned file sequence, this file sequence has comprised the file identification described packaging file is described according to certain logical order, these file identifications may generate by program, also can initiatively be inputted by the programmer, or read the logic generation by the HOOK program.
Because the file identification generated may include repetition or unnecessary, the so-called repetition, refer to that same file identification is more than one, so-called unnecessary, refers to that file identification can't find in packaging file.Therefore, need to the file identification generated be arranged the file identification of Delete superfluous and repetition.For unnecessary file identification, in the scanning packaging file, the file identification of All Files, be identified at the All Files comprised in the file sequence in the file identification scanned and searched, if do not find, illustrate that it does not lie in packaging file, by its deletion; When deleting the file identification repeated, because file identification is to arrange according to certain reading order, therefore, need to delete the file identification of sequence in back, and be retained in the file identification of front, and only retain one.When the file identification of Delete superfluous and repetition, optimum order is first to delete the file identification of repetition, and the workload of minimizing postorder that like this can be preferential, save time.
After file identification in the file sequence is arranged, need by the performance of these file identification assessment packaging files.Read successively the file identification in sequential file, search read file identification corresponding file in packaging file simultaneously, if the off-set value of the current file found equates with off-set value and the big or small sum thereof of the previous file found, record the corresponding file identification of this current file for desirable sign.Owing to reading first file identification, there is no so-called previous file sign, therefore, need to judge whether first file identification is desirable sign by initial value is set, if the off-set value of the corresponding file of first file identification equals initial value, illustrate that it is desirable sign.When specific implementation, two counters can be set, counter one is used to desirable sign counting, the off-set value sum big or small with it of the current file that counter two finds for record, for counter two arranges initial value, read successively the file identification in sequential file, when reading first file identification, search the file of this file identification correspondence in packaging file, if the off-set value of the file found in packaging file equals initial value, illustrate that it is desirable sign, counter one adds 1, simultaneously, the value of counter two is set to off-set value and the big or small sum thereof of first file identification institute respective file in packaging file, afterwards, read second file identification, search the file of this file identification in packaging file, if the off-set value of the file found equates with the value of counter two, illustrate that second file identification is for desirable sign, counter one adds 1 again, off-set value and big or small sum that the value that counter two is set simultaneously is second file identification institute respective file, the like, until that all file identifications read is complete.
Finally, the number of calculating desirable sign accounts for the ratio of All Files sign in the file sequence, and ratio value is between 0 to 1, and this numerical value reacted the readwrite performance of packaging file, and data are higher, show that readwrite performance is better.
For file identification, can select unduplicated filename, file relative path, file absolute path or file path cryptographic hash etc., as long as the sign of different files is unique.
The invention provides a kind of system of assessing the packaging file readwrite performance, comprising:
For the device of formation sequence file, described sequential file includes the file identification described packaging file is described according to certain logical order;
For deleting the file identification that described sequential file can't find in packaging file, delete the device of the file identification repeated in sequential file simultaneously, wherein, during the file identification that repeats in deleting sequential file, delete sequence after file identification, retain the file identification the preceding that sorts;
For reading successively the file identification of sequential file, search read file identification corresponding file in packaging file simultaneously, if the off-set value of the current file found in packaging file is with the previous file found, the off-set value in packaging file and big or small sum thereof equate, record the device of the corresponding file identification of this current file for desirable sign, wherein, for first read file identification, judge by the mode that initial value is set whether first read file identification is desirable sign, if the off-set value of the corresponding file of first file identification read is identical with initial value, record it for desirable sign,
Account for the device of the ratio of sequential file All Files sign for calculating desirable sign.
Wherein, All Files in described packaging file is scanned, obtain the file identification of All Files, contrasted by the file identification by sequential file and the file identification obtained, to delete the file identification that can't find in described sequential file in packaging file.
Described system adopts the method identical with the above to be assessed packaging file, concrete with reference to content described in above method.
Embodiment 2:
The present embodiment describes the method in embodiment 1 by object lesson, and wherein the file sequence is as follows:
Include successively and include three file identifications in this file sequence, be followed successively by a.txt, b.txt, c.txt.The file comprised in packaging file is as follows:
File identification |
Off-set value |
File size |
a.txt |
0 |
100 |
b.txt |
100 |
200 |
d.txt |
300 |
10 |
c.txt |
310 |
90 |
e.txt |
400 |
100 |
Wherein, off-set value has recorded the offset address of respective file in packaging file, and file size has shown the size of this file.
After file identification in the file sequence is arranged, file identification is followed successively by a.txt, b.txt, c.txt, because wherein there is no repetition and unnecessary file identification.
The initial value of counter two is set to 0, and generally, when packaging file is stored, the off-set value of its first file is 0, therefore, when the initial value of counter two is set, should carry out initialization according to the off-set value of first file in packaging file.
File identification in the file reading sequence successively, first reading is a.txt, finds that its off-set value is identical with initial value, illustrate that it is desirable sign, counter one adds 1, and the value of counter two is set to the off-set value sum big or small with it of respective file, i.e. " 0 "+" 100 "; Afterwards, read second file identification b.txt, its off-set value is 100, identical with the value in counter two, illustrates that it is desirable sign, and counter one adds 1 again, and the value of counter two is set to " 100 "+" 200 " simultaneously; Read the 3rd file identification c.txt, its off-set value is 310, unequal with 300 numerical value in counter two, illustrates that it is not desirable sign, and the value of counter two is set to " 310 "+" 90 " simultaneously; So far, all file identifications read complete, and the number of calculating desirable sign accounts for the ratio of All Files sign, and 2/3, therefore " assessment result "=2/3=0.66.
The above, be preferred embodiment of the present invention, and the present invention is not limited to above-mentioned embodiment, as long as it reaches technique effect of the present invention with identical means, all should belong to protection scope of the present invention.