Skip to content

Commit

Permalink
[feature] Improve JSON performance (#213)
Browse files Browse the repository at this point in the history
* [feature] Improve JSON performance

* Use dotnet 8 for building

* Use net8.0 test report file

* Increase wait time

* Ensure discovery

* Change code coverage file to net6.0

* Changed dotnet installation order

* Force coveralls v2.2.3

* Do not fail because coveralls report

* Install dotnet 8 for the running platform

* Installed dotnet 7
  • Loading branch information
jmmorato authored Nov 20, 2023
1 parent 1e35f57 commit a810e11
Show file tree
Hide file tree
Showing 16 changed files with 107 additions and 84 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/cd_standard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:

- uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.0.x'
dotnet-version: '8.0.x'

- name: Cache OpenDDS libraries
id: opendds-libraries-windows-cd
Expand Down Expand Up @@ -130,7 +130,7 @@ jobs:

- uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.0.x'
dotnet-version: '8.0.x'

- name: Cache OpenDDS libraries
id: opendds-libraries-linux-cd
Expand Down Expand Up @@ -236,7 +236,7 @@ jobs:

- uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.0.x'
dotnet-version: '8.0.x'

- name: Cache OpenDDS libraries
id: opendds-libraries-macos-cd
Expand Down Expand Up @@ -341,11 +341,11 @@ jobs:
./dotnet-install.ps1 -Architecture 'x64' -Channel 6.0;
echo "PATH=$Env:PATH" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
- name: Setup dotnet 7.0
- name: Setup dotnet 8.0
shell: pwsh
run: |
Invoke-WebRequest 'https://dot.net/v1/dotnet-install.ps1' -OutFile 'dotnet-install.ps1';
./dotnet-install.ps1 -Architecture 'x64' -Channel 7.0;
./dotnet-install.ps1 -Architecture 'x64' -Channel 8.0;
echo "PATH=$Env:PATH" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
- name: Install GitVersion
Expand Down Expand Up @@ -491,7 +491,7 @@ jobs:

- uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.0.x'
dotnet-version: '8.0.x'

- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0
Expand Down Expand Up @@ -583,7 +583,7 @@ jobs:

- uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.0.x'
dotnet-version: '8.0.x'

- name: Download OpenDDSharp NuGets
uses: actions/download-artifact@v3
Expand Down
71 changes: 41 additions & 30 deletions .github/workflows/ci_standard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,36 @@ jobs:
with:
fetch-depth: 0

# - name: Setup dotnet 8.0
# uses: actions/setup-dotnet@v3
# with:
# dotnet-version: '8.0.x'
#
# - name: Setup dotnet 6.0
# uses: actions/setup-dotnet@v3
# with:
# dotnet-version: '6.0.x'

- name: Setup dotnet 6.0
uses: actions/setup-dotnet@v3
with:
dotnet-version: '6.0.x'
shell: pwsh
run: |
Invoke-WebRequest 'https://dot.net/v1/dotnet-install.ps1' -OutFile 'dotnet-install.ps1';
./dotnet-install.ps1 -Architecture '${{ matrix.BuildPlatform }}' -Channel 6.0;
echo "PATH=$Env:PATH" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
- name: Setup dotnet 7.0
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.0.402'
shell: pwsh
run: |
Invoke-WebRequest 'https://dot.net/v1/dotnet-install.ps1' -OutFile 'dotnet-install.ps1';
./dotnet-install.ps1 -Architecture '${{ matrix.BuildPlatform }}' -Channel 7.0;
echo "PATH=$Env:PATH" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
# - name: Setup dotnet 6.0
# shell: pwsh
# run: |
# Invoke-WebRequest 'https://dot.net/v1/dotnet-install.ps1' -OutFile 'dotnet-install.ps1';
# ./dotnet-install.ps1 -Architecture '${{ matrix.BuildPlatform }}' -Channel 6.0;
# echo "PATH=$Env:PATH" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
#
# - name: Setup dotnet 7.0
# shell: pwsh
# run: |
# Invoke-WebRequest 'https://dot.net/v1/dotnet-install.ps1' -OutFile 'dotnet-install.ps1';
# ./dotnet-install.ps1 -Architecture '${{ matrix.BuildPlatform }}' -Channel 7.0;
# echo "PATH=$Env:PATH" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
- name: Setup dotnet 8.0
shell: pwsh
run: |
Invoke-WebRequest 'https://dot.net/v1/dotnet-install.ps1' -OutFile 'dotnet-install.ps1';
./dotnet-install.ps1 -Architecture '${{ matrix.BuildPlatform }}' -Channel 8.0;
echo "PATH=$Env:PATH" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
- name: Cache OpenDDS libraries
id: opendds-libraries-windows
Expand Down Expand Up @@ -93,7 +100,7 @@ jobs:
if: success() || failure()
with:
name: "Test Report: win-${{ matrix.BuildPlatform }} ${{ matrix.BuildConfiguration }}"
path: TestResults/netcoreapp3.1/test-results.trx,TestResults/net5.0/test-results.trx,TestResults/net6.0/test-results.trx,TestResults/net7.0/test-results.trx,TestResults/net461/test-results.trx,TestResults/net462/test-results.trx,TestResults/net47/test-results.trx,TestResults/net471/test-results.trx,TestResults/net472/test-results.trx,TestResults/net48/test-results.trx
path: TestResults/netcoreapp3.1/test-results.trx,TestResults/net5.0/test-results.trx,TestResults/net6.0/test-results.trx,TestResults/net7.0/test-results.trx,TestResults/net8.0/test-results.trx,TestResults/net461/test-results.trx,TestResults/net462/test-results.trx,TestResults/net47/test-results.trx,TestResults/net471/test-results.trx,TestResults/net472/test-results.trx,TestResults/net48/test-results.trx
reporter: dotnet-trx

- name: Get path to lcov file
Expand All @@ -102,13 +109,14 @@ jobs:
run: printf 'lcov_path=%s\n' ./TestResults/net6.0/*/coverage.info >> $GITHUB_OUTPUT

- name: Coveralls
uses: coverallsapp/github-action@v2
uses: coverallsapp/github-action@v2.2.3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
file: "${{ steps.get_lcov_path.outputs.lcov_path }}"
format: lcov
parallel: true
flag-name: coverage-windows-${{ join(matrix.*, '-') }}
fail-on-error: false

build_linux:
runs-on: ubuntu-latest
Expand All @@ -129,10 +137,10 @@ jobs:
with:
dotnet-version: '6.0.x'

- name: Setup dotnet 7.0
- name: Setup dotnet 8.0
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.0.402'
dotnet-version: '8.0.x'

- name: Cache OpenDDS libraries
id: opendds-libraries-linux
Expand Down Expand Up @@ -219,7 +227,7 @@ jobs:
if: success() || failure()
with:
name: "Test Report: linux-x64"
path: TestResults/netcoreapp3.1/test-results.trx,TestResults/net5.0/test-results.trx,TestResults/net6.0/test-results.trx,TestResults/net7.0/test-results.trx,TestResults/net461/test-results.trx,TestResults/net462/test-results.trx,TestResults/net47/test-results.trx,TestResults/net471/test-results.trx,TestResults/net472/test-results.trx,TestResults/net48/test-results.trx
path: TestResults/netcoreapp3.1/test-results.trx,TestResults/net5.0/test-results.trx,TestResults/net6.0/test-results.trx,TestResults/net7.0/test-results.trx,TestResults/net8.0/test-results.trx,TestResults/net461/test-results.trx,TestResults/net462/test-results.trx,TestResults/net47/test-results.trx,TestResults/net471/test-results.trx,TestResults/net472/test-results.trx,TestResults/net48/test-results.trx
reporter: dotnet-trx

- name: Get path to lcov file
Expand All @@ -228,13 +236,14 @@ jobs:
run: printf 'lcov_path=%s\n' ${{ github.workspace }}/TestResults/net6.0/*/coverage.info >> $GITHUB_OUTPUT

- name: Upload coverage to Coveralls
uses: coverallsapp/github-action@v2
uses: coverallsapp/github-action@v2.2.3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ steps.get_lcov_path.outputs.lcov_path }}
format: lcov
parallel: true
flag-name: coverage-linux-x64-Release
fail-on-error: false

build_macos:
runs-on: macos-13
Expand All @@ -255,10 +264,10 @@ jobs:
with:
dotnet-version: '6.0.x'

- name: Setup dotnet 7.0
- name: Setup dotnet 8.0
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.0.402'
dotnet-version: '8.0.x'

- name: Cache OpenDDS libraries
id: opendds-libraries-macos
Expand Down Expand Up @@ -345,7 +354,7 @@ jobs:
if: success() || failure()
with:
name: "Test Report: osx-x64"
path: TestResults/netcoreapp3.1/test-results.trx,TestResults/net5.0/test-results.trx,TestResults/net6.0/test-results.trx,TestResults/net7.0/test-results.trx,TestResults/net461/test-results.trx,TestResults/net462/test-results.trx,TestResults/net47/test-results.trx,TestResults/net471/test-results.trx,TestResults/net472/test-results.trx,TestResults/net48/test-results.trx
path: TestResults/netcoreapp3.1/test-results.trx,TestResults/net5.0/test-results.trx,TestResults/net6.0/test-results.trx,TestResults/net7.0/test-results.trx,TestResults/net8.0/test-results.trx,TestResults/net461/test-results.trx,TestResults/net462/test-results.trx,TestResults/net47/test-results.trx,TestResults/net471/test-results.trx,TestResults/net472/test-results.trx,TestResults/net48/test-results.trx
reporter: dotnet-trx

- name: Get path to lcov file
Expand All @@ -354,22 +363,24 @@ jobs:
run: printf 'lcov_path=%s\n' ${{ github.workspace }}/TestResults/net6.0/*/coverage.info >> $GITHUB_OUTPUT

- name: Upload coverage to Coveralls
uses: coverallsapp/github-action@v2
uses: coverallsapp/github-action@v2.2.3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ steps.get_lcov_path.outputs.lcov_path }}
format: lcov
parallel: true
flag-name: coverage-macos-x64-Release
fail-on-error: false

publish_coveralls:
runs-on: ubuntu-latest
needs: [build_windows, build_linux, build_macos]
steps:
- name: Publish coverage on Coveralls
uses: coverallsapp/github-action@v2
uses: coverallsapp/github-action@v2.2.3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
carryforward: coverage-windows-x64-Release,coverage-windows-x64-Debug,coverage-windows-x86-Release,coverage-windows-x86-Debug,coverage-linux-x64-Release,coverage-macos-x64-Release
fail-on-error: false

2 changes: 1 addition & 1 deletion Build/OpenDDSharp.Build/OpenDDSharp.Build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>

<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.7.30">
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.8.14">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
Expand Down
3 changes: 3 additions & 0 deletions Documentation/articles/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ The following table shows the Target Frameworks that are already implemented and
| net7.0 | :white_check_mark: |
| net7.0-android | :x: |
| net7.0-ios | :x: |
| net8.0 | :white_check_mark: |
| net8.0-android | :x: |
| net8.0-ios | :x: |

The following table shows the Runtimes Identifiers that are already implemented and tested ( :white_check_mark: ) and the ones that are planned for next versions ( :x: ):

Expand Down
6 changes: 3 additions & 3 deletions Examples/ConsoleDemoCore/ConsoleDemoCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Platforms>x64;x86;ARM64</Platforms>
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;osx-x64;osx-arm64</RuntimeIdentifiers>
<UseCurrentRuntimeIdentifier>true</UseCurrentRuntimeIdentifier>
Expand Down Expand Up @@ -30,7 +30,7 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>

<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.7.30">
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.8.14">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
Expand All @@ -40,7 +40,7 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

<ItemGroup>
<AssemblyAttribute Include="System.CLSCompliant">
<_Parameter1>true</_Parameter1>
Expand Down
49 changes: 25 additions & 24 deletions Native/CSharpJsonImplTemplate.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
public class <%TYPE%>TypeSupport : ITypeSupport<<%TYPE%>>
{
#region Field
private static readonly JsonSerializerOptions _serializerOptions = new JsonSerializerOptions
{
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
WriteIndented = false,
AllowTrailingCommas = true,
Converters =
{
new JsonStringEnumConverter(),
new OctetArrayConverter(),
new FloatJsonConverter(),
new DoubleJsonConverter(),
new DecimalJsonConverter(),
},
};

private static readonly <%TYPE%>SerializerContext _serializerContext = new <%TYPE%>SerializerContext(_serializerOptions);

private IntPtr _native;
#endregion

Expand Down Expand Up @@ -29,34 +46,12 @@

public string EncodeToString(<%TYPE%> sample)
{
return JsonSerializer.Serialize(sample, new JsonSerializerOptions
{
AllowTrailingCommas = false,
Converters =
{
new JsonStringEnumConverter(),
new OctetArrayConverter(),
new FloatJsonConverter(),
new DoubleJsonConverter(),
new DecimalJsonConverter(),
}
});
return JsonSerializer.Serialize(sample, typeof(<%TYPE%>), _serializerContext);
}

public <%TYPE%> DecodeFromString(string str)
{
return JsonSerializer.Deserialize<<%TYPE%>>(str, new JsonSerializerOptions
{
AllowTrailingCommas = true,
Converters =
{
new JsonStringEnumConverter(),
new OctetArrayConverter(),
new FloatJsonConverter(),
new DoubleJsonConverter(),
new DecimalJsonConverter(),
}
});
return JsonSerializer.Deserialize(str, typeof(<%TYPE%>), _serializerContext) as <%TYPE%>;
}
#endregion

Expand All @@ -79,6 +74,12 @@
#endregion
}

[JsonSourceGenerationOptions(GenerationMode = JsonSourceGenerationMode.Default)]
[JsonSerializable(typeof(<%TYPE%>))]
public partial class <%TYPE%>SerializerContext : JsonSerializerContext
{
}

public class <%TYPE%>DataWriter : DataWriter
{
#region Fields
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ The following table shows the Target Frameworks that are already implemented and
| net7.0 | :white_check_mark: |
| net7.0-android | :x: |
| net7.0-ios | :x: |
| net8.0 | :white_check_mark: |
| net8.0-android | :x: |
| net8.0-ios | :x: |

The following table shows the Runtimes Identifiers that are already implemented and tested ( :white_check_mark: ) and the ones that are planned for next versions ( :x: ):

Expand Down
6 changes: 3 additions & 3 deletions Sources/OpenDDSharp.BuildTasks/OpenDDSharp.BuildTasks.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0;net7.0;</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net6.0;net7.0;net8.0;</TargetFrameworks>
<Nullable>disable</Nullable>
<LangVersion>latest</LangVersion>
<CodeAnalysisRuleSet>..\..\OpenDDSharpRules.ruleset</CodeAnalysisRuleSet>
Expand All @@ -10,8 +10,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Build.Framework" Version="17.7.2" />
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="17.7.2" />
<PackageReference Include="Microsoft.Build.Framework" Version="17.8.3" />
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="17.8.3" />

<!-- Analyzer API for our custom checks. -->
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.7.0">
Expand Down
Loading

0 comments on commit a810e11

Please sign in to comment.