Skip to content

Commit

Permalink
Sep 0.4.0 (#61)
Browse files Browse the repository at this point in the history
* add Sep_MT

* forward args to benchmark runner
  • Loading branch information
nietras authored Jan 2, 2024
1 parent 407b3cc commit 6b98337
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
6 changes: 6 additions & 0 deletions NCsvPerf/CsvReadable/Benchmarks/PackageAssetsSuite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,12 @@ public void Sep()
Execute(new Sep());
}

[Benchmark]
public void Sep_MT()
{
Execute(new Sep_MT());
}

[Benchmark]
public void ServiceStack_Text()
{
Expand Down
29 changes: 29 additions & 0 deletions NCsvPerf/CsvReadable/Implementations/Sep_MT.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using nietras.SeparatedValues;

namespace Knapcode.NCsvPerf.CsvReadable
{
public class Sep_MT : ICsvReader
{
public List<T> GetRecords<T>(MemoryStream stream) where T : ICsvReadable, new()
{
using var reader = nietras.SeparatedValues.Sep.Reader(o => o with
{
HasHeader = false,
#if ENABLE_STRING_POOLING
CreateToString = SepToString.PoolPerColThreadSafeFixedCapacity(maximumStringLength: 128),
#endif
})
.From(stream);

return reader.ParallelEnumerate(row =>
{
var record = new T();
record.Read(row.UnsafeToStringDelegate);
return record;
}).ToList();
}
}
}
2 changes: 1 addition & 1 deletion NCsvPerf/NCsvPerf.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<PackageReference Include="NReco.Csv" Version="1.0.2" />
<PackageReference Include="Open.Text.CSV" Version="3.4.0" />
<PackageReference Include="RecordParser" Version="2.3.0" />
<PackageReference Include="Sep" Version="0.3.0" />
<PackageReference Include="Sep" Version="0.4.0" />
<PackageReference Include="ServiceStack.Text" Version="6.11.0" />
<PackageReference Include="Sky.Data.Csv" Version="2.5.0" />
<PackageReference Include="SoftCircuits.CsvParser" Version="4.1.0" />
Expand Down
2 changes: 1 addition & 1 deletion NCsvPerf/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ private static void Main(string[] args)
#else
config = null;
#endif
BenchmarkRunner.Run<PackageAssetsSuite>(config);
BenchmarkRunner.Run<PackageAssetsSuite>(config, args);
}
}
}

0 comments on commit 6b98337

Please sign in to comment.