Skip to content

Commit

Permalink
[wasm] Add bench output log, to the file and to the console (dotnet#1…
Browse files Browse the repository at this point in the history
…10669)

This improves diagnostic in our measurement infra
  • Loading branch information
radekdoulik authored and hez2010 committed Dec 14, 2024
1 parent cb8d141 commit a4ca48f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
10 changes: 7 additions & 3 deletions src/mono/sample/wasm/browser-bench/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class MainApp {
setExclusions(exclusions.join(','));
}

const r = await fetch("/bootstrap.flag", {
const r = await fetch("/rewrite=bootstrap.flag", {
method: 'POST',
body: "ok"
});
Expand All @@ -96,15 +96,19 @@ class MainApp {
if (resultString.length == 0) break;
document.getElementById("out").innerHTML += resultString;
console.log(resultString);
await fetch("/log=bench-log.txt", {
method: 'POST',
body: resultString
});
}

document.getElementById("out").innerHTML += "Finished";
const r1 = await fetch("/results.json", {
const r1 = await fetch("/rewrite=results.json", {
method: 'POST',
body: getFullJsonResults()
});
console.log("post request complete, response: ", r1);
const r2 = await fetch("/results.html", {
const r2 = await fetch("/rewrite=results.html", {
method: 'POST',
body: document.getElementById("out").innerHTML
});
Expand Down
25 changes: 23 additions & 2 deletions src/mono/sample/wasm/simple-server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,32 @@ private async void ReceivePostAsync(HttpListenerContext context)
if (contentType != null && contentType.StartsWith("text/plain") && path.StartsWith("/"))
{
path = path.Substring(1);
var split = path.Split('=');
string cmd;
if (split.Length > 1)
{
cmd = split[0];
path = split[1];
} else
cmd = "rewrite";

if (Verbose)
Console.WriteLine($" writting POST stream to '{path}' file");
Console.WriteLine($" POST cmd: {cmd} path: '{path}'");

var content = await new StreamReader(context.Request.InputStream).ReadToEndAsync().ConfigureAwait(false);
await File.WriteAllTextAsync(path, content).ConfigureAwait(false);

switch (cmd) {
case "rewrite":
await File.WriteAllTextAsync(path, content).ConfigureAwait(false);
break;
case "log":
await File.AppendAllTextAsync(path, content + "\n").ConfigureAwait(false);
Console.WriteLine($" log: {content}");
break;
default:
Console.WriteLine($" unknown command: {cmd}");
break;
}
}
else
return;
Expand Down

0 comments on commit a4ca48f

Please sign in to comment.