Skip to content

Instantly share code, notes, and snippets.

@EatonZ
Created January 9, 2023 16:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EatonZ/4d6003a94886c104e28cc6fd593c9274 to your computer and use it in GitHub Desktop.
Save EatonZ/4d6003a94886c104e28cc6fd593c9274 to your computer and use it in GitHub Desktop.
Benchmark code for testing Xbox 360 dash.xex loading speeds.
//https://eaton-works.com/2023/01/09/how-microsoft-attempted-to-make-the-xbox-360-dashboard-load-faster/
DbgPrint("[Benchmark] Benchmark begin.\n");
//Use a 1 MB buffer. This results in the best performance for both devices.
DWORD readBufferSize = 1048576;
//FLASH symbolically linked to: \\Device\\Flash
HANDLE hFlash = CreateFile("FLASH:\\dash.xex", GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
//HDDSYSEXT symbolically linked to: \\Device\\Harddisk0\\SystemExtPartition
HANDLE hExt = CreateFile("HDDSYSEXT:\\20449700\\dash.xex", GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFlash == INVALID_HANDLE_VALUE || hExt == INVALID_HANDLE_VALUE)
{
DbgPrint("[Benchmark] A CreateFile failed with error %d.\n", GetLastError());
return;
}
LARGE_INTEGER flashDashSize;
LARGE_INTEGER extDashSize;
if (!GetFileSizeEx(hFlash, &flashDashSize) || !GetFileSizeEx(hExt, &extDashSize))
{
DbgPrint("[Benchmark] A GetFileSizeEx failed with error %d.\n", GetLastError());
return;
}
PVOID readBuffer = malloc(readBufferSize);
if (readBuffer == NULL)
{
DbgPrint("[Benchmark] No memory available for read buffer.\n");
return;
}
LARGE_INTEGER counterFreq;
LARGE_INTEGER counterStart;
LARGE_INTEGER counterEnd;
//Let's be fancy and use these APIs. Note that using GetTickCount also produces the same end results.
QueryPerformanceFrequency(&counterFreq);
QueryPerformanceCounter(&counterStart);
DWORD numRead;
while (flashDashSize.QuadPart > 0)
{
if (!ReadFile(hFlash, readBuffer, readBufferSize, &numRead, NULL))
{
DbgPrint("[Benchmark] ReadFile (flash) failed with error %d.\n", GetLastError());
return;
}
flashDashSize.QuadPart -= numRead;
}
QueryPerformanceCounter(&counterEnd);
DWORD flashTimeMs = ((counterEnd.QuadPart - counterStart.QuadPart) * 1000) / counterFreq.QuadPart;
QueryPerformanceCounter(&counterStart);
while (extDashSize.QuadPart > 0)
{
if (!ReadFile(hExt, readBuffer, readBufferSize, &numRead, NULL))
{
DbgPrint("[Benchmark] ReadFile (ext) failed with error %d.\n", GetLastError());
return;
}
extDashSize.QuadPart -= numRead;
}
QueryPerformanceCounter(&counterEnd);
DWORD extTimeMs = ((counterEnd.QuadPart - counterStart.QuadPart) * 1000) / counterFreq.QuadPart;
DbgPrint("[Benchmark] Benchmark concluded. Results with buffer size of %d: Nand=%dms, HDD=%dms\n", readBufferSize, flashTimeMs, extTimeMs);
return;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment