File tree Expand file tree Collapse file tree 2 files changed +44
-1
lines changed
Expand file tree Collapse file tree 2 files changed +44
-1
lines changed Original file line number Diff line number Diff line change 147147 <Compile Remove =" libraries\System.Text.Json\Serializer\WritePreservedReferences.cs" />
148148 <Compile Remove =" libraries\System.Net.Security\SslStreamTests.Context.cs" />
149149 <Compile Remove =" libraries\System.Formats.Cbor\*.cs" />
150+ <Compile Remove =" libraries\System.Runtime\Perf.Half.cs" />
150151 </ItemGroup >
151152
152153 <ItemGroup Condition =" '$(TargetFrameworkIdentifier)' == '.NETFramework' Or ('$(TargetFrameworkIdentifier)' == '.NETCoreApp' And '$(_TargetFrameworkVersionWithoutV)' < '6.0')" >
217218 <!-- Workaround https://github.com/dotnet/project-system/issues/935 -->
218219 <None Include =" **/*.cs" />
219220 </ItemGroup >
220-
221221</Project >
Original file line number Diff line number Diff line change 1+ // Licensed to the .NET Foundation under one or more agreements.
2+ // The .NET Foundation licenses this file to you under the MIT license.
3+ // See the LICENSE file in the project root for more information.
4+
5+ using System . Collections . Generic ;
6+ using System . Globalization ;
7+ using System . Linq ;
8+ using System . Runtime . CompilerServices ;
9+ using System . Runtime . InteropServices ;
10+
11+ using BenchmarkDotNet . Attributes ;
12+
13+ using MicroBenchmarks ;
14+
15+ namespace System . Tests
16+ {
17+ [ BenchmarkCategory ( Categories . Libraries ) ]
18+ public class Perf_Half
19+ {
20+ public static IEnumerable < Half > Values => new Half [ ]
21+ {
22+ BitConverter . UInt16BitsToHalf ( 0x03ff ) , //Maximum subnormal number in Half
23+ ( Half ) 12345.0f /* same value used by other tests to compare the perf */ ,
24+ BitConverter . UInt16BitsToHalf ( 0x7dff ) //NaN
25+ } ;
26+
27+ public static IEnumerable < float > SingleValues => new float [ ]
28+ {
29+ 6.097555E-05f ,
30+ 12345.0f /* same value used by other tests to compare the perf */ ,
31+ 65520.0f , //Minimum value that is infinity in Half
32+ float . NaN
33+ } ;
34+
35+ [ Benchmark ]
36+ [ ArgumentsSource ( nameof ( SingleValues ) ) ]
37+ public Half SingleToHalf ( float value ) => ( Half ) value ;
38+
39+ [ Benchmark ]
40+ [ ArgumentsSource ( nameof ( Values ) ) ]
41+ public float HalfToSingle ( Half value ) => ( float ) value ;
42+ }
43+ }
You can’t perform that action at this time.
0 commit comments