Skip to main content

Benchmarks

These benchmarks compare Testably.Abstractions with System.IO.Abstractions for the same calls. The mock file system of Testably.Abstractions models more of the real behavior, such as file locks, timestamps and the rules of each operating system, so some of its extra time is the cost of behaving like the real file system.

A complete unit test: seed a small project, let the code under test read its configuration, write the sources into one output file, back it up and delete a source, then check the result. Both libraries run the same calls.

27.42 µswith Testably.Abstractions

System.IO.Abstractions takes 2.6× as long.

TimeMemory
Testably.Abstractions27.42 µs39.90 KiB
System.IO.Abstractions23.0.070.94 µs2.6×System.IO.Abstractions compared to Testably.Abstractions over the last 16 runs; the dashed line marks equal time166.70 KiB4.2×

Lower is better. Bars longer than four times the fastest library are cut so the others stay comparable. The line after each time shows the last runs compared to Testably.Abstractions. Hover a bar, a multiple or a line for the exact comparison.

Measured on 2026-11-29 at commit f3c60397BenchmarkDotNet MediumRun (in-process)ubuntu-latest
MockFileSystem fileSystem = new();
fileSystem.Directory.CreateDirectory("project/src");
fileSystem.File.WriteAllText("project/config.json", "{\"output\":\"out/bundle.txt\"}");
for (int i = 0; i < 5; i++)
{
fileSystem.File.WriteAllText($"project/src/file{i}.cs", $"class C{i} {{ }}");
}

string config = fileSystem.File.ReadAllText("project/config.json");
fileSystem.Directory.CreateDirectory("project/out");
using (StreamWriter writer = fileSystem.File.CreateText("project/out/bundle.txt"))
{
foreach (string file in fileSystem.Directory.EnumerateFiles("project/src", "*.cs"))
{
writer.WriteLine(fileSystem.File.ReadAllText(file));
}
}

fileSystem.File.Copy("project/out/bundle.txt", "project/out/bundle.bak");
fileSystem.File.Delete("project/src/file0.cs");

View source on GitHub

How these numbers are measured
  • Suite: Testably.Abstractions.Benchmarks driven by BenchmarkDotNet.
  • Job: MediumRun with the in-process toolchain on .NET 10.
  • Runner: ubuntu-latest GitHub Actions agent, refreshed on every push to main.
  • Parameters: the initialization benchmark runs with 10 and 100 files, the read and write benchmark with 1 KB and 64 KB of text, and the enumeration benchmark with 10 and 1,000 files and with the patterns * and *.txt; each value can be selected in the chart.
  • Charts: every multiple is relative to Testably.Abstractions, and bars longer than four times the fastest library are cut so the others stay comparable. Lower is better.