forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[browser] bench - separate scripts for memory snapshot (dotnet#93548)
- Loading branch information
1 parent
cccdc1d
commit a30d6c9
Showing
12 changed files
with
137 additions
and
23 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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> | ||
<title>blazor</title> | ||
<base href="./" /> | ||
<link rel="stylesheet" href="css/bootstrap/bootstrap.min.css" /> | ||
<link rel="stylesheet" href="css/bootstrap-icons/bootstrap-icons.min.css" /> | ||
<link rel="stylesheet" href="css/app.css" /> | ||
<link rel="icon" type="image/png" href="favicon.png" /> | ||
<link href="blazor.styles.css" rel="stylesheet" /> | ||
</head> | ||
|
||
<body> | ||
<div id="app"> | ||
<svg class="loading-progress"> | ||
<circle r="40%" cx="50%" cy="50%" /> | ||
<circle r="40%" cx="50%" cy="50%" /> | ||
</svg> | ||
<div class="loading-progress-text"></div> | ||
</div> | ||
|
||
<div id="blazor-error-ui"> | ||
An unhandled error has occurred. | ||
<a href="" class="reload">Reload</a> | ||
<a class="dismiss">🗙</a> | ||
</div> | ||
<script type="module" src="./_framework/blazor.webassembly.js" autostart="false"></script> | ||
<script type="module" src="./start.js"></script> | ||
</body> | ||
|
||
</html> |
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
"use strict"; | ||
|
||
class FrameApp { | ||
reachedCallback() { | ||
if (window.parent != window) { | ||
window.parent.resolveAppStartEvent("reached"); | ||
} | ||
} | ||
} | ||
|
||
let mute = false; | ||
try { | ||
globalThis.frameApp = new FrameApp(); | ||
globalThis.frameApp.ReachedCallback = globalThis.frameApp.reachedCallback.bind(globalThis.frameApp); | ||
if (window.parent != window) { | ||
window.addEventListener("pageshow", event => { window.parent.resolveAppStartEvent("pageshow"); }) | ||
} | ||
|
||
// receive blazor benchmark event and forward it to resolveAppStartEvent | ||
window.receiveBenchmarkEvent = function (name) { | ||
if (window !== window.parent) { | ||
window.parent.resolveAppStartEvent("blazor: " + name); | ||
} | ||
}; | ||
|
||
window.muteErrors = () => { | ||
mute = true; | ||
} | ||
|
||
const urlParams = new URLSearchParams(window.location.search); | ||
const myParam = urlParams.get('memorySnapshot'); | ||
|
||
Blazor.start({ | ||
configureRuntime: dotnet => { | ||
if (myParam === "true") { | ||
dotnet.withStartupMemoryCache(true); | ||
} | ||
} | ||
}); | ||
|
||
} | ||
catch (err) { | ||
if (!mute) { | ||
console.error(`WASM ERROR ${err}`); | ||
} | ||
} |
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
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
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<!DOCTYPE html> | ||
<!-- Licensed to the .NET Foundation under one or more agreements. --> | ||
<!-- The .NET Foundation licenses this file to you under the MIT license. --> | ||
<html> | ||
|
||
<head> | ||
<title>browser-frame</title> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<script type='module' src="./start.js"></script> | ||
<script type="module" src="./frame.js"></script> | ||
</head> | ||
|
||
<body> | ||
<span id="out"></span> | ||
</body> | ||
|
||
</html> |
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
import { dotnet } from './_framework/dotnet.js' | ||
|
||
const urlParams = new URLSearchParams(window.location.search); | ||
const myParam = urlParams.get('memorySnapshot'); | ||
|
||
const { setModuleImports, getAssemblyExports, getConfig } = await dotnet | ||
.withDiagnosticTracing(false) | ||
.withStartupMemoryCache(myParam === "true") | ||
.withApplicationArgumentsFromQuery() | ||
.create(); | ||
|
||
setModuleImports('main.js', { | ||
window: { | ||
location: { | ||
href: () => globalThis.window.location.href | ||
} | ||
} | ||
}); | ||
|
||
const config = getConfig(); | ||
const exports = await getAssemblyExports(config.mainAssemblyName); | ||
const text = exports.MyClass.Greeting(); | ||
console.log(text); | ||
|
||
document.getElementById('out').innerHTML = text; | ||
await dotnet.run(); |
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
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