Nice3point.BenchmarkDotNet.Revit 2026.0.0

Prefix Reserved
dotnet add package Nice3point.BenchmarkDotNet.Revit --version 2026.0.0
                    
NuGet\Install-Package Nice3point.BenchmarkDotNet.Revit -Version 2026.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Nice3point.BenchmarkDotNet.Revit" Version="2026.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Nice3point.BenchmarkDotNet.Revit" Version="2026.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Nice3point.BenchmarkDotNet.Revit" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Nice3point.BenchmarkDotNet.Revit --version 2026.0.0
                    
#r "nuget: Nice3point.BenchmarkDotNet.Revit, 2026.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Nice3point.BenchmarkDotNet.Revit@2026.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Nice3point.BenchmarkDotNet.Revit&version=2026.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Nice3point.BenchmarkDotNet.Revit&version=2026.0.0
                    
Install as a Cake Tool

Benchmarking library for Revit

Nuget Downloads Last Commit

Write performance benchmarks for your Revit add-ins using the BenchmarkDotNet, and share reproducible measurement experiments.

Installation

You can install this library as a NuGet package.

The packages are compiled for specific versions of Revit. To support different versions of libraries in one project, use the RevitVersion property:

<PackageReference Include="Nice3point.BenchmarkDotNet.Revit" Version="$(RevitVersion).*"/>

Writing your first benchmark

Start by creating a new class inheriting from RevitApiBenchmark:

public class MyBenchmarks : RevitApiBenchmark
{

}

Add one or more methods marked with [Benchmark]:

using BenchmarkDotNet.Attributes;

public class MyBenchmarks : RevitApiBenchmark
{
    [Benchmark]
    public void MyBenchmark()
    {
        
    }
}

This is your runnable benchmark. The base class ensures the benchmark executes within Revit's single-threaded API context.

Running your benchmarks

You can run your benchmarks with a simple configuration. BenchmarkDotNet uses the Release configuration by default to run, which will cause a failure when running benchmarks for Revit, where API multi-versioning is required. In this case, use the WithCurrentConfiguration() extension for the Job, which will run the benchmark for your selected Solution configuration.

using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Running;
using Nice3point.BenchmarkDotNet.Revit;

var configuration = ManualConfig.Create()
    .AddJob(Job.Default.WithCurrentConfiguration());

BenchmarkRunner.Run<MyBenchmarks>(configuration);

You must have a licensed copy of Autodesk Revit installed on your machine to run benchmarks, with a version that matches the selected Solution configuration.

Application-level benchmarks

Benchmark Revit application‑level operations:

using BenchmarkDotNet.Attributes;

public class RevitApplicationBenchmarks : RevitApiBenchmark
{
    [Benchmark]
    public double Create_XYZ_Distance()
    {
        var point = Application.Create.NewXYZ(3, 4, 5);
        return point.DistanceTo(XYZ.Zero);
    }
}

Benchmarks using global hooks

BenchmarkDotNet provides [GlobalSetup] and [GlobalCleanup] hooks, but due to library limitations, it cannot be assigned twice. If you need these hooks in your benchmarks, for example to open the Document, use OnSetup/OnCleanup overrides instead:

using BenchmarkDotNet.Attributes;

public class RevitDocumentBenchmarks : RevitApiBenchmark
{
    private Document _documentFile = null!;

    protected sealed override void OnSetup()
    {
        _documentFile = Application.OpenDocumentFile($@"C:\Program Files\Autodesk\Revit {Application.VersionNumber}\Samples\rac_basic_sample_family.rfa");
    }
    
    protected sealed override void OnCleanup()
    {
        _documentFile.Close(false);
    }

    [Benchmark]
    public IList<Element> WhereElementIsElementTypeToElements()
    {
        return new FilteredElementCollector(_documentFile)
            .WhereElementIsElementType()
            .ToElements();
    }

    [Benchmark]
    public IList<Element> ElementIsElementTypeFilterToElements()
    {
        return new FilteredElementCollector(_documentFile)
            .WherePasses(new ElementIsElementTypeFilter())
            .ToElements();
    }

    [Benchmark]
    public List<Element> WhereElementIsElementTypeToList()
    {
        return new FilteredElementCollector(_documentFile)
            .WhereElementIsElementType()
            .ToList();
    }

    [Benchmark]
    public List<ElementType> WhereElementIsElementTypeCastToList()
    {
        return new FilteredElementCollector(_documentFile)
            .WhereElementIsElementType()
            .Cast<ElementType>()
            .ToList();
    }

    [Benchmark]
    public List<ElementType> WhereElementIsElementTypeOfTypeToList()
    {
        return new FilteredElementCollector(_documentFile)
            .WhereElementIsElementType()
            .OfType<ElementType>()
            .ToList();
    }
}

BenchmarkDotNet v0.15.8, Windows 11 (10.0.22631.6199/23H2/2023Update/SunValley3)
AMD Ryzen 5 5600 3.50GHz, 1 CPU, 12 logical and 6 physical cores
.NET SDK 10.0.100
  [Host]    : .NET 8.0.22 (8.0.22, 8.0.2225.52707), X64 RyuJIT x86-64-v3
  MediumRun : .NET 8.0.22 (8.0.22, 8.0.2225.52707), X64 RyuJIT x86-64-v3

Job=MediumRun  BuildConfiguration=Release.R26  IterationCount=15  
LaunchCount=2  WarmupCount=10  

Method Mean Error StdDev Allocated
WhereElementIsElementTypeToElements 122.0 μs 4.54 μs 6.80 μs 5.55 KB
ElementIsElementTypeFilterToElements 412.0 μs 7.52 μs 11.26 μs 5.71 KB
WhereElementIsElementTypeToList 122.1 μs 2.84 μs 4.17 μs 5.7 KB
WhereElementIsElementTypeCastToList 122.6 μs 2.41 μs 3.45 μs 5.76 KB
WhereElementIsElementTypeOfTypeToList 122.0 μs 2.19 μs 3.20 μs 5.76 KB
Product Compatible and additional computed target framework versions.
.NET net8.0-windows7.0 is compatible.  net9.0-windows was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2026.0.0 100 12/31/2025
2025.0.0 86 12/31/2025
2024.0.0 83 12/31/2025
2023.0.0 83 12/31/2025
2022.0.0 91 12/31/2025
2021.0.0 83 12/31/2025

Initial release. Enjoy!