-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Shift the responsibility of checking profile's size to the browser.
- Loading branch information
1 parent
760689b
commit 8e4bc94
Showing
2 changed files
with
25 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 14 additions & 7 deletions
21
src/mono/wasm/testassets/WasmBasicTestApp/App/wwwroot/profiler.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,35 @@ | ||
export function saveProfile(Module) { | ||
let profileData = readProfileFile(Module); | ||
const fileName = "output.mlpd"; | ||
let profileData = readProfileFile(Module, fileName); | ||
|
||
if (!profileData) { | ||
console.error("Profile data is empty or could not be read."); | ||
return; | ||
} | ||
|
||
const a = document.createElement('a'); | ||
const blob = new Blob([profileData]); | ||
a.href = URL.createObjectURL(blob); | ||
a.download = "output.mlpd"; | ||
a.download = fileName; | ||
// Append anchor to body. | ||
document.body.appendChild(a); | ||
a.click(); | ||
|
||
console.log(`TestOutput -> Profile data of size ${profileData.length} bytes started downloading.`); | ||
|
||
// Remove anchor from body | ||
document.body.removeChild(a); | ||
} | ||
|
||
function readProfileFile(Module) { | ||
let profileFilePath="output.mlpd"; | ||
function readProfileFile(Module, fileName) { | ||
|
||
var stat = Module.FS.stat(profileFilePath); | ||
var stat = Module.FS.stat(fileName); | ||
|
||
if (stat && stat.size > 0) { | ||
return Module.FS.readFile(profileFilePath); | ||
return Module.FS.readFile(fileName); | ||
} | ||
else { | ||
console.debug(`Unable to fetch the profile file ${profileFilePath} as it is empty`); | ||
console.debug(`Unable to fetch the profile file ${fileName} as it is empty`); | ||
return null; | ||
} | ||
} |