Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 93802ae

Browse files
author
aimenux
committed
Add LibFour based on protobuf
1 parent ec76b35 commit 93802ae

34 files changed

+236
-34
lines changed

‎App/App.csproj‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
</ItemGroup>
1111

1212
<ItemGroup>
13-
<ProjectReference Include="..\Libs\LibOne1円-LibOne.csproj" />
14-
<ProjectReference Include="..\Libs\LibThree3円-LibThree.csproj" />
15-
<ProjectReference Include="..\Libs\LibTwo2円-LibTwo.csproj" />
13+
<ProjectReference Include="..\Libs1円-LibOne1円-LibOne.csproj" />
14+
<ProjectReference Include="..\Libs2円-LibTwo2円-LibTwo.csproj" />
15+
<ProjectReference Include="..\Libs3円-LibThree3円-LibThree.csproj" />
16+
<ProjectReference Include="..\Libs4円-LibFour4円-LibFour.csproj" />
1617
</ItemGroup>
1718

1819
</Project>

‎App/Benchmarks/BenchCategory.cs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ public enum BenchCategory
44
{
55
BinaryFormatter,
66
BinarySerializer,
7-
GroBuf
7+
GroBuf,
8+
ProtoBuf
89
}
910
}

‎App/Benchmarks/BinarySerializationBench.cs‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
using App.Helpers;
22
using BenchmarkDotNet.Attributes;
3+
using LibFour;
34
using LibOne;
45
using LibTwo;
56
using LibThree;
67
using EmployeeOne = LibOne.Models.Employee;
78
using EmployeeTwo = LibTwo.Models.Employee;
89
using EmployeeThree = LibThree.Models.Employee;
10+
using EmployeeFour = LibFour.Models.Employee;
911

1012
namespace App.Benchmarks
1113
{
@@ -15,10 +17,12 @@ public class BinarySerializationBench
1517
private static readonly LibOneBinarySerializer SerializerOne = new ();
1618
private static readonly LibTwoBinarySerializer SerializerTwo = new ();
1719
private static readonly LibThreeBinarySerializer SerializerThree = new ();
20+
private static readonly LibFourBinarySerializer SerializerFour = new ();
1821

1922
public EmployeeOne EmployeeOne { get; private set; }
2023
public EmployeeTwo EmployeeTwo { get; private set; }
2124
public EmployeeThree EmployeeThree { get; private set; }
25+
public EmployeeFour EmployeeFour { get; private set; }
2226

2327
[Params(16, 32, 64, 128, 256)]
2428
public int Length { get; set; }
@@ -29,6 +33,7 @@ public void Setup()
2933
EmployeeOne = RandomHelper.RandomEmployeeOne(Length);
3034
EmployeeTwo = RandomHelper.RandomEmployeeTwo(Length);
3135
EmployeeThree = RandomHelper.RandomEmployeeThree(Length);
36+
EmployeeFour = RandomHelper.RandomEmployeeFour(Length);
3237
}
3338

3439
[Benchmark]
@@ -54,5 +59,13 @@ public EmployeeThree SerializeAndDeserializeThree()
5459
using var stream = SerializerThree.Serialize(EmployeeThree);
5560
return SerializerThree.Deserialize<EmployeeThree>(stream);
5661
}
62+
63+
[Benchmark]
64+
[BenchmarkCategory(nameof(BenchCategory.ProtoBuf))]
65+
public EmployeeFour SerializeAndDeserializeFour()
66+
{
67+
using var stream = SerializerFour.Serialize(EmployeeFour);
68+
return SerializerFour.Deserialize<EmployeeFour>(stream);
69+
}
5770
}
5871
}

‎App/Helpers/RandomHelper.cs‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using EmployeeOne = LibOne.Models.Employee;
44
using EmployeeTwo = LibTwo.Models.Employee;
55
using EmployeeThree = LibThree.Models.Employee;
6+
using EmployeeFour = LibFour.Models.Employee;
67

78
namespace App.Helpers
89
{
@@ -55,6 +56,21 @@ public static EmployeeThree RandomEmployeeThree(int length)
5556
};
5657
}
5758

59+
public static EmployeeFour RandomEmployeeFour(int length)
60+
{
61+
return new()
62+
{
63+
FirstName = RandomString(length),
64+
LastName = RandomString(length),
65+
Title = RandomString(length),
66+
Address = new LibFour.Models.Address
67+
{
68+
City = RandomString(length),
69+
Country = RandomString(length)
70+
}
71+
};
72+
}
73+
5874
private static string RandomString(int length)
5975
{
6076
const string chars = @"ABCDEFGHIJKLMNOPQRSTUVWXYZ";

‎BinarySerializationBenchDemo.sln‎

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,31 @@ VisualStudioVersion = 16.0.31515.178
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "App", "App\App.csproj", "{4C899376-9F35-402F-A883-4D40CA9924E9}"
77
EndProject
8-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "1-LibOne", "Libs\LibOne1円-LibOne.csproj", "{3C865B64-575D-4595-AD5D-FC2ABEDCF6E9}"
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "1-LibOne", "Libs\1-LibOne1円-LibOne.csproj", "{3C865B64-575D-4595-AD5D-FC2ABEDCF6E9}"
99
EndProject
10-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "2-LibTwo", "Libs\LibTwo2円-LibTwo.csproj", "{BA3F38B1-1A27-4313-8F96-67067AA0FCCB}"
10+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "2-LibTwo", "Libs\2-LibTwo2円-LibTwo.csproj", "{BA3F38B1-1A27-4313-8F96-67067AA0FCCB}"
1111
EndProject
12-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "1-LibOneTests", "Tests\LibOneTests1円-LibOneTests.csproj", "{1F56F913-C950-4B10-987C-80FF63DDF80F}"
12+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "1-LibOneTests", "Tests\1-LibOneTests1円-LibOneTests.csproj", "{1F56F913-C950-4B10-987C-80FF63DDF80F}"
1313
EndProject
1414
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{B8CC92F3-BD6F-4488-8F21-0E5EB082E86F}"
1515
EndProject
16-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "2-LibTwoTests", "Tests\LibTwoTests2円-LibTwoTests.csproj", "{AAA9CD12-64BB-4BB1-B6BC-BC32FD067148}"
16+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "2-LibTwoTests", "Tests\2-LibTwoTests2円-LibTwoTests.csproj", "{AAA9CD12-64BB-4BB1-B6BC-BC32FD067148}"
1717
EndProject
1818
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{007DEE4C-2CC4-43D4-B519-0493D99EFC5A}"
1919
ProjectSection(SolutionItems) = preProject
2020
.github\workflows\ci.yml = .github\workflows\ci.yml
2121
README.md = README.md
2222
EndProjectSection
2323
EndProject
24-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "3-LibThree", "Libs\LibThree3円-LibThree.csproj", "{6EB3FD24-4027-41E1-900E-B0E49BBC273A}"
24+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "3-LibThree", "Libs\3-LibThree3円-LibThree.csproj", "{6EB3FD24-4027-41E1-900E-B0E49BBC273A}"
2525
EndProject
2626
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Libs", "Libs", "{6B439BE7-FEB9-4BD4-9472-DC55E6579E40}"
2727
EndProject
28-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "3-LibThreeTests", "Tests\LibThreeTests3円-LibThreeTests.csproj", "{82C6F832-39ED-4923-B199-737A0B0D4168}"
28+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "3-LibThreeTests", "Tests3円-LibThreeTests3円-LibThreeTests.csproj", "{82C6F832-39ED-4923-B199-737A0B0D4168}"
29+
EndProject
30+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "4-LibFour", "Libs4円-LibFour4円-LibFour.csproj", "{0FE23361-FCD3-4647-856D-783045F33083}"
31+
EndProject
32+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "4-LibFourTests", "Tests4円-LibFourTests4円-LibFourTests.csproj", "{9282ABC7-6339-4A73-9092-683608C5702A}"
2933
EndProject
3034
Global
3135
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -61,6 +65,14 @@ Global
6165
{82C6F832-39ED-4923-B199-737A0B0D4168}.Debug|Any CPU.Build.0 = Debug|Any CPU
6266
{82C6F832-39ED-4923-B199-737A0B0D4168}.Release|Any CPU.ActiveCfg = Release|Any CPU
6367
{82C6F832-39ED-4923-B199-737A0B0D4168}.Release|Any CPU.Build.0 = Release|Any CPU
68+
{0FE23361-FCD3-4647-856D-783045F33083}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
69+
{0FE23361-FCD3-4647-856D-783045F33083}.Debug|Any CPU.Build.0 = Debug|Any CPU
70+
{0FE23361-FCD3-4647-856D-783045F33083}.Release|Any CPU.ActiveCfg = Release|Any CPU
71+
{0FE23361-FCD3-4647-856D-783045F33083}.Release|Any CPU.Build.0 = Release|Any CPU
72+
{9282ABC7-6339-4A73-9092-683608C5702A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
73+
{9282ABC7-6339-4A73-9092-683608C5702A}.Debug|Any CPU.Build.0 = Debug|Any CPU
74+
{9282ABC7-6339-4A73-9092-683608C5702A}.Release|Any CPU.ActiveCfg = Release|Any CPU
75+
{9282ABC7-6339-4A73-9092-683608C5702A}.Release|Any CPU.Build.0 = Release|Any CPU
6476
EndGlobalSection
6577
GlobalSection(SolutionProperties) = preSolution
6678
HideSolutionNode = FALSE
@@ -72,6 +84,8 @@ Global
7284
{AAA9CD12-64BB-4BB1-B6BC-BC32FD067148} = {B8CC92F3-BD6F-4488-8F21-0E5EB082E86F}
7385
{6EB3FD24-4027-41E1-900E-B0E49BBC273A} = {6B439BE7-FEB9-4BD4-9472-DC55E6579E40}
7486
{82C6F832-39ED-4923-B199-737A0B0D4168} = {B8CC92F3-BD6F-4488-8F21-0E5EB082E86F}
87+
{0FE23361-FCD3-4647-856D-783045F33083} = {6B439BE7-FEB9-4BD4-9472-DC55E6579E40}
88+
{9282ABC7-6339-4A73-9092-683608C5702A} = {B8CC92F3-BD6F-4488-8F21-0E5EB082E86F}
7589
EndGlobalSection
7690
GlobalSection(ExtensibilityGlobals) = postSolution
7791
SolutionGuid = {2FF41457-09E2-4EF0-9B00-4C765FF973B6}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /