Skip to content

Commit

Permalink
Update dependencies and re-target .NET 6.0 (shibayan#24)
Browse files Browse the repository at this point in the history
* Update dependencies

* Re-target to .NET 6.0 or later
  • Loading branch information
shibayan authored Sep 4, 2023
1 parent f156eb6 commit 439955a
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 51 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
branches: [ master ]

env:
DOTNET_VERSION: 6.0.x
DOTNET_VERSION: 7.0.x

jobs:
build:
Expand All @@ -16,7 +16,7 @@ jobs:
- uses: actions/checkout@v3

- name: Use .NET ${{ env.DOTNET_VERSION }}
uses: actions/setup-dotnet@v2
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
tags: [ v* ]

env:
DOTNET_VERSION: 6.0.x
DOTNET_VERSION: 7.0.x

jobs:
publish:
Expand All @@ -14,7 +14,7 @@ jobs:
- uses: actions/checkout@v3

- name: Use .NET ${{ env.DOTNET_VERSION }}
uses: actions/setup-dotnet@v2
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.2" />
<PackageReference Include="BenchmarkDotNet" Version="0.13.7" />
</ItemGroup>

<ItemGroup>
Expand Down
9 changes: 3 additions & 6 deletions CsvHelper.FastDynamic.Performance/ReaderBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,19 @@
using System.Linq;

using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Diagnosers;

using CsvHelper.FastDynamic.Performance.Internal;

namespace CsvHelper.FastDynamic.Performance;

[MemoryDiagnoser]
[EventPipeProfiler(EventPipeProfile.CpuSampling)]
public class ReaderBenchmark
{
private const string SampleCsvFile = @".\sampledata\SFO_Airport_Monthly_Utility_Consumption_for_Natural_Gas__Water__and_Electricity.csv";

public ReaderBenchmark()
{
_sampleCsvData = File.ReadAllText(SampleCsvFile);
}

private readonly string _sampleCsvData;
private readonly string _sampleCsvData = File.ReadAllText(SampleCsvFile);

[Benchmark(Baseline = true)]
public IReadOnlyList<dynamic> GetRecords()
Expand Down
2 changes: 2 additions & 0 deletions CsvHelper.FastDynamic.Performance/WriterBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
using System.IO;

using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Diagnosers;

namespace CsvHelper.FastDynamic.Performance;

[MemoryDiagnoser]
[EventPipeProfiler(EventPipeProfile.CpuSampling)]
public class WriterBenchmark
{
private const string SampleCsvFile = @".\sampledata\SFO_Airport_Monthly_Utility_Consumption_for_Natural_Gas__Water__and_Electricity.csv";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="xunit" Version="2.5.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
4 changes: 2 additions & 2 deletions CsvHelper.FastDynamic/CsvHelper.FastDynamic.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.1;netstandard2.0</TargetFrameworks>
<TargetFramework>net6.0</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>

Expand All @@ -17,7 +17,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CsvHelper" Version="29.0.0" />
<PackageReference Include="CsvHelper" Version="30.0.1" />
</ItemGroup>

<ItemGroup>
Expand Down
8 changes: 2 additions & 6 deletions CsvHelper.FastDynamic/CsvReaderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public static class CsvReaderExtensions

public static IEnumerable<dynamic> EnumerateDynamicRecords(this CsvReader csvReader)
{
if (csvReader.Configuration.HasHeaderRecord && csvReader.HeaderRecord is null)
if (csvReader.HeaderRecord is null)
{
if (!csvReader.Read())
{
Expand Down Expand Up @@ -56,8 +56,6 @@ public static IEnumerable<dynamic> EnumerateDynamicRecords(this CsvReader csvRea
}
}

#if NETSTANDARD2_1

public static async Task<IReadOnlyList<dynamic>> GetDynamicRecordsAsync(this CsvReader csvReader)
{
var records = new List<dynamic>();
Expand All @@ -72,7 +70,7 @@ public static async Task<IReadOnlyList<dynamic>> GetDynamicRecordsAsync(this Csv

public static async IAsyncEnumerable<dynamic> EnumerateDynamicRecordsAsync(this CsvReader csvReader)
{
if (csvReader.Configuration.HasHeaderRecord && csvReader.HeaderRecord is null)
if (csvReader.HeaderRecord is null)
{
if (!await csvReader.ReadAsync().ConfigureAwait(false))
{
Expand Down Expand Up @@ -116,6 +114,4 @@ public static async IAsyncEnumerable<dynamic> EnumerateDynamicRecordsAsync(this
yield return record;
}
}

#endif
}
4 changes: 0 additions & 4 deletions CsvHelper.FastDynamic/CsvWriterExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ public static async Task WriteDynamicRecordsAsync(this CsvWriter csvWriter, IEnu
}
}

#if NETSTANDARD2_1

public static async Task WriteDynamicRecordsAsync(this CsvWriter csvWriter, IAsyncEnumerable<object> records)
{
var context = csvWriter.Context;
Expand All @@ -69,8 +67,6 @@ public static async Task WriteDynamicRecordsAsync(this CsvWriter csvWriter, IAsy
}
}

#endif

private static void WriteHeaderInternal(this CsvWriter csvWriter, object record)
{
switch (record)
Expand Down
44 changes: 21 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,38 +53,36 @@ await foreach (var @record in records)

## Performance

### Dynamic record reader
### Dynamic records reader

```
BenchmarkDotNet=v0.13.2, OS=Windows 11 (10.0.22621.608)
AMD Ryzen 9 5950X, 1 CPU, 32 logical and 16 physical cores
.NET SDK=6.0.401
[Host] : .NET 6.0.9 (6.0.922.41905), X64 RyuJIT AVX2
DefaultJob : .NET 6.0.9 (6.0.922.41905), X64 RyuJIT AVX2
BenchmarkDotNet v0.13.7, Windows 11 (10.0.22621.2215/22H2/2022Update/SunValley2)
AMD Ryzen 9 7950X, 1 CPU, 32 logical and 16 physical cores
.NET SDK 7.0.400
[Host] : .NET 7.0.10 (7.0.1023.36312), X64 RyuJIT AVX2
DefaultJob : .NET 7.0.10 (7.0.1023.36312), X64 RyuJIT AVX2
| Method | Mean | Error | StdDev | Ratio | Gen0 | Gen1 | Allocated | Alloc Ratio |
|--------------------- |---------:|--------:|--------:|------:|--------:|--------:|----------:|------------:|
| GetRecords | 878.3 us | 3.62 us | 3.20 us | 1.00 | 31.2500 | 15.6250 | 510.84 KB | 1.00 |
| GetDictionaryRecords | 208.0 us | 0.85 us | 0.76 us | 0.24 | 21.7285 | 10.7422 | 355.03 KB | 0.69 |
| GetDynamicRecords | 176.4 us | 1.07 us | 0.95 us | 0.20 | 14.4043 | 6.3477 | 237.26 KB | 0.46 |
| GetRawRecords | 154.7 us | 1.08 us | 1.01 us | 0.18 | 13.1836 | 5.8594 | 218.98 KB | 0.43 |
| GetRecords | 684.3 μs | 3.24 μs | 3.03 μs | 1.00 | 31.2500 | 15.6250 | 510.87 KB | 1.00 |
| GetDictionaryRecords | 200.3 μs | 0.71 μs | 0.66 μs | 0.29 | 21.7285 | 21.4844 | 355.05 KB | 0.70 |
| GetDynamicRecords | 163.7 μs | 0.91 μs | 0.85 μs | 0.24 | 14.4043 | 5.1270 | 237.28 KB | 0.46 |
| GetRawRecords | 154.1 μs | 0.45 μs | 0.38 μs | 0.23 | 13.1836 | 5.1270 | 219 KB | 0.43 |
```

### Dynamic record writer
### Dynamic records writer

```
BenchmarkDotNet=v0.13.2, OS=Windows 11 (10.0.22621.608)
AMD Ryzen 9 5950X, 1 CPU, 32 logical and 16 physical cores
.NET SDK=6.0.401
[Host] : .NET 6.0.9 (6.0.922.41905), X64 RyuJIT AVX2
DefaultJob : .NET 6.0.9 (6.0.922.41905), X64 RyuJIT AVX2
| Method | Mean | Error | StdDev | Ratio | Gen0 | Gen1 | Allocated | Alloc Ratio |
|---------------------------------- |---------:|--------:|--------:|------:|--------:|-------:|----------:|------------:|
| WriteRecords_DynamicObject | 873.9 us | 2.82 us | 2.64 us | 1.00 | 55.6641 | 9.7656 | 914.53 KB | 1.00 |
| WriteDynamicRecords_DynamicObject | 498.9 us | 2.52 us | 2.36 us | 0.57 | 13.6719 | 2.4414 | 225.84 KB | 0.25 |
BenchmarkDotNet v0.13.7, Windows 11 (10.0.22621.2215/22H2/2022Update/SunValley2)
AMD Ryzen 9 7950X, 1 CPU, 32 logical and 16 physical cores
.NET SDK 7.0.400
[Host] : .NET 7.0.10 (7.0.1023.36312), X64 RyuJIT AVX2
DefaultJob : .NET 7.0.10 (7.0.1023.36312), X64 RyuJIT AVX2
| Method | Mean | Error | StdDev | Ratio | Gen0 | Gen1 | Allocated | Alloc Ratio |
|---------------------------------- |---------:|--------:|--------:|------:|--------:|--------:|----------:|------------:|
| WriteRecords_DynamicObject | 670.2 μs | 4.27 μs | 3.99 μs | 1.00 | 55.6641 | 12.6953 | 914.65 KB | 1.00 |
| WriteDynamicRecords_DynamicObject | 414.1 μs | 1.93 μs | 1.80 μs | 0.62 | 13.6719 | 2.9297 | 225.95 KB | 0.25 |
```

## Thanks
Expand Down

0 comments on commit 439955a

Please sign in to comment.