react-native-update 10.53.1 → 10.55.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/README-CN.md +59 -31
  2. package/README.md +62 -32
  3. package/android/jni/HDiffPatch/.travis.yml +33 -0
  4. package/android/jni/HDiffPatch/builds/xcode/bestParams.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  5. package/android/jni/HDiffPatch/builds/xcode/hdiffz.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  6. package/android/jni/HDiffPatch/builds/xcode/hdiffz.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  7. package/android/jni/HDiffPatch/builds/xcode/hpatchz.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  8. package/android/jni/HDiffPatch/builds/xcode/lz4.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  9. package/android/jni/HDiffPatch/builds/xcode/lzma.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  10. package/android/jni/HDiffPatch/builds/xcode/testHashClash.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  11. package/android/jni/HDiffPatch/builds/xcode/testHashClash.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  12. package/android/jni/HDiffPatch/builds/xcode/unitTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  13. package/android/jni/HDiffPatch/builds/xcode/zstd.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  14. package/android/jni/lzma/DOC/7zC.txt +187 -0
  15. package/android/jni/lzma/DOC/7zFormat.txt +469 -0
  16. package/android/jni/lzma/DOC/Methods.txt +173 -0
  17. package/android/jni/lzma/DOC/installer.txt +166 -0
  18. package/android/jni/lzma/DOC/lzma-history.txt +446 -0
  19. package/android/jni/lzma/DOC/lzma-sdk.txt +357 -0
  20. package/android/jni/lzma/DOC/lzma-specification.txt +1176 -0
  21. package/android/jni/lzma/DOC/lzma.txt +328 -0
  22. package/android/jni/lzma/bin/7zS2.sfx +0 -0
  23. package/android/jni/lzma/bin/7zS2con.sfx +0 -0
  24. package/android/jni/lzma/bin/7zSD.sfx +0 -0
  25. package/android/jni/lzma/bin/7zdec.exe +0 -0
  26. package/android/jni/lzma/bin/7zr.exe +0 -0
  27. package/android/jni/lzma/bin/installer/config.txt +5 -0
  28. package/android/jni/lzma/bin/installer/cr.bat +5 -0
  29. package/android/jni/lzma/bin/lzma.exe +0 -0
  30. package/android/jni/lzma/bin/x64/7zr.exe +0 -0
  31. package/android/lib/arm64-v8a/librnupdate.so +0 -0
  32. package/android/lib/armeabi-v7a/librnupdate.so +0 -0
  33. package/android/lib/x86/librnupdate.so +0 -0
  34. package/android/lib/x86_64/librnupdate.so +0 -0
  35. package/android/src/main/java/cn/reactnative/modules/update/ArchiveLimits.java +44 -0
  36. package/android/src/main/java/cn/reactnative/modules/update/DownloadTask.java +124 -40
  37. package/android/src/main/java/cn/reactnative/modules/update/InstallRecord.java +125 -0
  38. package/android/src/main/java/cn/reactnative/modules/update/NativeCheckOrchestrator.java +43 -11
  39. package/android/src/main/java/cn/reactnative/modules/update/NativeUpdateFlow.java +2 -0
  40. package/android/src/main/java/cn/reactnative/modules/update/SafeZipFile.java +90 -0
  41. package/android/src/main/java/cn/reactnative/modules/update/UpdateContext.java +79 -19
  42. package/android/src/main/java/cn/reactnative/modules/update/UpdateFileUtils.java +21 -0
  43. package/android/src/main/java/cn/reactnative/modules/update/UpdateModuleImpl.java +33 -2
  44. package/android/src/main/java/cn/reactnative/modules/update/UpdateModuleSupport.java +1 -0
  45. package/android/src/newarch/cn/reactnative/modules/update/UpdateModule.java +5 -0
  46. package/android/src/oldarch/cn/reactnative/modules/update/UpdateModule.java +5 -0
  47. package/cpp/patch_core/archive_limits.h +38 -0
  48. package/cpp/patch_core/install_record.h +36 -0
  49. package/cpp/update_flow_core/flow_json.h +1 -0
  50. package/cpp/update_flow_core/update_flow_core.cpp +41 -7
  51. package/cpp/update_flow_core/update_flow_core.h +9 -0
  52. package/cpp/update_flow_core/update_flow_jni.cpp +12 -0
  53. package/harmony/pushy/src/main/cpp/PushyTurboModule.cpp +2 -0
  54. package/harmony/pushy/src/main/cpp/pushy.cpp +37 -0
  55. package/harmony/pushy/src/main/ets/ArchiveLimits.ts +83 -0
  56. package/harmony/pushy/src/main/ets/DownloadTask.ts +126 -30
  57. package/harmony/pushy/src/main/ets/InstallRecord.ts +129 -0
  58. package/harmony/pushy/src/main/ets/NativeCheckOrchestrator.ts +24 -2
  59. package/harmony/pushy/src/main/ets/NativePatchCore.ts +5 -0
  60. package/harmony/pushy/src/main/ets/PushyTurboModule.ts +12 -0
  61. package/harmony/pushy/src/main/ets/UpdateContext.ts +78 -15
  62. package/harmony/pushy.har +0 -0
  63. package/ios/RCTPushy/RCTPushy.mm +384 -25
  64. package/ios/RCTPushy/RCTPushyDownloader.mm +32 -0
  65. package/package.json +25 -2
  66. package/src/NativePushy.ts +13 -0
  67. package/src/client.ts +288 -47
  68. package/src/core.ts +17 -3
  69. package/src/error.ts +3 -0
  70. package/src/errorReporting.ts +136 -0
  71. package/src/index.ts +14 -0
  72. package/src/locales/en.ts +3 -0
  73. package/src/locales/zh.ts +2 -0
  74. package/src/metadata.ts +166 -0
  75. package/src/provider.tsx +52 -17
  76. package/src/type.ts +29 -0
  77. package/src/updateFlowCore.ts +95 -4
  78. package/src/utils.ts +31 -19
  79. package/.gitmodules +0 -6
  80. package/BUNDLEHASH_MIGRATION.md +0 -355
  81. package/NATIVE_CHECKUPDATE_DESIGN.md +0 -539
  82. package/NATIVE_CHECK_FOLLOWUPS.md +0 -514
  83. package/android/jni/HDiffPatch/test/_private_searchBestParams.cpp +0 -301
  84. package/android/jni/HDiffPatch/test/hpatchz_test.cpp +0 -292
  85. package/android/jni/HDiffPatch/test/testHashClash.cpp +0 -436
  86. package/android/jni/HDiffPatch/test/unit_test.cpp +0 -417
  87. package/biome.json +0 -59
  88. package/cpp/patch_core/tests/fixtures/rawstored.lzma2label.patch.bin +0 -0
  89. package/cpp/patch_core/tests/fixtures/rawstored.new.bin +0 -0
  90. package/cpp/patch_core/tests/fixtures/rawstored.old.bin +0 -0
  91. package/cpp/patch_core/tests/fixtures/v96.hbc +0 -0
  92. package/cpp/patch_core/tests/fixtures/v96.meta.json +0 -1
  93. package/cpp/patch_core/tests/fixtures/v96.streampatch.bin +0 -0
  94. package/cpp/patch_core/tests/fixtures/v96.t.hbc +0 -0
  95. package/cpp/patch_core/tests/fixtures/v96.tpatch.bin +0 -0
  96. package/cpp/patch_core/tests/fixtures/v96.tstreampatch.bin +0 -0
  97. package/cpp/patch_core/tests/fixtures/v96b.hbc +0 -0
  98. package/cpp/patch_core/tests/fixtures/v98.hbc +0 -0
  99. package/cpp/patch_core/tests/fixtures/v98.t.hbc +0 -0
  100. package/cpp/patch_core/tests/fixtures/v98b.hbc +0 -0
  101. package/cpp/patch_core/tests/fixtures/v98b.t.hbc +0 -0
  102. package/cpp/patch_core/tests/hbc_transform_test.cpp +0 -384
  103. package/cpp/patch_core/tests/patch_core_test.cpp +0 -970
  104. package/cpp/update_flow_core/tests/flow_vectors.json +0 -1401
  105. package/cpp/update_flow_core/tests/update_flow_core_test.cpp +0 -317
  106. package/scripts/check-expo-version.js +0 -92
@@ -1,436 +0,0 @@
1
- // testHashClash.cpp
2
- // tool for HDiff
3
- // An estimation method for detecting hash clashs
4
- /*
5
- The MIT License (MIT)
6
- Copyright (c) 2012-2019 HouSisong
7
-
8
- Permission is hereby granted, free of charge, to any person
9
- obtaining a copy of this software and associated documentation
10
- files (the "Software"), to deal in the Software without
11
- restriction, including without limitation the rights to use,
12
- copy, modify, merge, publish, distribute, sublicense, and/or sell
13
- copies of the Software, and to permit persons to whom the
14
- Software is furnished to do so, subject to the following
15
- conditions:
16
-
17
- The above copyright notice and this permission notice shall be
18
- included in all copies of the Software.
19
-
20
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
22
- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24
- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
25
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27
- OTHER DEALINGS IN THE SOFTWARE.
28
- */
29
-
30
- #include <iostream>
31
- #include <stdlib.h>
32
- #include <vector>
33
- #include <unordered_map>
34
- #include "zlib.h"
35
- #include "md5.h" // https://sourceforge.net/projects/libmd5-rfc
36
- #include "../libHDiffPatch/HDiff/private_diff/limit_mem_diff/adler_roll.h"
37
- #include "../_clock_for_demo.h"
38
- typedef unsigned char TByte;
39
- typedef ptrdiff_t TInt;
40
- typedef size_t TUInt;
41
-
42
- /*
43
- struct THash{
44
- typename TValue;
45
- static const char* name() const;
46
- void hash_begin();
47
- void hash(const TByte* pdata,const TByte* pdataEnd);
48
- void hash_finish(TValue* hv);
49
- };*/
50
-
51
- struct THash_md5_128{
52
- typedef std::pair<uint64_t,uint64_t> TValue;
53
- inline static const char* name() { return "md5_128"; }
54
- md5_state_t _hv;
55
- inline void hash_begin() { md5_init(&_hv); }
56
- inline void hash(const TByte* pdata,const TByte* pdata_end)
57
- { md5_append(&_hv,pdata,(int)(pdata_end-pdata)); }
58
- inline void hash_end(TValue* hv) { md5_finish(&_hv,(TByte*)hv); }
59
- };
60
-
61
- namespace std{
62
- template<> struct hash<THash_md5_128::TValue>{
63
- inline size_t operator()(const THash_md5_128::TValue& v) const{
64
- return v.first^v.second; }
65
- };
66
- template<> struct less<THash_md5_128::TValue>{
67
- inline bool operator()(const THash_md5_128::TValue& x,const THash_md5_128::TValue& y)const{
68
- return (x.first^x.second) < (y.first^y.second); }
69
- };
70
- }
71
-
72
- struct THash_crc32{
73
- typedef uint32_t TValue;
74
- inline static const char* name() { return "crc32"; }
75
- TValue _hv;
76
- inline void hash_begin() { _hv=(TValue)crc32(0,0,0); }
77
- inline void hash(const TByte* pdata,const TByte* pdata_end)
78
- { _hv=(TValue)crc32(_hv,pdata,(uInt)(pdata_end-pdata)); }
79
- inline void hash_end(TValue* hv) { *hv=_hv; }
80
- };
81
-
82
- struct THash_adler32{
83
- typedef uint32_t TValue;
84
- inline static const char* name() { return "adler32"; }
85
- TValue _hv;
86
- inline void hash_begin() { _hv=(TValue)adler32(0,0,0); }
87
- inline void hash(const TByte* pdata,const TByte* pdata_end)
88
- { _hv=(TValue)adler32(_hv,pdata,(uInt)(pdata_end-pdata)); }
89
- inline void hash_end(TValue* hv) { *hv=_hv; }
90
- };
91
-
92
-
93
- struct THash_adler32h{
94
- typedef uint32_t TValue;
95
- inline static const char* name() { return "adler32h"; }
96
- TValue _hv;
97
- inline void hash_begin() { _hv=adler32_start(0,0); }
98
- inline void hash(const TByte* pdata,const TByte* pdata_end)
99
- { _hv=adler32_append(_hv,pdata,(pdata_end-pdata));
100
- //assert(_hv==(TValue)adler32(1,pdata,(pdata_end-pdata)));
101
- }
102
- inline void hash_end(TValue* hv) { *hv=_hv; }
103
- };
104
-
105
- struct THash_fadler32{
106
- typedef uint32_t TValue;
107
- inline static const char* name() { return "fadler32"; }
108
- TValue _hv;
109
- inline void hash_begin() { _hv=fast_adler32_start(0,0); }
110
- inline void hash(const TByte* pdata,const TByte* pdata_end)
111
- { _hv=fast_adler32_append(_hv,pdata,(pdata_end-pdata)); }
112
- inline void hash_end(TValue* hv) { *hv=_hv; }
113
- };
114
-
115
- struct THash_adler64h{
116
- typedef uint64_t TValue;
117
- inline static const char* name() { return "adler64h"; }
118
- TValue _hv;
119
- inline void hash_begin() { _hv=adler64_start(0,0); }
120
- inline void hash(const TByte* pdata,const TByte* pdata_end)
121
- { _hv=adler64_append(_hv,pdata,(pdata_end-pdata)); }
122
- inline void hash_end(TValue* hv) { *hv=_hv; }
123
- };
124
-
125
- struct THash_fadler64{
126
- typedef uint64_t TValue;
127
- inline static const char* name() { return "fadler64"; }
128
- TValue _hv;
129
- inline void hash_begin() { _hv=fast_adler64_start(0,0); }
130
- inline void hash(const TByte* pdata,const TByte* pdata_end)
131
- { _hv=fast_adler64_append(_hv,pdata,(pdata_end-pdata)); }
132
- inline void hash_end(TValue* hv) { *hv=_hv; }
133
- };
134
-
135
- struct THash_fadler128{
136
- typedef adler128_t TValue;
137
- inline static const char* name() { return "fadler128"; }
138
- TValue _hv;
139
- inline void hash_begin() { _hv=fast_adler128_start(0,0); }
140
- inline void hash(const TByte* pdata,const TByte* pdata_end)
141
- { _hv=fast_adler128_append(_hv,pdata,(pdata_end-pdata)); }
142
- inline void hash_end(TValue* hv) { *hv=_hv; }
143
- };
144
- struct _adler128_t_hash{
145
- inline size_t operator()(const adler128_t& c)const{
146
- return c.adler ^ c.sum;
147
- }
148
- };
149
- struct _adler128_t_cmp{
150
- inline bool operator()(const adler128_t& x, const adler128_t& y)const{
151
- return (x.adler==y.adler) & (x.sum==y.sum);
152
- }
153
- };
154
-
155
- const uint64_t kMaxMapNodeSize=80000000ull; //run test memory ctrl
156
- const size_t kRandTestMaxSize=1024*1024*1024;//test rand data size
157
- const size_t kMaxHashDataSize=256;
158
- size_t kMinClash=0; //run test max time ctrl
159
-
160
- template <class THash,class TUInt,int kTestBit=sizeof(TUInt)*8,TUInt kTestMask=(TUInt)~(TUInt)0>
161
- void test(const TByte* data,const TByte* data_end){
162
- typedef typename THash::TValue TValue;
163
- typedef std::pair<const TByte*,const TByte*> TPair;
164
- typedef std::unordered_map<TUInt,TPair> TMap;
165
- double time0=clock_s();
166
- const size_t clip_count=sizeof(TValue)/sizeof(TUInt);
167
- assert(clip_count*sizeof(TUInt)==sizeof(TValue)); //unsupport other bit
168
- TMap maps[clip_count];
169
- for (size_t m=0;m<clip_count;++m)
170
- maps[m].reserve(kMaxMapNodeSize*3/clip_count);
171
- unsigned int rand_seed=7;
172
- if (kTestMask!=(TUInt)~(TUInt)0) printf("mask[%08X %08X] ",(int)(kTestMask>>32),(int)kTestMask);
173
- printf("%s%s ",THash::name(),std::string(10-strlen(THash::name()),' ').c_str());
174
-
175
- uint64_t curClashMin=0;
176
- uint64_t clashs[clip_count]={0};
177
- double clashBases[clip_count]={0};
178
- size_t i=0;
179
- while (curClashMin<kMinClash) {
180
- uint64_t clashMin=-(uint64_t)1;
181
- for (size_t m=0;m<clip_count;++m){
182
- if (clashs[m]<clashMin) clashMin=clashs[m];
183
- }
184
- curClashMin=clashMin;
185
-
186
- size_t dlen=rand_r(&rand_seed) % kMaxHashDataSize;
187
- size_t dstrat=rand_r(&rand_seed) % ((data_end-data) - dlen);
188
- assert(dstrat+dlen<=(data_end-data));
189
- const TByte* pv =data+dstrat;
190
- const TByte* pv_end=pv+dlen;
191
-
192
- THash th;
193
- typename THash::TValue hvs;
194
- th.hash_begin();
195
- th.hash(pv,pv_end);
196
- th.hash_end(&hvs);
197
- for (size_t m=0;m<clip_count;++m){
198
- TMap& map=maps[m];
199
- uint64_t& clash=clashs[m];
200
- double& clashBase=clashBases[m];
201
- TUInt hv=((TUInt*)&hvs)[m];
202
- hv&=kTestMask;
203
- auto it=map.find(hv);
204
- if (it==map.end()){
205
- if (map.size()*clip_count<kMaxMapNodeSize)
206
- map[hv]=TPair(pv,pv_end);
207
- clashBase+=map.size();
208
- ++i;
209
- }else{
210
- const TPair& v=it->second;
211
- const TByte* vf=v.first;
212
- if ((pv_end-pv)!=(v.second-vf)){
213
- ++clash;
214
- clashBase+=map.size();
215
- ++i;
216
- } else if (pv==vf){
217
- //same i
218
- }else{
219
- bool isEq=true;
220
- for (size_t e=0; e<dlen; ++e) {
221
- if (pv[e]==vf[e]){
222
- continue;
223
- }else{
224
- isEq=false;
225
- break;
226
- }
227
- }
228
- if (isEq){
229
- //same i
230
- }else{
231
- ++clash;
232
- clashBase+=map.size();
233
- ++i;
234
- }
235
- }
236
- }
237
- }
238
- }
239
- for (size_t m=0;m<clip_count;++m)
240
- maps[m].clear();
241
-
242
- printf("test %dbitx%d, clash rate: ",kTestBit,(int)clip_count);
243
- if (clip_count>0) printf("[");
244
- for (size_t m=0;m<clip_count; ++m) {
245
- double clashR=clashs[m]/clashBases[m];
246
- if (m>0) printf(" ");
247
- if (clashR>0){
248
- //printf("%.3e(%.1fbit)",clashR,log2(1/clashR));
249
- printf("%.2fbit",log2(1/clashR));
250
- }else{
251
- printf("0/%.3e",clashBases[m]);
252
- }
253
- }
254
- if (clip_count>0) printf("]");
255
- printf(" \ttime:%.1fs\n",(clock_s()-time0));
256
- }
257
-
258
- template <uint64_t kTestMask0,uint64_t kTestMask1>
259
- void test_fadler128(const TByte* data,const TByte* data_end){
260
- typedef THash_fadler128 THash;
261
- typedef uint64_t TUInt;
262
- typedef typename THash::TValue TValue;
263
- typedef std::pair<const TByte*,const TByte*> TPair;
264
- typedef std::unordered_map<TValue,TPair,_adler128_t_hash,_adler128_t_cmp> TMap;
265
- double time0=clock_s();
266
- const size_t clip_count=1;
267
- TMap maps[clip_count];
268
- for (size_t m=0;m<clip_count;++m)
269
- maps[m].reserve(kMaxMapNodeSize*3/clip_count);
270
- unsigned int rand_seed=7;
271
- printf("mask[%08X %08X ",(int)(kTestMask1>>32),(int)kTestMask1);
272
- printf("%08X %08X] ",(int)(kTestMask0>>32),(int)kTestMask0);
273
- printf("%s%s ",THash::name(),std::string(10-strlen(THash::name()),' ').c_str());
274
-
275
- uint64_t curClashMin=0;
276
- uint64_t clashs[clip_count]={0};
277
- double clashBases[clip_count]={0};
278
- size_t i=0;
279
- while (curClashMin<kMinClash) {
280
- uint64_t clashMin=-(uint64_t)1;
281
- for (size_t m=0;m<clip_count;++m){
282
- if (clashs[m]<clashMin) clashMin=clashs[m];
283
- }
284
- curClashMin=clashMin;
285
-
286
- size_t dlen=rand_r(&rand_seed) % kMaxHashDataSize;
287
- size_t dstrat=rand_r(&rand_seed) % ((data_end-data) - dlen);
288
- assert(dstrat+dlen<=(data_end-data));
289
- const TByte* pv =data+dstrat;
290
- const TByte* pv_end=pv+dlen;
291
-
292
- THash th;
293
- typename THash::TValue hvs;
294
- th.hash_begin();
295
- th.hash(pv,pv_end);
296
- th.hash_end(&hvs);
297
- for (size_t m=0;m<clip_count;++m){
298
- TMap& map=maps[m];
299
- uint64_t& clash=clashs[m];
300
- double& clashBase=clashBases[m];
301
- TValue hv=hvs;
302
- hv.adler&=kTestMask0;
303
- hv.sum&=kTestMask1;
304
- auto it=map.find(hv);
305
- if (it==map.end()){
306
- if (map.size()*clip_count<kMaxMapNodeSize)
307
- map[hv]=TPair(pv,pv_end);
308
- clashBase+=map.size();
309
- ++i;
310
- }else{
311
- const TPair& v=it->second;
312
- const TByte* vf=v.first;
313
- if ((pv_end-pv)!=(v.second-vf)){
314
- ++clash;
315
- clashBase+=map.size();
316
- ++i;
317
- } else if (pv==vf){
318
- //same i
319
- }else{
320
- bool isEq=true;
321
- for (size_t e=0; e<dlen; ++e) {
322
- if (pv[e]==vf[e]){
323
- continue;
324
- }else{
325
- isEq=false;
326
- break;
327
- }
328
- }
329
- if (isEq){
330
- //same i
331
- }else{
332
- ++clash;
333
- clashBase+=map.size();
334
- ++i;
335
- }
336
- }
337
- }
338
- }
339
- }
340
- for (size_t m=0;m<clip_count;++m)
341
- maps[m].clear();
342
-
343
- printf("clash rate: ");
344
- if (clip_count>0) printf("[");
345
- for (size_t m=0;m<clip_count; ++m) {
346
- double clashR=clashs[m]/clashBases[m];
347
- if (m>0) printf(" ");
348
- if (clashR>0){
349
- //printf("%.3e(%.1fbit)",clashR,log2(1/clashR));
350
- printf("%.2fbit",log2(1/clashR));
351
- }else{
352
- printf("0/%.3e",clashBases[m]);
353
- }
354
- }
355
- if (clip_count>0) printf("]");
356
- printf(" \ttime:%.1fs\n",(clock_s()-time0));
357
- }
358
-
359
- int main() {
360
- double bestCR_32bit =1.0/(((uint64_t)1)<<32);
361
- double bestCR_64bit =bestCR_32bit*bestCR_32bit;
362
- double bestCR_128bit=bestCR_64bit*bestCR_64bit;
363
- printf("32bit hash best clash rate: %.3e (1/%llu) \n",
364
- bestCR_32bit,(((uint64_t)1)<<32));
365
- printf("48bit hash best clash rate: %.3e (1/%llu) \n",
366
- 1.0/(((uint64_t)1)<<48),(((uint64_t)1)<<48));
367
- printf("64bit hash best clash rate: %.3e (1/%llu%llu) \n",
368
- bestCR_64bit,(((uint64_t)(-(uint64_t)1)))/10,(((uint64_t)(-(uint64_t)1)))%10+1);
369
- printf("128bit hash best clash rate: %.3e (1/%.3e) \n\n",
370
- bestCR_128bit,1/bestCR_128bit);
371
-
372
- std::vector<TByte> data(kRandTestMaxSize);
373
- unsigned int rand_seed=0;
374
- for (size_t i=0; i<data.size(); ++i) {
375
- data[i]=(TByte)rand_r(&rand_seed);
376
- }
377
- const uint64_t kTestMask8=((((uint64_t)1)<<8)-1);
378
- const uint64_t kTestMask16=((((uint64_t)1)<<16)-1);
379
- const uint64_t kTestMask32=((((uint64_t)1)<<32)-1);
380
- const uint64_t kTestMask64=~(uint64_t)0;
381
-
382
- //*
383
- kMinClash=100000;
384
- test<THash_adler32,uint8_t>(data.data(),data.data()+data.size());
385
- test<THash_adler32,uint16_t>(data.data(),data.data()+data.size());
386
- test<THash_adler32,uint32_t>(data.data(),data.data()+data.size());
387
- test<THash_adler32h,uint32_t>(data.data(),data.data()+data.size());
388
- test<THash_crc32,uint32_t>(data.data(),data.data()+data.size());
389
- test<THash_md5_128,uint32_t>(data.data(),data.data()+data.size());
390
- test<THash_adler64h,uint8_t>(data.data(),data.data()+data.size());
391
- test<THash_adler64h,uint16_t>(data.data(),data.data()+data.size());
392
- test<THash_adler64h,uint32_t>(data.data(),data.data()+data.size());
393
- test<THash_adler64h,uint64_t>(data.data(),data.data()+data.size());
394
- test<THash_fadler32,uint8_t>(data.data(),data.data()+data.size());
395
- test<THash_fadler32,uint16_t>(data.data(),data.data()+data.size());
396
- test<THash_fadler32,uint32_t>(data.data(),data.data()+data.size());
397
- test<THash_fadler64,uint8_t>(data.data(),data.data()+data.size());
398
- test<THash_fadler64,uint16_t>(data.data(),data.data()+data.size());
399
- test<THash_fadler64,uint32_t>(data.data(),data.data()+data.size());
400
- //test<THash_fadler64,uint64_t>(data.data(),data.data()+data.size());
401
- test<THash_fadler128,uint8_t>(data.data(),data.data()+data.size());
402
- test<THash_fadler128,uint16_t>(data.data(),data.data()+data.size());
403
- test<THash_fadler128,uint32_t>(data.data(),data.data()+data.size());
404
- kMinClash=50;
405
- test<THash_fadler128,uint64_t>(data.data(),data.data()+data.size());
406
- printf("\n");
407
- //*/
408
- //*
409
- printf("NOTE: test fadler64 32bit ...\n");
410
- kMinClash=100000;
411
- test<THash_fadler64,uint64_t,32,kTestMask32>(data.data(),data.data()+data.size());
412
- test<THash_fadler64,uint64_t,32,kTestMask32<<32>(data.data(),data.data()+data.size());
413
- test<THash_fadler64,uint64_t,32,kTestMask32<<16>(data.data(),data.data()+data.size());
414
- test<THash_fadler64,uint64_t,32,kTestMask16|kTestMask16<<32>(data.data(),data.data()+data.size());
415
- test<THash_fadler64,uint64_t,32,kTestMask16<<16|kTestMask16<<48>(data.data(),data.data()+data.size());
416
- test<THash_fadler64,uint64_t,32,kTestMask16|kTestMask16<<48>(data.data(),data.data()+data.size());
417
- printf("\n");
418
- //*/
419
- /*
420
- printf("NOTE: not enough time to get next test results ...\n");
421
- kMinClash=1;
422
- test_fadler128<kTestMask32,kTestMask32>(data.data(),data.data()+data.size());
423
- test_fadler128<kTestMask32,kTestMask32<<32>(data.data(),data.data()+data.size());
424
- test_fadler128<kTestMask32<<32,kTestMask32>(data.data(),data.data()+data.size());
425
- test_fadler128<kTestMask32<<32,kTestMask32<<32>(data.data(),data.data()+data.size());
426
- printf("\n");
427
- //*/
428
- //*
429
- printf("NOTE: not enough time to get next test results ...\n");
430
- kMinClash=1; // for timesaving but increase deviation
431
- test<THash_fadler64,uint64_t>(data.data(),data.data()+data.size());
432
- test<THash_md5_128,uint64_t>(data.data(),data.data()+data.size());
433
- //*/
434
- return 0;
435
- }
436
-