Skip to content

Commit 8a09cea

Browse files
committed
Improvements for 3.0.0
1 parent 5ea4e2c commit 8a09cea

21 files changed

+35396
-17099
lines changed

README.md

+17-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,17 @@
1-
# ktor-benchmarks
1+
# Ktor Benchmarks
2+
3+
This repository contains benchmark tests for various performance metrics.
4+
5+
### Allocation Benchmark (/allocation-benchmark)
6+
7+
Tests how much memory is allocated on a given request. This is done before every merge to ensure that the ktor server
8+
maintains a low memory profile by avoiding erroneous allocations.
9+
10+
**Testing:** `ServerCallAllocationTest` runs through the supported engines and calculates the memory allocated per request. When a new baseline is required,
11+
you may run the `dumpAllocations` gradle target.
12+
13+
**Inspection:** the allocation baseline dump is a series of JSON files. For easy reading of the values exported here, use the `reportServer` gradle target
14+
which has two pages for inspecting where memory is being allocated. `previewClasses.html` shows the largest memory consumers for types allocated, and
15+
`previewSites.html` shows the code sites that allocate the most memory.
16+
17+
**TeamCity:** [https://ktor.teamcity.com/buildConfiguration/Ktor_AllocationTests](https://ktor.teamcity.com/buildConfiguration/Ktor_AllocationTests)
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
2+
const formatSize = (size) => Math.round(size / 1024 / 1024 * 1000) / 1000 + "Mb"
3+
4+
export function displaySite(sites, item) {
5+
const site = sites.append("div")
6+
.attr("class", "site")
7+
.attr("data-expand", "false")
8+
9+
const stackTrace = item.stackTrace.split(", ")
10+
11+
const siteElem = site.append("div")
12+
.attr("class", "header")
13+
siteElem.append("div").attr("class", "chevron")
14+
siteElem.append("span")
15+
.style("font-weight", "bold")
16+
.text(`${formatSize(item.totalSize)} (${item.totalCount})`)
17+
siteElem.append("span")
18+
.text(stackTrace[1].split(" ")[0])
19+
siteElem.on("click", () => {
20+
site.attr("data-expand", site.attr("data-expand") === "false")
21+
})
22+
23+
const stack = site.append("ul")
24+
.attr("class", "stacktrace")
25+
.style("list-style-type", "none")
26+
27+
stackTrace.forEach((stackItem) => {
28+
const li = stack.append("li")
29+
const [file, fun] = stackItem.split(" ")
30+
li.append("span").attr("class", "file").text(file)
31+
li.append("span").attr("class", "fun").text(fun)
32+
})
33+
}

0 commit comments

Comments
 (0)