-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhance the performance of Log API methods
- Loading branch information
1 parent
a40afa5
commit 026d74a
Showing
6 changed files
with
203 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using BenchmarkDotNet.Attributes; | ||
using BenchmarkDotNet.Configs; | ||
using BenchmarkDotNet.Reports; | ||
using BenchmarkDotNet.Running; | ||
using GeneXus.Diagnostics; | ||
using Xunit; | ||
namespace BenchmarkTest | ||
{ | ||
public class LoggerBenchmark | ||
{ | ||
[Params(1000)] | ||
public int N; | ||
const int Debug = 5; | ||
|
||
[Benchmark] | ||
public void Write_PerformanceTest() | ||
{ | ||
for (int i = 0; i < N; i++) | ||
{ | ||
Log.Write("Test Message", "Test Topi", Debug); | ||
} | ||
} | ||
} | ||
|
||
public class PerformanceTests | ||
{ | ||
const double MAX_NANOSECONDS = 150000; | ||
[Fact] | ||
public void RunLoggerBenchmark() | ||
{ | ||
#if DEBUG | ||
var config = DefaultConfig.Instance.WithOptions(ConfigOptions.DisableOptimizationsValidator); | ||
Summary summary = BenchmarkRunner.Run<LoggerBenchmark>(config); | ||
#else | ||
Summary summary = BenchmarkRunner.Run<LoggerBenchmark>(); | ||
#endif | ||
Assert.NotEmpty(summary.Reports); | ||
foreach (BenchmarkReport report in summary.Reports) | ||
{ | ||
Assert.NotEmpty(report.AllMeasurements); | ||
foreach (Measurement runMeasure in report.AllMeasurements) | ||
{ | ||
Assert.InRange(runMeasure.Nanoseconds, low: 0, high: MAX_NANOSECONDS); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>net462</TargetFrameworks> | ||
<IsPackable>false</IsPackable> | ||
<IsTestProject>true</IsTestProject> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="BenchmarkDotNet" Version="0.13.11" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0" /> | ||
<PackageReference Include="xunit" Version="2.4.2" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="coverlet.collector" Version="6.0.0"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\..\src\dotnetcore\GxClasses\GxClasses.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Update="appsettings.json"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
<None Update="log.console.config"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
{ | ||
"appSettings": { | ||
"AppMainNamespace": "GeneXus.Programs", | ||
"DataStore1": "Default", | ||
"DataStore-Count": "1", | ||
"DataStore-Default": "Default", | ||
"Connection-Default-DBMS": "sqlserver", | ||
"Connection-Default-Port": "", | ||
"Connection-Default-LockTimeout": "0", | ||
"Connection-Default-LockRetryCount": "10", | ||
"Connection-Default-IsolationLevel": "CR", | ||
"Connection-Default-Datasource": "", | ||
"Connection-Default-User": "", | ||
"Connection-Default-Password": "", | ||
"Connection-Default-DB": "", | ||
"Connection-Default-Schema": "", | ||
"Connection-Default-Opts": "", | ||
"Connection-Default-TrnInt": "1", | ||
"DateFormat": "MDY", | ||
"YearLimit": "1940", | ||
"TimeAmPmFormat": "12", | ||
"VER_STAMP": "20210602.093942", | ||
"CS_BLOB_PATH": "PublicTempStorage", | ||
"TMPMEDIA_DIR": "PrivateTempStorage", | ||
"PRINT_LAYOUT_METADATA_DIR": "LayoutMetadata", | ||
"StorageTimeZone": "1", | ||
"LOGIN_AS_USERID": "0", | ||
"LANGUAGE": "eng", | ||
"LANG_NAME": "English", | ||
"DECIMAL_POINT": ".", | ||
"DATE_FMT": "MDY", | ||
"CTOD_DATE_FMT": "L", | ||
"Culture": "en-US", | ||
"Theme": "Carmine", | ||
"UseNamedParameters": "1", | ||
"EnableIntegratedSecurity": "0", | ||
"MAX_CURSOR": "100", | ||
"STATIC_CONTENT": "", | ||
"GX_BUILD_NUMBER": "11103481", | ||
"CACHE_CONTENT_EXPIRATION": "36", | ||
"ENABLE_MANAGEMENT": "0", | ||
"COMPRESS_HTML": "1", | ||
"IE_COMPATIBILITY_VIEW": "EmulateIE7", | ||
"DocumentType": "HTML5", | ||
"EXPOSE_METADATA": "0", | ||
"SMART_CACHING": "0", | ||
"wcf:serviceHostingEnvironment:useClassicReadEntityBodyMode": "true", | ||
"HTTP_PROTOCOL": "Unsecure", | ||
"SAMESITE_COOKIE": "Lax", | ||
"CACHE_INVALIDATION_TOKEN": "20216211291931", | ||
"CORS_ALLOW_ORIGIN": "https://normal-website.com", | ||
"MY_CUSTOM_PTY": "DEFAULT_VALUE" | ||
}, | ||
"languages": { | ||
"English": { | ||
"code": "eng", | ||
"culture": "en-US", | ||
"date_fmt": "MDY", | ||
"decimal_point": ".", | ||
"thousand_sep": ",", | ||
"time_fmt": "12" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<log4net> | ||
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender"> | ||
<layout type="log4net.Layout.PatternLayout"> | ||
<conversionPattern value="%d{ISO8601} [%t] %-5p %c - %m%n"/> | ||
</layout> | ||
</appender> | ||
|
||
<appender name="RollingFile" type="log4net.Appender.RollingFileAppender"> | ||
<file value="client.log"/> | ||
<appendToFile value="true"/> | ||
<maximumFileSize value="9000KB"/> | ||
<maxSizeRollBackups value="4"/> | ||
<rollingStyle value="Size"/> | ||
<layout type="log4net.Layout.PatternLayout"> | ||
<conversionPattern value="%d{ISO8601} [%t] %-5p %c - %m%n"/> | ||
</layout> | ||
<lockingModel type="log4net.Appender.FileAppender+ExclusiveLock"/> | ||
</appender> | ||
|
||
<root> | ||
<level value="DEBUG"/> | ||
<appender-ref ref="RollingFile"/> | ||
</root> | ||
<!-- GeneXus Standard Classes Logging !--> | ||
<!-- <logger name="GeneXus" additivity="false"> | ||
<level value="ALL" /> | ||
<appender-ref ref="RollingFile"/> | ||
</logger> !--> | ||
|
||
<!-- User custom Logging !--> | ||
<logger name="GeneXusUserLog" additivity="false"> | ||
<level value="ERROR" /> | ||
<appender-ref ref="RollingFile"/> | ||
</logger> | ||
|
||
|
||
</log4net> |