-
Notifications
You must be signed in to change notification settings - Fork 275
/
Copy pathPerf.CborWriter.cs
28 lines (24 loc) · 1.06 KB
/
Perf.CborWriter.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using BenchmarkDotNet.Attributes;
using MicroBenchmarks;
using System.Collections.Generic;
namespace System.Formats.Cbor.Tests
{
[BenchmarkCategory(Categories.Libraries, Categories.NoWASM)]
public class Perf_CborWriter
{
private CborWriter _ctap2Writer = new CborWriter(CborConformanceMode.Ctap2Canonical, convertIndefiniteLengthEncodings: true);
private byte[] _writeBuffer = new byte[1024];
[Benchmark]
[ArgumentsSource(nameof(ECDSaCosePublicKeys))]
public void WriteCoseKey(ECDsaCosePublicKey publicKey)
{
_ctap2Writer.Reset();
_ctap2Writer.WriteECParametersAsCosePublicKey(publicKey.ECParameters, publicKey.HashAlgorithmName);
_ctap2Writer.Encode(_writeBuffer);
}
public IEnumerable<object> ECDSaCosePublicKeys() => ECDsaCosePublicKey.CreatePublicKeys();
}
}