• Avalanche.Core
Search Results for

    Show / Hide Table of Contents
    • Avalanche.Accessor
      • Introduction
      • IAccessor
        • IAccessor
        • IFieldAccessor
        • IListAccessor
        • IMapAccessor
        • IRecordAccessor
        • IOneOfAccessor
        • IAnyAccessor
      • Dto
        • Introduction
        • IList<T>
        • IDictionary<K,V>
        • FieldInfo
        • OneOfAttribute
        • StructLayoutAttribute
        • Class
      • Articles
        • Dependency Injection
        • AccessorMessages
    • Avalanche.Binding
      • Introduction
    • Avalanche.Configuration
      • Introduction
      • Configuration Binding
      • ConfigurationExtensions
      • MemoryConfiguration
      • PrintTree
      • Saving IOptions
      • Yaml
    • Avalanche.Converter
      • Introduction
      • EnumConverter
      • Func<,>
      • HexConverter
      • PrimitiveConverter
      • StringConverter
    • Avalanche.Core
      • License
    • Avalanche.DataType
      • Introduction
      • DataType
        • IDataType
        • IListType
        • IMapType
        • IRecordType
        • IFieldType
        • IOneOfType
        • IAnyType
        • IStringType
        • IValueType
        • IIntegerType
        • IEnumerationType
        • IFloatingPointType
      • Dto
        • Introduction
        • IList<T>
        • IDictionary<K,V>
        • FieldInfo
        • Enum
        • OneOfAttribute
        • StructLayoutAttribute
        • Class
        • DtoTarget(IDataType)
        • IntermediateTarget
      • Articles
        • DataTypeRequest
        • PrintTree
        • DataTypeMessages
    • Avalanche.Emit
      • Introduction
      • TypeBuilder
      • ConstructorBuilder
      • MethodBuilder
      • PropertyBuilder
      • FieldBuilder
      • Emit
      • Utilities
        • CustomAttributeUtilities
        • ToStringRequest
    • Avalanche.FileSystem
      • Introduction
      • Abstractions
        • IFileSystemBrowse
        • IFileSystemCreateDirectory
        • IFileSystemDelete
        • IFileSystemFileAttribute
        • IFileSystemMount
        • IFileSystemMove
        • IFileSystemObserve
        • IFileSystemOpenStream
        • IFileSystemOpenMemory
        • IEvent
        • IEntry
        • IOption
        • IToken
      • FileSystem
      • VirtualFileSystem
      • MemoryFileSystem
      • EmbeddedFileSystem
      • HttpFileSystem
      • Decoration
      • IFileProvider
      • Utilities
        • Dispose
        • FileDictionary
        • FileScanner
        • FilterEnumerable
        • OperationSession
        • PollingFilterWatchToken
        • VisitTree
      • Article
        • Examples
        • PrintTree
    • Avalanche.Identity
      • Introduction
      • Identity
      • IdentityParts
      • IdentityInterner
      • IdentityComparer
      • Print Tree
      • IdentityAccessors
        • Introduction
        • TypeName
    • Avalanche.Localization
      • Introduction
      • Localization
      • LocalizationFile
      • LocalizationFiles
      • LocalizationFileSystem
      • LocalizationFileFormat
      • LocalizationLine
      • LocalizationLines
      • TemplateFormat
      • CultureProvider
      • FallbackCultureProvider
      • ResourceManager
      • LocalizationError
      • Microsoft.Extensions
        • Introduction
        • DependencyInjection
        • FileProvider
        • Logging
        • ITextLocalizer
        • IFileLocalizer
        • Localization
      • Asp.Net
        • Introduction
        • Supplying localization
        • Inject to pages
        • Culture Assigned
        • Minimalistic Api
        • Diagnostics
      • Pluralization
        • Introduction
        • Multiple plural parameters
        • Custom PluralRules
        • Invariant Culture
        • Unit Prefix
        • IPluralRule
        • IPluralNumber
        • IPluralRules
        • CLDRs
        • Unicode.CLDR40
        • Unicode.CLDR41
        • Unicode.CLDR42
        • Unicode.CLDR43
      • Articles
        • Alphabet localization
        • Benchmarks
        • Caching
        • Class Library
        • Demo
        • Diagnostics
        • Embedded resources
        • Emplacement
        • File localization
        • Text localization
        • Printing templates
    • Avalanche.Memory
      • Introduction
      • IMemory<T>
      • BlockMemory<T>
      • FileMemory
      • ListMemory<L, T>
      • MemoryMemory<T>
      • MMFMemory<T>
      • PointerMemory<T>
      • Slice<M, T>
      • StreamMemory
      • Concurrency
        • RWLockedMemory
        • SynchronizedMemory
      • Serialization
        • Benchmarks
        • Fixed<T>
        • Variable<T>
        • ZigZag<T>
        • StringEncoding
      • Articles
        • Fixed-size and Variable-sized
        • IBlockPool<T>
        • Print Tree
        • Read and Write events
        • Stream View
        • Zero Heap
    • Avalanche.Message
      • Introduction
      • IMessage
      • IMessageProvider
      • IMessageDescription
      • IMessageDescriptions
      • MessageDescriptionsBase
      • MessageLevel
      • Message printing
      • Messages and Exceptions
      • Microsoft.Extensions
        • DependencyInjection
      • Articles
        • Aggregate Messages
        • Localization
        • Localization Templates
        • Logging
        • Validation
    • Avalanche.Module
      • Introduction
      • IServiceCollection
      • IServiceBuilder
      • IHostBuilder
      • Dependencies
    • Avalanche.Options
      • Introduction
      • OptionsExtensions
      • OptionsMonitorCast
    • Avalanche.Protobuf
      • Introduction
    • Avalanche.Service
      • Introduction
      • Service
        • Introduction
        • IService
        • IServiceDisposable
        • IServiceDecoration
        • IServiceCast
        • IServiceObservable
        • IServiceContainer
        • Construction
        • Query
        • CancellationToken
        • CachePolicy
        • Scope
      • Handler
        • Introduction
        • IHandler
        • IHandlerCast
        • IHandlerDecoration
        • IHandlerWithOrder
        • CancellationToken
        • Cyclicity
        • Delegates
        • Invokable
        • ExportAttribute
        • OrderAttribute
        • PrintTree
        • Recursion
      • Query
        • Introduction
        • IQuery
        • IQueryCast
        • IQueryDecoration
      • Entry
        • Introduction
        • IEntry
        • IEntryCast
        • IEntryDecoration
        • IEntryObservable
        • IEntryVisitable
        • EntryState
      • Request
        • Introduction
        • IRequest
        • IRequestFor
        • IRequestToBeCached
        • IRequestToBeDisposed
        • RequestAttribute
        • ContextParameterAttribute
        • Print Tree
      • Dependency Injection
        • Introduction
        • Asp.Net
        • ServiceRequest<T>
        • Decorating a service
        • Handler
        • CachePolicy
        • CancellationToken
        • QueryLogger
        • IHostBuilder
      • Examples
        • NodeCount
        • Expression
        • Mapper
      • Articles
        • Benchmarks
        • Error Handling
        • ServiceMessages
    • Avalanche.StatusCode
      • Introduction
      • HResult
        • Introduction
        • HResult.Facilities
        • BasicMessages
        • RpcMessages
        • DispatchMessages
        • StorageMessages
        • ItfMessages
        • Win32Messages
        • WindowsMessages
        • SspiMessages
        • CertMessages
        • MediaServerMessages
        • SetupApiMessages
        • ScardMessages
        • ComPlusMessages
        • ClrMessages
        • UserModeFilterManagerMessages
        • GraphicsMessages
        • TpmServicesMessages
        • TpmSoftwareMessages
        • PlaMessages
        • FveMessages
        • FwpMessages
        • NdisMessages
        • DltMessages
      • System
        • Introduction
        • AccessControlMessages
        • AggregateMessages
        • AppDomainMessages
        • ArgumentMessages
        • ArgumentNullMessages
        • ArgumentOutOfRangeMessages
        • ArithmeticMessages
        • ArrayMessages
        • AssemblyMessages
        • BadImageFormatMessages
        • CodeContractMessages
        • CodePageMessages
        • CollectionsMessages
        • CompilerServiceMessages
        • CryptographyMessages
        • CultureMessages
        • DiagnosticsMessages
        • EventSourceMessages
        • ExecutionEngineMessages
        • FormatMessages
        • HostProtectionMessages
        • IOMessages
        • IndexOutOfRangeMessages
        • InteropServiceMessages
        • InvalidCastMessages
        • InvalidOperationMessages
        • IsolatedStorageMessages
        • LazyMessages
        • MarshalerMessages
        • MemoryMessages
        • MiscellaneousMessages
        • NotImplementedMessages
        • NotSupportedMessages
        • ObjectDisposedMessages
        • OperationCanceledMessages
        • OverflowMessages
        • PlatformMessages
        • PolicyMessages
        • PrincipalMessages
        • ProgramMessages
        • ReferenceMessages
        • ReflectionMessages
        • RegionMessages
        • RemotingMessages
        • ResourcesMessages
        • SecurityMessages
        • SerializationMessages
        • StackMessages
        • TaskMessages
        • TextMessages
        • ThreadingMessages
        • TimeZoneMessages
        • TypeMessages
        • XmlMessages
      • HttpStatusCode
      • OpcUaStatusCode
    • Avalanche.Template
      • Introduction
      • TemplateFormats
      • ITemplatePrintable
      • ITemplateFormatPrintable
      • ITemplateText
      • ITemplateBreakdown
      • ITemplateFormat
      • ITemplateFormats
      • Extract Arguments
      • Emplacement
    • Avalanche.Tokenizer
      • Introduction
      • IToken
      • ITokenizer
      • Tokenizers
    • Avalanche.Utilities
      • Introduction
      • Collections
        • ArrayList
        • ArrayUtilities
        • BijectionMap
        • CachedSelect
        • DictionaryAdapter
        • EnumerableExtensions
        • LocakableDictionary
        • LockableList
        • MapList
        • Pipe
        • RingQueue
        • StructList
        • Tuples
        • TupleUtilities
      • Comparers
        • IGraphComparer
        • IGraphComparable
        • AlphaNumericComparer
        • EnumerableComparer
        • EnumerableGraphComparer
        • ReferenceComparer
        • KeyValuePairComparer
        • DefaultComparerProvider
        • RecordComparer
      • Cloners
        • ICloner
        • IGraphCloner
        • IGraphCloneable
        • ListCloner
        • DictionaryCloner
        • FieldCloner
        • PassthroughCloner
        • RecordCloner
        • ClonerProvider
      • Dispose
        • IDisposeAttachable
        • IDisposeBelatable
      • Provider
        • Introduction
        • ProviderBase
        • Delegate
        • Pipe
        • Cache
        • ResultCapture
        • AsReadOnly
        • SharedResource
        • AsService
        • IProviderEvent
      • Record
        • IRecordDescription
        • IFieldDescription
        • IConstructorDescription
        • IConstructionDescription
        • IParameterDescription
        • IRecordProviders
        • RecordDelegates
          • RecordCreate
          • RecordClone
          • RecordCopy
          • IRecordDelegates
        • FieldDelegates
          • FieldRead
          • FieldWrite
          • RecreateWith
          • IFieldDelegates
      • Reflection
        • EnumDescription
      • String
        • IEscaper
        • UnicodeString
        • Hex
      • Miscellaneous
        • IIdGenerator
        • Permutation
        • IReadOnly
        • IUserDataContainer
        • ITreeNode
        • Void
    • Avalanche.Writer
      • Introduction
      • ConstantWriter
      • Context
      • ConvertWriter
      • DefaultConstructor
      • DelegateWriter
      • PassthroughWriter
      • Referer
      • TypeCast
      • Writer
      • WriterPipe
      • WriterMessages

    Serialization Benchmarks

    The following serialization operations were ran on various primitives.

    byte[] data = new byte[32];
    var memory = new MemoryMemory<byte>(data);
    Fixed<T>.TryWrite(memory, default, 0L);
    Fixed<T>.TryRead(memory, out T value, 0L);
    Variable<T>.TryWrite(memory, default, out int bytesWritten, 0L);
    Variable<T>.TryRead(memory, out value, out bytesWritten, 0L);
    ZigZag<T>.TryWrite(memory, default, out bytesWritten, 0L);
    ZigZag<T>.TryRead(memory, out value, out bytesWritten, 0L);
    

    Int8

    Method Mean Error StdDev Allocated
    FixedT_TryWrite 4.509 ns 0.0540 ns 0.0505 ns -
    FixedT_TryRead 4.433 ns 0.0570 ns 0.0533 ns -
    VariableT_TryWrite 13.453 ns 0.0481 ns 0.0375 ns -
    VariableT_TryRead 10.981 ns 0.1019 ns 0.0953 ns -
    ZigZagT_TryWrite 13.485 ns 0.0435 ns 0.0386 ns -
    ZigZagT_TryRead 10.674 ns 0.0279 ns 0.0233 ns -

    UInt8

    Method Mean Error StdDev Allocated
    FixedT_TryWrite 4.446 ns 0.0361 ns 0.0338 ns -
    FixedT_TryRead 4.572 ns 0.0296 ns 0.0231 ns -
    VariableT_TryWrite 13.306 ns 0.1323 ns 0.1237 ns -
    VariableT_TryRead 11.674 ns 0.2578 ns 0.4779 ns -
    ZigZagT_TryWrite 13.068 ns 0.0791 ns 0.0701 ns -
    ZigZagT_TryRead 10.749 ns 0.1356 ns 0.1268 ns -

    Int16

    Method Mean Error StdDev Allocated
    FixedT_TryWrite 5.541 ns 0.0748 ns 0.0699 ns -
    FixedT_TryRead 5.316 ns 0.0414 ns 0.0346 ns -
    VariableT_TryWrite 13.132 ns 0.1499 ns 0.1329 ns -
    VariableT_TryRead 11.851 ns 0.0387 ns 0.0323 ns -
    ZigZagT_TryWrite 13.918 ns 0.0181 ns 0.0151 ns -
    ZigZagT_TryRead 11.495 ns 0.0586 ns 0.0457 ns -

    UInt16

    Method Mean Error StdDev Allocated
    FixedT_TryWrite 5.472 ns 0.0278 ns 0.0217 ns -
    FixedT_TryRead 5.298 ns 0.0573 ns 0.0536 ns -
    VariableT_TryWrite 13.081 ns 0.0971 ns 0.0861 ns -
    VariableT_TryRead 11.825 ns 0.1258 ns 0.1176 ns -
    ZigZagT_TryWrite 13.977 ns 0.1710 ns 0.1516 ns -
    ZigZagT_TryRead 11.495 ns 0.0956 ns 0.0894 ns -

    Int32

    Method Mean Error StdDev Allocated
    FixedT_TryWrite 4.883 ns 0.0366 ns 0.0325 ns -
    FixedT_TryRead 4.637 ns 0.0342 ns 0.0303 ns -
    VariableT_TryWrite 13.958 ns 0.0467 ns 0.0364 ns -
    VariableT_TryRead 12.455 ns 0.0263 ns 0.0206 ns -
    ZigZagT_TryWrite 14.643 ns 0.0920 ns 0.0816 ns -
    ZigZagT_TryRead 11.950 ns 0.1408 ns 0.1317 ns -

    UInt32

    Method Mean Error StdDev Allocated
    FixedT_TryWrite 4.901 ns 0.0197 ns 0.0185 ns -
    FixedT_TryRead 4.637 ns 0.0493 ns 0.0461 ns -
    VariableT_TryWrite 13.988 ns 0.0628 ns 0.0524 ns -
    VariableT_TryRead 12.527 ns 0.0947 ns 0.0886 ns -
    ZigZagT_TryWrite 14.621 ns 0.0989 ns 0.0826 ns -
    ZigZagT_TryRead 12.051 ns 0.0899 ns 0.0841 ns -

    Int64

    Method Mean Error StdDev Allocated
    FixedT_TryWrite 4.845 ns 0.0369 ns 0.0327 ns -
    FixedT_TryRead 4.430 ns 0.0496 ns 0.0464 ns -
    VariableT_TryWrite 15.808 ns 0.0515 ns 0.0430 ns -
    VariableT_TryRead 13.521 ns 0.1464 ns 0.1369 ns -
    ZigZagT_TryWrite 16.043 ns 0.1749 ns 0.1551 ns -
    ZigZagT_TryRead 13.393 ns 0.0991 ns 0.0927 ns -

    UInt64

    Method Mean Error StdDev Allocated
    FixedT_TryWrite 4.838 ns 0.0464 ns 0.0434 ns -
    FixedT_TryRead 4.433 ns 0.0476 ns 0.0445 ns -
    VariableT_TryWrite 15.864 ns 0.0900 ns 0.0798 ns -
    VariableT_TryRead 13.452 ns 0.0996 ns 0.0931 ns -
    ZigZagT_TryWrite 15.975 ns 0.1005 ns 0.0891 ns -
    ZigZagT_TryRead 13.502 ns 0.1105 ns 0.1034 ns -

    Int128

    Method Mean Error StdDev Allocated
    FixedT_TryWrite 5.048 ns 0.0544 ns 0.0454 ns -
    FixedT_TryRead 4.502 ns 0.0768 ns 0.0719 ns -
    VariableT_TryWrite 20.095 ns 0.2685 ns 0.2512 ns -
    VariableT_TryRead 16.115 ns 0.2673 ns 0.2369 ns -
    ZigZagT_TryWrite 19.251 ns 0.0552 ns 0.0431 ns -
    ZigZagT_TryRead 17.463 ns 0.1636 ns 0.1530 ns -

    UInt128

    Method Mean Error StdDev Allocated
    FixedT_TryWrite 4.810 ns 0.0432 ns 0.0361 ns -
    FixedT_TryRead 4.454 ns 0.0588 ns 0.0550 ns -
    VariableT_TryWrite 19.985 ns 0.2806 ns 0.2625 ns -
    VariableT_TryRead 15.876 ns 0.0437 ns 0.0365 ns -
    ZigZagT_TryWrite 19.345 ns 0.2770 ns 0.2591 ns -
    ZigZagT_TryRead 17.231 ns 0.1683 ns 0.1574 ns -

    Setup

    BenchmarkDotNet=v0.13.5, OS=Windows 11 (10.0.22621.1555/22H2/2022Update/SunValley2)
    AMD Ryzen 9 3950X, 1 CPU, 32 logical and 16 physical cores
    .NET SDK=7.0.300-preview.23179.2
    

    Full Example

    Full example
    using System;
    using Avalanche.Memory;
    using static System.Console;
    
    public class benchmarks<T> where T: struct
    {
        public static void Run()
        {
            {
                // <01>
                byte[] data = new byte[32];
                var memory = new MemoryMemory<byte>(data);
                Fixed<T>.TryWrite(memory, default, 0L);
                Fixed<T>.TryRead(memory, out T value, 0L);
                Variable<T>.TryWrite(memory, default, out int bytesWritten, 0L);
                Variable<T>.TryRead(memory, out value, out bytesWritten, 0L);
                ZigZag<T>.TryWrite(memory, default, out bytesWritten, 0L);
                ZigZag<T>.TryRead(memory, out value, out bytesWritten, 0L);
                // </01>
            }
        }
    }
    
    
    In This Article
    Back to top