KScript docs
EN

Timings

Reading the summary

Phases

Every run goes through the same steps, and the first table shows each one:

Phase What it is
start kscript From starting the kscript program to its first line of work: .NET starting up and loading kscript.
native types Setting up the built-in types such as email, url and money, once per run.
packages Loading a package the script uses, such as KScript.Data, once per package.
read Reading a script's file from disk.
parse Turning a script's text into its structure.
imports Bringing in what the script imports, including reading, parsing and checking each imported script.
check Checking the script for mistakes before any of it runs.
run Running the script.
analyse, lint What kscript check does to each file: its analysis, then its lint rules.

Times is how many times the step happened: a script that imports two others reads three files. Share is the step's part of the whole time. Because imports holds the reading, parsing and checking of the scripts it brings in, the shares can add up to more than 100%.

Calls

The second table lists what took the most time of its own, so the top row is where time was really spent. Each row is one of these kinds:

Kind What it counts
function A function written in KScript, such as fn fib(n: int), with the file and line it was declared on. A type's methods and extension methods count here too.
lambda A short function such as fn(word) => $word->count() > 3, with where it was written.
method A built-in method, such as string->split or list->filter.
command A built-in command, such as @read_file or @max.
element A built-in statement, such as echo or expect. statements is a .kscript file's plain lines of assignments and calls.
test One test, in kscript test.
file One file, in kscript check.
request One request, in kscript serve.

The columns say:

  • Calls: how many times it ran.
  • Total: the time from its start to its end, calls it made included. When a function calls itself, only the outermost call counts, so the time isn't counted twice.
  • Own: Total without the time spent in the calls it made. In the example, list->filter took 14.7 ms in all, but 8.57 ms of that was the lambda it called, so its own time is 6.01 ms.
  • Average: Total divided by Calls.
  • Longest: the single slowest run of it.

The first time anything runs, .NET compiles it, so a first call is often much slower than the rest. When something runs many times, look at Average as well as Longest.

Slowest single calls

The last table lists the slowest single calls, tests, files or requests, longest first, with when each started (At, counted from the start of kscript). It finds the one slow call among many fast ones, such as the one request that waited on a database.