Collecting data about cbor time
This commit is contained in:
1 parent
c14f0498a8
commit
af6e7b6547
4 files changed
+17
-7
No files matched your search
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Formats.Cbor;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
@@ -12,11 +13,16 @@ namespace mROA.Cbor
|
||||
{
|
||||
public class CborSerializationToolkit : IContextualSerializationToolKit
|
||||
{
|
||||
public static TimeSpan SerializationTime = TimeSpan.Zero;
|
||||
public byte[] Serialize(object objectToSerialize, IEndPointContext context)
|
||||
{
|
||||
var sw = Stopwatch.StartNew();
|
||||
var writer = new CborWriter();
|
||||
WriteData(objectToSerialize, writer, context);
|
||||
return writer.Encode();
|
||||
var result = writer.Encode();
|
||||
sw.Stop();
|
||||
SerializationTime = SerializationTime.Add(sw.Elapsed);
|
||||
return result;
|
||||
}
|
||||
|
||||
public int Serialize(object objectToSerialize, Span<byte> destination, IEndPointContext context)
|
||||
|
||||
Reference in new issue
Block a user