MCPcopy Create free account
hub / github.com/Scobalula/Greyhound / SpeedStorage_Test

Function SpeedStorage_Test

src/External/CascLib/test/CascTest.cpp:916–969  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

914}
915
916static 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
971static bool WINAPI OnlineStorage_OpenCB(
972 void * PtrUserParam, // User-specific parameter passed to the callback

Callers

nothing calls this directly

Calls 8

MakeFullPathFunction · 0.85
CascOpenStorageFunction · 0.85
CascCloseStorageFunction · 0.85
GetCascErrorFunction · 0.85
PrintProgressMethod · 0.80
SetStartTimeMethod · 0.80
PrintErrorMethod · 0.80
PrintTotalTimeMethod · 0.80

Tested by

no test coverage detected