Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
47 lines (34 loc) · 2 KB

File metadata and controls

47 lines (34 loc) · 2 KB
Copy raw file
Download raw file
Outline
Edit and raw actions

TSTL Benchmarks

These benchmarks are written in typescript and transpiled to lua by using tstl.

Memory benchmarks

To add a new benchmark add a new file to memory_benchmarks and default export a function with the following type: () => void. To prevent the benchmark from reporting "useful" results of your benchmark function as garbage, simply return the result. The memory used by the returned result won't count towards the total garbage amount.

For example (memory_benchmarks/my_benchmark.ts):

export default function myBenchmark() {
  const n = 123;
  const result = [];
  for (let i = 0; i < n; i++) {
    // Do something memory instensive
  }
  return result; // Return results so they wont be counted as garbage
}

Goal

The goal of memory benchmarks is to track how much (memory) "garbage" is created by tstl. For that reason garbage collection is disabled in the benchmarks.

You can force the creation of "garbage" by creating a lot of anonymous functions or temporary tables (see lua-users.org for more information).

To avoid crashes in the CI your benchmark should not use more than 500MB of memory.

Runtime benchmarks

To add a new runtime benchmark (execution time), add a new file to runtime_benchmarks and default export a function with the following type: () => void.

Running locally

  1. Create a benchmark baseline called "benchmark_baseline.json": tstl -p tsconfig.53.json && cd dist && lua -- run.lua benchmark_baseline.json
  2. Make some changes to tstl.
  3. Create an updated benchmark and compare with the baseline: tstl -p tsconfig.53.json && cd dist && lua -- run.lua benchmark_updated.json benchmark_baseline.json
  4. The above command will output comparison data as json to stdout. If you provide a path as third argument the comparison data will be written to that path instead. tstl -p tsconfig.53.json && cd dist && lua -- run.lua benchmark_updated.json benchmark_baseline.json result.md
Morty Proxy This is a proxified and sanitized view of the page, visit original site.