| 914 | } |
| 915 | |
| 916 | static DWORD SpeedStorage_Test(PFN_RUN_TEST PfnRunTest, LPCSTR szStorage, LPCSTR szExpectedNameHash = NULL, LPCSTR szExpectedDataHash = NULL, LPCSTR szFileName = NULL) |
| 917 | { |
| 918 | TLogHelper LogHelper(szStorage); |
| 919 | HANDLE hStorage; |
| 920 | TCHAR szFullPath[MAX_PATH]; |
| 921 | DWORD dwErrCode = ERROR_SUCCESS; |
| 922 | int nOpenCount = 100; |
| 923 | |
| 924 | // Keep compiler happy |
| 925 | CASCLIB_UNUSED(PfnRunTest); |
| 926 | CASCLIB_UNUSED(szExpectedNameHash); |
| 927 | CASCLIB_UNUSED(szExpectedDataHash); |
| 928 | CASCLIB_UNUSED(szFileName); |
| 929 | |
| 930 | // Prepare the full path of the storage |
| 931 | MakeFullPath(szFullPath, _countof(szFullPath), szStorage); |
| 932 | |
| 933 | // Open the storage for the first time to load all files to the cache |
| 934 | LogHelper.PrintProgress("Opening storage (caching-in) ..."); |
| 935 | if(CascOpenStorage(szFullPath, 0, &hStorage)) |
| 936 | { |
| 937 | // Close right away |
| 938 | CascCloseStorage(hStorage); |
| 939 | hStorage = NULL; |
| 940 | |
| 941 | // Set the start time of the operation |
| 942 | LogHelper.SetStartTime(); |
| 943 | |
| 944 | // Now open the storage again, many times in order to measure how fast can we load it |
| 945 | for(int i = 0; i < nOpenCount; i++) |
| 946 | { |
| 947 | LogHelper.PrintProgress("Opening storage (%u /%u) ...", i, nOpenCount); |
| 948 | if(!CascOpenStorage(szFullPath, 0, &hStorage)) |
| 949 | { |
| 950 | LogHelper.PrintError("Error: Failed to open storage %s", szStorage); |
| 951 | break; |
| 952 | } |
| 953 | |
| 954 | CascCloseStorage(hStorage); |
| 955 | hStorage = NULL; |
| 956 | } |
| 957 | |
| 958 | // Print the total time |
| 959 | LogHelper.PrintTotalTime(); |
| 960 | } |
| 961 | else |
| 962 | { |
| 963 | LogHelper.PrintError("Error: Failed to open storage %s", szStorage); |
| 964 | assert(GetCascError() != ERROR_SUCCESS); |
| 965 | dwErrCode = GetCascError(); |
| 966 | } |
| 967 | |
| 968 | return dwErrCode; |
| 969 | } |
| 970 | |
| 971 | static bool WINAPI OnlineStorage_OpenCB( |
| 972 | void * PtrUserParam, // User-specific parameter passed to the callback |
nothing calls this directly
no test coverage detected