在好例子网,分享、交流、成长!
您当前所在位置:首页Others 开发实例一般编程问题 → NBench:.NET应用的跨平台性能基准测试框架

NBench:.NET应用的跨平台性能基准测试框架

一般编程问题

下载此实例
  • 开发语言:Others
  • 实例大小:0.29M
  • 下载次数:0
  • 浏览次数:7
  • 发布时间:2024-04-08
  • 实例类别:一般编程问题
  • 发 布 人:chenxiaolan
  • 文件格式:.zip
  • 所需积分:2
 相关标签:

实例介绍

【实例简介】
NBench是一个专为.NET开发者设计的性能基准测试和测试框架,它允许开发者像使用XUnit或NUnit测试应用代码一样,对他们的应用性能进行“单元测试”。这个框架支持跨平台使用,意味着无论是在Windows还是其他操作系统上,开发者都可以利用NBench来确保他们的应用达到最佳性能。
NBench的主要特点包括但不限于:轻松集成到现有的.NET项目中、提供详尽的性能测试指标以及简洁明了的测试结果输出。通过使用NBench,开发者能够及早发现性能瓶颈,从而在产品发布前做出必要的优化。
// 示例代码
// 使用NBench进行性能测试示例
[TestFixture]
public class MyPerformanceTests {
    [PerfBenchmark(Description = "测试我的应用性能",
                   NumberOfIterations = 3,
                   RunMode = RunMode.Throughput,
                   TestMode = TestMode.Test)]
    [MemoryAssertion(MemoryMetric.TotalBytesAllocated, MustBe.LessThanOrEqualTo, ByteConstants.ThirtyTwoKb)]
    public void BenchmarkMethod() {
        // 这里添加测试代码
    }
}
【实例截图】
【核心代码】
文件清单
└── NBench-a90aac33496e41cfdf466f911eb23c74e0c12a70
    ├── appsettings.json
    ├── benchmarks
    │   └── NBench.Microbenchmarks
    │       ├── App.config
    │       ├── NBench.Microbenchmarks.csproj
    │       ├── Program.cs
    │       ├── Properties
    │       │   └── AssemblyInfo.cs
    │       ├── SDK
    │       │   ├── Sdk_ActionBenchmarkInvoker.cs
    │       │   ├── Sdk_ReflectionBenchmarkInvoker.cs
    │       │   └── Sdk_ReflectionBenchmarkInvokerWithRealWork.cs
    │       └── Util
    │           └── Util_AtomicCounters.cs
    ├── build.cmd
    ├── build.fsx
    ├── build.ps1
    ├── build.sh
    ├── build-system
    │   ├── azure-pipeline.template.yaml
    │   ├── pr-validation.yaml
    │   ├── README.md
    │   └── windows-release.yaml
    ├── contributing.md
    ├── docs
    │   ├── api
    │   │   └── index.md
    │   ├── articles
    │   │   ├── benchmarks.md
    │   │   ├── index.md
    │   │   ├── measurements.md
    │   │   ├── quickstart.md
    │   │   ├── running.md
    │   │   └── toc.yml
    │   ├── docfx.json
    │   ├── images
    │   │   ├── install
    │   │   │   └── create-project.png
    │   │   ├── NBench_icon.png
    │   │   ├── NBench_logo_large.png
    │   │   ├── NBench_logo_square_140.png
    │   │   ├── NBench_logo_square_280.png
    │   │   └── NBench_logo_square_90.png
    │   ├── index.md
    │   ├── toc.yml
    │   └── web.config
    ├── images
    │   ├── NBench_logo_large.png
    │   ├── NBench_logo_square_140.png
    │   ├── NBench_logo_square_280.png
    │   └── NBench_logo_square_90.png
    ├── LICENSE
    ├── NBench.sln
    ├── README.md
    ├── RELEASE_NOTES.md
    ├── serve-docs.cmd
    ├── serve-docs.ps1
    ├── src
    │   ├── common.props
    │   ├── NBench
    │   │   ├── BenchmarkContext.cs
    │   │   ├── ByteConstants.cs
    │   │   ├── Collection
    │   │   │   ├── Counters
    │   │   │   │   ├── CounterMetricCollector.cs
    │   │   │   │   └── CounterSelector.cs
    │   │   │   ├── GarbageCollection
    │   │   │   │   ├── GcCollectionsPerGenerationCollector.cs
    │   │   │   │   └── GcCollectionsSelector.cs
    │   │   │   ├── Memory
    │   │   │   │   ├── GcTotalMemoryCollector.cs
    │   │   │   │   └── TotalMemorySelector.cs
    │   │   │   ├── MetricCollector.cs
    │   │   │   ├── MetricNames.cs
    │   │   │   ├── MetricsCollectorSelector.cs
    │   │   │   └── Timing
    │   │   │       ├── TimingCollector.cs
    │   │   │       └── TimingSelector.cs
    │   │   ├── CommandLine.cs
    │   │   ├── Counter.cs
    │   │   ├── CounterMeasurementAttribute.cs
    │   │   ├── GcMeasurementAttribute.cs
    │   │   ├── IBenchmarkTrace.cs
    │   │   ├── MeasurementAttribute.cs
    │   │   ├── MemoryMeasurementAttribute.cs
    │   │   ├── Metrics
    │   │   │   ├── BenchmarkRun.cs
    │   │   │   ├── Counters
    │   │   │   │   ├── CounterBenchmarkSetting.cs
    │   │   │   │   ├── CounterMeasurementConfigurator.cs
    │   │   │   │   ├── CounterMetricName.cs
    │   │   │   │   └── CreateCounterBenchmarkSetting.cs
    │   │   │   ├── GarbageCollection
    │   │   │   │   ├── GcBenchmarkSetting.cs
    │   │   │   │   ├── GcMeasurementConfigurator.cs
    │   │   │   │   └── GcMetricName.cs
    │   │   │   ├── MeasureBucket.cs
    │   │   │   ├── Memory
    │   │   │   │   ├── MemoryBenchmarkSetting.cs
    │   │   │   │   ├── MemoryMeasurementConfigurator.cs
    │   │   │   │   └── MemoryMetricName.cs
    │   │   │   ├── MetricMeasurement.cs
    │   │   │   ├── MetricName.cs
    │   │   │   └── Timing
    │   │   │       ├── TimingBenchmarkSetting.cs
    │   │   │       ├── TimingMeasurementConfigurator.cs
    │   │   │       └── TimingMetricName.cs
    │   │   ├── MustBe.cs
    │   │   ├── NBench.csproj
    │   │   ├── NBenchException.cs
    │   │   ├── NBenchRunner.cs
    │   │   ├── PerformanceBenchmark.cs
    │   │   ├── Properties
    │   │   │   └── Friends.cs
    │   │   ├── Reporting
    │   │   │   ├── AggregateMetrics.cs
    │   │   │   ├── BenchmarkFinalResults.cs
    │   │   │   ├── BenchmarkResults.cs
    │   │   │   ├── BenchmarkRunReport.cs
    │   │   │   ├── BenchmarkStat.cs
    │   │   │   ├── CompositeBenchmarkOutput.cs
    │   │   │   ├── IBenchmarkOutput.cs
    │   │   │   ├── MetricRunReport.cs
    │   │   │   ├── NoOpBenchmarkOutput.cs
    │   │   │   ├── Targets
    │   │   │   │   ├── ActionBenchmarkOutput.cs
    │   │   │   │   ├── ConsoleBenchmarkOutput.cs
    │   │   │   │   └── MarkdownBenchmarkOutput.cs
    │   │   │   └── TeamCityBenchmarkOutput.cs
    │   │   ├── Sdk
    │   │   │   ├── ActionBenchmarkInvoker.cs
    │   │   │   ├── Assertion.cs
    │   │   │   ├── AssertionResult.cs
    │   │   │   ├── AssertionType.cs
    │   │   │   ├── BenchmarkBuilder.cs
    │   │   │   ├── BenchmarkConstants.cs
    │   │   │   ├── Benchmark.cs
    │   │   │   ├── BenchmarkSettings.cs
    │   │   │   ├── Compiler
    │   │   │   │   ├── Assemblies
    │   │   │   │   │   ├── AssemblyRuntimeLoader.cs
    │   │   │   │   │   ├── IAssemblyLoader.cs
    │   │   │   │   │   └── NetFrameworkAssemblyLoader.cs
    │   │   │   │   ├── IDiscovery.cs
    │   │   │   │   ├── ReflectionDiscovery.Configurators.cs
    │   │   │   │   └── ReflectionDiscovery.cs
    │   │   │   ├── DefaultBenchmarkAssertionRunner.cs
    │   │   │   ├── IBenchmarkAssertionRunner.cs
    │   │   │   ├── IBenchmarkInvoker.cs
    │   │   │   ├── IBenchmarkSetting.cs
    │   │   │   ├── IMeasurementConfigurator.cs
    │   │   │   ├── MeasurementConfigurator.cs
    │   │   │   ├── ReflectionBenchmarkInvoker.cs
    │   │   │   ├── RunnerSettings.cs
    │   │   │   ├── TestPackage.cs
    │   │   │   ├── TestRunner.cs
    │   │   │   └── WarmupData.cs
    │   │   ├── Sys
    │   │   │   └── SysInfo.cs
    │   │   ├── TimingMeasurementAttribute.cs
    │   │   ├── Tracing
    │   │   │   ├── BenchmarkOutputTrace.cs
    │   │   │   ├── NoOpBenchmarkTrace.cs
    │   │   │   ├── TraceEvent.cs
    │   │   │   └── TraceLevel.cs
    │   │   └── Util
    │   │       ├── AtomicCounter.cs
    │   │       └── FileNameGenerator.cs
    │   ├── NBench.TestAssembly
    │   │   ├── App.config
    │   │   ├── ConfigBenchmark.cs
    │   │   ├── CounterThroughputBenchmark.cs
    │   │   ├── NBench.TestAssembly.csproj
    │   │   ├── Properties
    │   │   │   └── AssemblyInfo.cs
    │   │   └── SimpleCounterBenchmark.cs
    │   ├── NBench.Tests
    │   │   ├── Collection
    │   │   │   ├── Memory
    │   │   │   │   ├── GcCollectionsPerGenerationSpecs.cs
    │   │   │   │   └── GcTotalMemoryCollectorSpecs.cs
    │   │   │   └── Timing
    │   │   │       └── TimingCollectorSpec.cs
    │   │   ├── CommandLineSpecs.cs
    │   │   ├── CounterSpecs.cs
    │   │   ├── Metrics
    │   │   │   └── MeasureBucketSpecs.cs
    │   │   ├── NBench.Tests.csproj
    │   │   ├── Properties
    │   │   │   └── AssemblyInfo.cs
    │   │   ├── Reporting
    │   │   │   └── BenchmarkStatSpecs.cs
    │   │   ├── Sdk
    │   │   │   ├── AssertionSpecs.cs
    │   │   │   ├── BenchmarkBuilderSpecs.cs
    │   │   │   ├── BenchmarkExceptionSpecs.cs
    │   │   │   ├── BenchmarkFastIterationSpecs.cs
    │   │   │   ├── BenchmarkRunSpecs.cs
    │   │   │   ├── BenchmarkSettingsSpecs.cs
    │   │   │   ├── BenchmarkSlowIterationSpecs.cs
    │   │   │   ├── BenchmarkThroughputSpecs.cs
    │   │   │   ├── BenchmarkWarmupSpecs.cs
    │   │   │   └── Compiler
    │   │   │       ├── ReflectionBenchmarkInvokerSpecs.cs
    │   │   │       ├── ReflectionDiscoveryConfiguratorSpecs.cs
    │   │   │       └── ReflectionDiscoverySpecs.cs
    │   │   ├── TestMetricCollector.cs
    │   │   ├── Tracing
    │   │   │   └── BenchmarkTraceSpecs.cs
    │   │   └── XunitBenchmarkOutputHelper.cs
    │   ├── NBench.Tests.End2End
    │   │   ├── App.config
    │   │   ├── BugFix153Spec.cs
    │   │   ├── NBenchIntegrationTest.WithDependencies.cs
    │   │   ├── NBenchIntregrationTest.cs
    │   │   ├── NBench.Tests.End2End.csproj
    │   │   ├── Properties
    │   │   │   └── AssemblyInfo.cs
    │   │   └── SampleBenchmarks
    │   │       ├── CounterThroughputBenchmark.cs
    │   │       ├── GcAllGenerationsAssertionBenchmark.cs
    │   │       ├── SimpleCounterBenchmark.cs
    │   │       └── SimpleTimingAssertionBenchmark.cs
    │   ├── NBench.Tests.Performance
    │   │   ├── BenchmarkMemoryAllocationSpec.cs
    │   │   ├── CombinedPerfSpecs.cs
    │   │   ├── CounterPerfSpec.cs
    │   │   ├── IterationModeMeasurementSpec.cs
    │   │   ├── MemoryAllocationSpec.cs
    │   │   ├── NBench.Tests.Performance.csproj
    │   │   ├── Program.cs
    │   │   ├── Properties
    │   │   │   └── AssemblyInfo.cs
    │   │   ├── ThroughputLoopPerformanceSpec_Int32.cs
    │   │   ├── ThroughputLoopPerformanceSpec_Int64.cs
    │   │   └── TimingBenchmark.cs
    │   ├── NBench.Tests.Performance.WithDependencies
    │   │   ├── Actor
    │   │   │   └── ActorThroughputSpec.cs
    │   │   └── NBench.Tests.Performance.WithDependencies.csproj
    │   └── NBench.Tests.Reporting
    │       ├── NBench.Tests.Reporting.csproj
    │       └── Reporting
    │           ├── MarkdownBenchmarkOutputSpec.cs
    │           └── MarkdownBenchmarkOutputSpec.Should_report_valid_markdown_format.approved.txt
    └── tools
        └── AddCopyrightHeaderToSourceFiles.ps1

56 directories, 192 files

标签:

实例下载地址

NBench:.NET应用的跨平台性能基准测试框架

不能下载?内容有错? 点击这里报错 + 投诉 + 提问

好例子网口号:伸出你的我的手 — 分享

网友评论

发表评论

(您的评论需要经过审核才能显示)

查看所有0条评论>>

小贴士

感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。

  • 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
  • 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
  • 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
  • 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。

关于好例子网

本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明

;
报警