Commit d688fb9 1 parent 0d2a146 commit d688fb9 Copy full SHA for d688fb9
File tree 5 files changed +95
-2
lines changed
csharp/PhoneNumbers.PerformanceTest
5 files changed +95
-2
lines changed Original file line number Diff line number Diff line change
1
+ name : build_and_run_unit_tests_windows
2
+
3
+ on :
4
+ push :
5
+ branches : [ "main" ]
6
+ pull_request :
7
+ branches : [ "main" ]
8
+ workflow_dispatch :
9
+
10
+ jobs :
11
+ build_and_run_unit_tests_windows :
12
+ runs-on : windows-latest
13
+ timeout-minutes : 20
14
+ steps :
15
+ - uses : actions/checkout@v4
16
+ - name : Setup .NET
17
+ uses : actions/setup-dotnet@v4
18
+ with :
19
+ dotnet-version : 8.x
20
+ - name : Run performance tests
21
+ run : dotnet run -c Release --framework net8.0
22
+ working-directory : ./csharp/PhoneNumbers.PerformanceTest
Original file line number Diff line number Diff line change @@ -129,7 +129,7 @@ publish/
129
129
# Publish Web Output
130
130
* . [Pp ]ublish.xml
131
131
* .azurePubxml
132
- # TODO: Comment the next line if you want to checkin your web deploy settings
132
+ # TODO: Comment the next line if you want to checkin your web deploy settings
133
133
# but database connection strings (with potential passwords) will be unencrypted
134
134
* .pubxml
135
135
* .publishproj
@@ -201,4 +201,7 @@ FakesAssemblies/
201
201
202
202
# Zipped Geocoding Data
203
203
geocoding.zip
204
- testgeocoding.zip
204
+ testgeocoding.zip
205
+
206
+ # Performance tests artifacts
207
+ csharp /PhoneNumbers.PerformanceTest /BenchmarkDotNet.Artifacts /
Original file line number Diff line number Diff line change
1
+ using BenchmarkDotNet . Attributes ;
2
+ using BenchmarkDotNet . Jobs ;
3
+
4
+ namespace PhoneNumbers . PerformanceTest
5
+ {
6
+ [ MemoryDiagnoser ]
7
+ [ SimpleJob ( RuntimeMoniker . Net48 ) ]
8
+ [ SimpleJob ( RuntimeMoniker . Net60 ) ]
9
+ [ SimpleJob ( RuntimeMoniker . Net70 ) ]
10
+ [ SimpleJob ( RuntimeMoniker . Net80 ) ]
11
+ public class PhoneNumberFormatBenchmark
12
+ {
13
+ private PhoneNumberUtil phoneNumberUtil ;
14
+ private PhoneNumber phoneNumber ;
15
+
16
+ [ GlobalSetup ]
17
+ public void Setup ( )
18
+ {
19
+ phoneNumberUtil = PhoneNumberUtil . GetInstance ( ) ;
20
+ phoneNumber = phoneNumberUtil . Parse ( "+14156667777" , "US" ) ;
21
+ }
22
+
23
+ [ Benchmark ]
24
+ public void FormatPhoneNumber ( )
25
+ {
26
+ phoneNumberUtil . Format ( phoneNumber , PhoneNumberFormat . INTERNATIONAL ) ;
27
+ }
28
+ }
29
+ }
30
+
31
+
Original file line number Diff line number Diff line change
1
+ <Project Sdk =" Microsoft.NET.Sdk" >
2
+
3
+ <PropertyGroup >
4
+ <OutputType >Exe</OutputType >
5
+ <TargetFrameworks >netframework4.8;net6.0;net7.0;net8.0</TargetFrameworks >
6
+ <ImplicitUsings >disable</ImplicitUsings >
7
+ </PropertyGroup >
8
+
9
+ <PropertyGroup Condition =" '$(TargetFramework)' == 'net6.0' Or '$(TargetFramework)' == 'net7.0' Or '$(TargetFramework)' == 'net8.0'" >
10
+ <Nullable >enable</Nullable >
11
+ </PropertyGroup >
12
+
13
+ <ItemGroup >
14
+ <PackageReference Include =" BenchmarkDotNet" Version =" 0.13.12" />
15
+ </ItemGroup >
16
+
17
+ <ItemGroup Condition =" '$(TargetFramework)' == 'net48' " >
18
+ <PackageReference Include =" System.Memory" Version =" 4.5.4" />
19
+ </ItemGroup >
20
+
21
+ <ItemGroup >
22
+ <ProjectReference Include =" ..\PhoneNumbers\PhoneNumbers.csproj" />
23
+ </ItemGroup >
24
+
25
+ </Project >
Original file line number Diff line number Diff line change
1
+ using BenchmarkDotNet . Running ;
2
+
3
+ namespace PhoneNumbers . PerformanceTest
4
+ {
5
+ public class Program
6
+ {
7
+ public static void Main ( string [ ] args )
8
+ {
9
+ var summary = BenchmarkRunner . Run < PhoneNumberFormatBenchmark > ( ) ;
10
+ }
11
+ }
12
+ }
You can’t perform that action at this time.
0 commit comments