-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from ktorio/bjhham/3.0.0
Improvements for allocation tests for 3.0.0
- Loading branch information
Showing
25 changed files
with
50,579 additions
and
9,723 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,17 @@ | ||
# ktor-benchmarks | ||
# Ktor Benchmarks | ||
|
||
This repository contains benchmark tests for various performance metrics. | ||
|
||
### Allocation Benchmark (/allocation-benchmark) | ||
|
||
Tests how much memory is allocated on a given request. This is done before every merge to ensure that the ktor server | ||
maintains a low memory profile by avoiding erroneous allocations. | ||
|
||
**Testing:** `ServerCallAllocationTest` runs through the supported engines and calculates the memory allocated per request. When a new baseline is required, | ||
you may run the `dumpAllocations` gradle target. | ||
|
||
**Inspection:** the allocation baseline dump is a series of JSON files. For easy reading of the values exported here, use the `reportServer` gradle target | ||
which has two pages for inspecting where memory is being allocated. `previewClasses.html` shows the largest memory consumers for types allocated, and | ||
`previewSites.html` shows the code sites that allocate the most memory. | ||
|
||
**TeamCity:** [https://ktor.teamcity.com/buildConfiguration/Ktor_AllocationTests](https://ktor.teamcity.com/buildConfiguration/Ktor_AllocationTests) |
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,53 @@ | ||
|
||
const formatSize = (size) => Math.round(size / 1024 / 1024 * 1000) / 1000 + "Mb" | ||
|
||
export function displaySite(sites, item) { | ||
const site = sites.append("div") | ||
.attr("class", "site") | ||
.attr("data-expand", "false") | ||
|
||
const stackTrace = item.stackTrace.split(", ") | ||
|
||
const siteElem = site.append("div") | ||
.attr("class", "header") | ||
siteElem.append("div").attr("class", "chevron") | ||
siteElem.append("span") | ||
.style("font-weight", "bold") | ||
.text(`${formatSize(item.totalSize)} (${item.totalCount})`) | ||
siteElem.append("span") | ||
.text(stackTrace[1].split(" ")[0]) | ||
siteElem.on("click", () => { | ||
site.attr("data-expand", site.attr("data-expand") === "false") | ||
}) | ||
|
||
const stack = site.append("ul") | ||
.attr("class", "stacktrace") | ||
.style("list-style-type", "none") | ||
|
||
stackTrace.forEach((stackItem) => { | ||
const li = stack.append("li") | ||
const [file, fun] = stackItem.split(" ") | ||
li.append("span").attr("class", "file").text(file) | ||
li.append("span").attr("class", "fun").text(fun) | ||
}) | ||
} | ||
|
||
export function setupRenderControls(drawAllocations) { | ||
const render = () => { | ||
const engineName = document.querySelector("input[name='engine']:checked").value | ||
const snapshotDir = document.querySelector("input[name='snapshot']:checked").value | ||
const reportPath = `${snapshotDir}/testMemoryConsumptionIsSame[${engineName}].json`; | ||
d3.json(reportPath).then(result => { | ||
drawAllocations(result.data) | ||
document.getElementById("info").innerText = "" | ||
}, () => { | ||
drawAllocations({}) | ||
document.getElementById("info").innerText = `Nothing found for ${reportPath}` | ||
}) | ||
} | ||
document.querySelectorAll("input[type='radio']").forEach(elem => { | ||
elem.onchange = render | ||
}) | ||
|
||
render() | ||
} |
Oops, something went wrong.