【基准测试】BenchmarkDotNet介绍
BenchmarkDotNet 概述 BenchmarkDotNet helps you to transform methods into benchmarks, track their performance, and share reproducible measurement experiments. It's no harder than writing unit tests 提取几个关键字(其实是只认识那几个英文单词) 将方法转换基准测试 跟踪性能 可重复实验 不必单元测试难 说白了,就是代码的性能测试,通常是用来比较两段代码/方法,或者在不同平台上的执行效果。 BenchmarkDotNet 快速入门 添加包 dotnet add package BenchmarkDotNet 添加需要基准测试的方法(这里我准备两个排序算法,快速排序 && 堆排序) [Benchmark] [Arguments(new int[] { 3, 1, 10, 9, 6, 2, 5, 7, 8, 4 })] public void QuickSort(int[] nums) => Demo.BenchmarkDotNet.QuickSort.Sort(nums); [Benchmark] [Arguments(new int[] { 3, 1, 10, 9, 6, 2, 5, 7, 8,