Nice3point.BenchmarkDotNet.Revit 2027.0.0

Prefix Reserved
dotnet add package Nice3point.BenchmarkDotNet.Revit --version 2027.0.0
                    
NuGet\Install-Package Nice3point.BenchmarkDotNet.Revit -Version 2027.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="2027.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="2027.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 2027.0.0
                    
#r "nuget: Nice3point.BenchmarkDotNet.Revit, 2027.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@2027.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=2027.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Nice3point.BenchmarkDotNet.Revit&version=2027.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 XYZ NewXyz()
    {
        return new XYZ(3, 4, 5);
    }

    [Benchmark]
    public XYZ CreateNewXyz()
    {
        return Application.Create.NewXYZ(3, 4, 5);
    }
}

Document benchmarks

Use OnGlobalSetup and OnGlobalCleanup overrides to open and close a document around benchmark iterations. BenchmarkDotNet provides [GlobalSetup] and [GlobalCleanup] hooks, but due to library limitations, they cannot be assigned twice:

using BenchmarkDotNet.Attributes;

public class RevitCollectorBenchmarks : RevitApiBenchmark
{
    private Document _document = null!;

    protected sealed override void OnGlobalSetup()
    {
        _document = Application.NewProjectDocument(UnitSystem.Metric);
    }

    protected sealed override void OnGlobalCleanup()
    {
        _document.Close(false);
    }

    [Benchmark]
    public IList<Element> WhereElementIsNotElementTypeToElements()
    {
        return new FilteredElementCollector(_document)
            .WhereElementIsNotElementType()
            .ToElements();
    }

    [Benchmark]
    public List<Element> WhereElementIsNotElementTypeToList()
    {
        return new FilteredElementCollector(_document)
            .WhereElementIsNotElementType()
            .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
WhereElementIsNotElementTypeToElements 2.203 ms 0.0494 ms 0.1440 ms 295.05 KB
WhereElementIsNotElementTypeToList 2.190 ms 0.0436 ms 0.0929 ms 310.09 KB

Benchmark configuration

BenchmarkDotNet initializes Revit with the English - United States language and the C:\Program Files\Autodesk\Revit {version} installation path. To override these defaults, use assembly-level attributes:

  • Add the attributes to any .cs file in your project (e.g., Program.cs):

    using Nice3point.Revit.Injector.Attributes;
    
    [assembly: RevitLanguage("ENU")]
    [assembly: RevitInstallationPath("D:\Autodesk\Revit Preview")]
    
  • Add the attributes directly to your .csproj file:

    
    <ItemGroup>
    
        <AssemblyAttribute Include="Nice3point.Revit.Injector.Attributes.RevitLanguageAttribute">
            <_Parameter1>ENU</_Parameter1>
        </AssemblyAttribute>
    
        <AssemblyAttribute Include="Nice3point.Revit.Injector.Attributes.RevitInstallationPathAttribute">
            <_Parameter1>D:\Autodesk\Revit $(RevitVersion)</_Parameter1>
        </AssemblyAttribute>
    
    </ItemGroup>
    

The RevitLanguage attribute accepts a language name (e.g., "English - United States"), code (e.g., "ENU") or LanguageType enum value (e.g., "English_GB" or "15").

Product Compatible and additional computed target framework versions.
.NET net10.0-windows7.0 is compatible. 
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
2027.0.0 39 4/7/2026
2027.0.0-preview.3.20260322 44 3/22/2026
2027.0.0-preview.2.20260203 62 2/3/2026
2026.1.0 28 4/7/2026
2026.1.0-preview.3.20260322 42 3/22/2026
2026.1.0-preview.2.20260203 55 2/3/2026
2025.1.0 37 4/7/2026
2025.1.0-preview.3.20260322 38 3/22/2026
2025.1.0-preview.2.20260203 53 2/3/2026
2024.1.0 29 4/7/2026
2024.1.0-preview.3.20260322 39 3/22/2026
2024.1.0-preview.2.20260203 55 2/3/2026
2023.1.0 31 4/7/2026
2023.1.0-preview.3.20260322 36 3/22/2026
2023.1.0-preview.2.20260203 53 2/3/2026
2022.1.0 28 4/7/2026
2022.1.0-preview.3.20260322 37 3/22/2026
2022.1.0-preview.2.20260203 54 2/3/2026
2021.1.0 31 4/7/2026
2021.1.0-preview.3.20260322 43 3/22/2026
Loading failed

This release adds support for Revit 2027, benchmarking for different languages and custom Revit installation path.

Localization support

BenchmarkDotNet initializes Revit with the English • United States language. To override these defaults, use assembly-level attributes:

• Add the attributes to any .cs file in your project (e.g., Program.cs):

   using Nice3point.Revit.Injector.Attributes;
   
   [assembly: RevitLanguage(ENU)]

• Add the attributes directly to your .csproj file:

   <!-• Revit Environment Configuration -->
   <ItemGroup>
       <AssemblyAttribute Include=Nice3point.Revit.Injector.Attributes.RevitLanguageAttribute>
           <_Parameter1>ENU</_Parameter1>
       </AssemblyAttribute>
   </ItemGroup>

The RevitLanguage attribute accepts a [language](https://help.autodesk.com/view/RVT/2026/ENU/?guid=GUID-BD09C1B4-5520-475D-BE7E-773642EEBD6C) name (e.g., English • United States), code (e.g., ENU)
or [LanguageType](https://www.revitapidocs.com/2026/dfda33cf-cbff-9fde-6672-38402e87510f.htm) enum value (e.g., English_GB or 15).

Custom Revit installation path

TUnit initializes Revit from C:\Program Files\Autodesk\Revit {version} installation path. To override these defaults, use assembly-level attributes:

• Add the attributes to any .cs file in your project (e.g., Program.cs):

   using Nice3point.Revit.Injector.Attributes;
   
   [assembly: RevitInstallationPath(D:\Autodesk\Revit Preview)]

• Add the attributes directly to your .csproj file:

   <!-• Revit Environment Configuration -->
   <ItemGroup>
       <AssemblyAttribute Include=Nice3point.Revit.Injector.Attributes.RevitInstallationPathAttribute>
           <_Parameter1>D:\Autodesk\Revit $(RevitVersion)</_Parameter1>
       </AssemblyAttribute>
   </ItemGroup>

Breaking changes

• Global hooks OnSetup/OnCleanup renamed to OnGlobalSetup/OnGlobalCleanup