Skip to content

Commit fcc0762

Browse files
committed
readme 以及速度测试
1 parent 0729d42 commit fcc0762

8 files changed

Lines changed: 1459 additions & 6 deletions

File tree

EleCho.Json/EleCho.Json.csproj

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,17 @@
33
<PropertyGroup>
44
<TargetFrameworks>netstandard2.1;net46;net47;net48;net5.0;net6.0</TargetFrameworks>
55
<LangVersion>latest</LangVersion>
6-
<Nullable>enable</Nullable>
6+
<Nullable>enable</Nullable>
7+
<Description>Easy, Simple, Fast JSON reader and writer.</Description>
8+
<PackageReadmeFile>readme.md</PackageReadmeFile>
9+
<PackageLicenseExpression>GPL-3.0-or-later</PackageLicenseExpression>
710
</PropertyGroup>
811

12+
<ItemGroup>
13+
<None Include="..\readme.md">
14+
<Pack>True</Pack>
15+
<PackagePath>\</PackagePath>
16+
</None>
17+
</ItemGroup>
18+
919
</Project>

EleCho.Json/license.txt

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

TestConsole/Program.cs

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Drawing;
55
using System.IO;
66
using EleCho.Json;
7+
using Newtonsoft.Json.Linq;
78

89
namespace TestConsole
910
{
@@ -36,9 +37,37 @@ static void Main(string[] args)
3637
}
3738
}));
3839

39-
JsonObject jobj = new JsonObject();
40-
string someV = jobj["some_key"] as JsonString;
41-
40+
Stopwatch stopwatch = new Stopwatch();
41+
42+
Console.Write("\n\n\n\n\n");
43+
Console.WriteLine("SpeedTest:");
44+
45+
stopwatch.Start();
46+
for (int i = 0; i < 1000; i++)
47+
{
48+
_ = JsonSerializer.Deserialize(jsonToRead);
49+
}
50+
stopwatch.Stop();
51+
Console.WriteLine("EleCho.Json > JsonSerializer.Deserialize: " + stopwatch.ElapsedMilliseconds + "ms");
52+
53+
stopwatch.Reset();
54+
stopwatch.Start();
55+
for (int i = 0; i < 1000; i++)
56+
{
57+
_ = System.Text.Json.JsonDocument.Parse(jsonToRead);
58+
}
59+
stopwatch.Stop();
60+
Console.WriteLine("System.Text.Json > JsonDocument.Parse: " + stopwatch.ElapsedMilliseconds + "ms");
61+
62+
stopwatch.Reset();
63+
stopwatch.Start();
64+
for (int i = 0; i < 1000; i++)
65+
{
66+
_ = JObject.Parse(jsonToRead);
67+
}
68+
stopwatch.Stop();
69+
Console.WriteLine("Newtonsoft.Json > JObject.Parse: " + stopwatch.ElapsedMilliseconds + "ms");
70+
4271
Console.ReadLine();
4372
}
4473
}

TestConsole/TestConsole.csproj

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
<FileAlignment>512</FileAlignment>
1313
<Deterministic>true</Deterministic>
1414
<TargetFrameworkProfile />
15+
<NuGetPackageImportStamp>
16+
</NuGetPackageImportStamp>
1517
</PropertyGroup>
1618
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1719
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -35,9 +37,40 @@
3537
<Prefer32Bit>false</Prefer32Bit>
3638
</PropertyGroup>
3739
<ItemGroup>
40+
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
41+
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.6.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
42+
</Reference>
43+
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
44+
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
45+
</Reference>
3846
<Reference Include="System" />
47+
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
48+
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
49+
</Reference>
3950
<Reference Include="System.Core" />
4051
<Reference Include="System.Drawing" />
52+
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
53+
<HintPath>..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll</HintPath>
54+
</Reference>
55+
<Reference Include="System.Numerics" />
56+
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
57+
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
58+
</Reference>
59+
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
60+
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
61+
</Reference>
62+
<Reference Include="System.Text.Encodings.Web, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
63+
<HintPath>..\packages\System.Text.Encodings.Web.6.0.0\lib\net461\System.Text.Encodings.Web.dll</HintPath>
64+
</Reference>
65+
<Reference Include="System.Text.Json, Version=6.0.0.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
66+
<HintPath>..\packages\System.Text.Json.6.0.2\lib\net461\System.Text.Json.dll</HintPath>
67+
</Reference>
68+
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
69+
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
70+
</Reference>
71+
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
72+
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath>
73+
</Reference>
4174
<Reference Include="System.Xml.Linq" />
4275
<Reference Include="System.Data.DataSetExtensions" />
4376
<Reference Include="Microsoft.CSharp" />
@@ -62,6 +95,7 @@
6295
</ItemGroup>
6396
<ItemGroup>
6497
<None Include="app.config" />
98+
<None Include="packages.config" />
6599
<None Include="Resources\j1.json" />
66100
<None Include="Resources\j2.json" />
67101
</ItemGroup>
@@ -72,4 +106,11 @@
72106
</ProjectReference>
73107
</ItemGroup>
74108
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
109+
<Import Project="..\packages\System.Text.Json.6.0.2\build\System.Text.Json.targets" Condition="Exists('..\packages\System.Text.Json.6.0.2\build\System.Text.Json.targets')" />
110+
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
111+
<PropertyGroup>
112+
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
113+
</PropertyGroup>
114+
<Error Condition="!Exists('..\packages\System.Text.Json.6.0.2\build\System.Text.Json.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\System.Text.Json.6.0.2\build\System.Text.Json.targets'))" />
115+
</Target>
75116
</Project>

TestConsole/app.config

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
3-
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/></startup></configuration>
3+
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" /></startup>
4+
<runtime>
5+
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
6+
<dependentAssembly>
7+
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
8+
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
9+
</dependentAssembly>
10+
</assemblyBinding>
11+
</runtime>
12+
</configuration>

TestConsole/packages.config

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="Microsoft.Bcl.AsyncInterfaces" version="6.0.0" targetFramework="net48" />
4+
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net48" />
5+
<package id="System.Buffers" version="4.5.1" targetFramework="net48" />
6+
<package id="System.Memory" version="4.5.4" targetFramework="net48" />
7+
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net48" />
8+
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net48" />
9+
<package id="System.Text.Encodings.Web" version="6.0.0" targetFramework="net48" />
10+
<package id="System.Text.Json" version="6.0.2" targetFramework="net48" />
11+
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net48" />
12+
<package id="System.ValueTuple" version="4.5.0" targetFramework="net48" />
13+
</packages>

0 commit comments

Comments
 (0)