Skip to content

Commit

Permalink
Don't upload benchmark result anymore to Azure (#2169)
Browse files Browse the repository at this point in the history
  • Loading branch information
nojaf authored Mar 29, 2022
1 parent fbd4b7f commit 8f2ab14
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 113 deletions.
48 changes: 2 additions & 46 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -294,52 +294,8 @@ Target.create "Benchmark" (fun _ ->
""
|> ignore

match Environment.environVarOrNone "TABLE_STORAGE_CONNECTION_STRING" with
| Some conn ->
let branchName = git "rev-parse --abbrev-ref HEAD"
let commit = git "rev-parse HEAD"
let operatingSystem = Environment.environVar "RUNNER_OS"

let results =
File.ReadLines("./BenchmarkDotNet.Artifacts/results/Fantomas.Benchmarks.Runners.CodePrinterTest-report.csv")
|> Seq.map (fun line -> line.Split(',') |> Array.toList)
|> Seq.toList
|> fun lineGroups ->
match lineGroups with
| [ header; values ] ->
let csvValues = List.zip header values

let metaData =
[ "Branch", branchName
"Commit", commit
"Operating System", operatingSystem ]

[ yield! csvValues; yield! metaData ]
| _ -> []

let storageAccount = CloudStorageAccount.Parse(conn)
let tableClient = storageAccount.CreateCloudTableClient()

let table = tableClient.GetTableReference("FantomasBenchmarks")

let entry = DynamicTableEntity()
entry.PartitionKey <- "GithubActions"

entry.RowKey <-
(sprintf "%s|%s|%s" branchName commit operatingSystem)
.ToLower()

results
|> List.iter (fun (k, v) ->
let key = k.Replace(' ', '_')

if not (isNull v) then
entry.Properties.Add(key, EntityProperty.CreateEntityPropertyFromObject(v)))

let tableOperation = TableOperation.InsertOrReplace(entry)

table.Execute(tableOperation) |> printfn "%O"
| None -> printfn "Not saving benchmark results to the cloud")
// TODO: the Azure storage account was removed, migrate this to a new solution.
)

Target.create "Format" (fun _ ->
let result =
Expand Down
68 changes: 1 addition & 67 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,78 +12,12 @@
<body>
<div class="jumbotron jumbotron-fluid mb-4">
<div class="container">
<h1 class="display-4">Fantomas Benchmark results</h1>
<p class="lead">A benchmark of CodePrinter.fs file</p>
<h1 class="display-4">Fantomas Benchmark results are unavailable</h1>
</div>
</div>
<div class="container mt-4">
<div id="mean"></div>
<div id="allocations"></div>
</div>
<script>
const sas = "sv=2019-10-10&ss=t&srt=sco&sp=r&se=2023-01-06T01:12:09Z&st=2020-06-12T16:12:09Z&spr=https&sig=HM4IEoODtjMScM9xKi7z0Jnob98uVCBa5MgYd4AE1aU%3D";
const apiUrl = `https://storfantomasmain.table.core.windows.net/FantomasBenchmarks()?$select=Mean,Operating_System,Allocated,Timestamp,StdDev,Commit&${sas}`;

const sortByTimestamp = (a, b) => {
const aDate = new Date(a.Timestamp);
const bDate = new Date(b.Timestamp);
return bDate - aDate;
}

function createCharts(values) {
const sortedValues = values.sort(sortByTimestamp);
const createTrace = (operationSystem, property) => {
const values = sortedValues.filter(v => v.Operating_System === operationSystem);
const x = values.map(v => v.Timestamp);
const y = values.map(v => parseFloat(v[property]));
return {
x,
y,
"type": "scatter",
name: operationSystem
}
};
const createLayout = (title) => {
return {
title,
xaxis: {
title: "Commit date on master"
},
yaxis: {
title
},
showLegend: true,
legend: {"orientation": "h"}
};
}

const createPlot = (property, title, nodeSelector) => {
const windows = createTrace("Windows", property);
const linux = createTrace("Linux", property);
const macOs = createTrace("macOS", property);
const node = document.querySelector(nodeSelector);
const layout = createLayout(title);
Plotly.newPlot(node, [windows, linux, macOs], layout);
}

createPlot("Mean", "Mean time in seconds", "#mean");
createPlot("Allocated", "Allocated in GB", "#allocations");
}

window.addEventListener("load", () => {
fetch(apiUrl, {
method: 'GET',
mode: 'cors',
headers: {
Accept: "application/json;odata=nometadata",
"Content-Type": "application/json"
}
})
.then(result => result.json())
.then(data => {
createCharts(data.value)
});
})
</script>
</body>
</html>

0 comments on commit 8f2ab14

Please sign in to comment.