Skip to content

Commit 8f503d2

Browse files
committed
Optimize logging
1 parent f9d4d0f commit 8f503d2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+368
-408
lines changed

Extensions/Xtensive.Orm.Logging.NLog/Log.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2013-2020 Xtensive LLC.
1+
// Copyright (C) 2013-2020 Xtensive LLC.
22
// This code is distributed under MIT license terms.
33
// See the License.txt file in the project root for more information.
44
// Created by: Dmitri Maximov
@@ -40,7 +40,7 @@ public override bool IsLogged(LogLevel level)
4040
}
4141

4242
/// <inheritdoc/>
43-
public override void Write(LogEventInfo info)
43+
public override void Write(in LogEventInfo info)
4444
{
4545
if (info.Exception!=null)
4646
target.Log(ConvertLevel(info.Level), info.Exception, info.FormattedMessage);

Extensions/Xtensive.Orm.Logging.log4net/Log.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2014-2020 Xtensive LLC.
1+
// Copyright (C) 2014-2020 Xtensive LLC.
22
// This code is distributed under MIT license terms.
33
// See the License.txt file in the project root for more information.
44
// Created by: Alexey Kulakov
@@ -43,7 +43,7 @@ public override bool IsLogged(LogLevel level)
4343
}
4444

4545
/// <inheritdoc />
46-
public override void Write(LogEventInfo info)
46+
public override void Write(in LogEventInfo info)
4747
{
4848
target.Logger.Log(target.Logger.GetType(), ConvertLevel(info.Level), info.FormattedMessage, info.Exception);
4949
}

Orm/Xtensive.Orm.Tests.Core/DotNetFramework/NewTupleLogicTest.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,18 @@ public void PeformanceTest()
145145

146146
private void Test(int count)
147147
{
148-
using (warmup ? new Disposable(delegate { }) :
149-
TestLog.InfoRegion("With boxing"))
148+
if (warmup) {
150149
TestTupleAccess(new BoxingTuple(), count);
151-
using (warmup ? new Disposable(delegate { }) :
152-
TestLog.InfoRegion("Without boxing"))
153150
TestTupleAccess(new NonBoxingTuple(), count);
151+
}
152+
else {
153+
using(TestLog.InfoRegion("With boxing")) {
154+
TestTupleAccess(new BoxingTuple(), count);
155+
}
156+
using (TestLog.InfoRegion("Without boxing")) {
157+
TestTupleAccess(new NonBoxingTuple(), count);
158+
}
159+
}
154160
}
155161

156162
private void TestTupleAccess(TestTuple tuple, int count)

Orm/Xtensive.Orm.Tests.Core/DotNetFramework/ThreadingTest.cs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ private void LockTest(double speedFactor, int threadCount)
219219
passCountBase /= 10;
220220

221221
TestHelper.CollectGarbage();
222-
using (warmup ? null : TestLog.InfoRegion(string.Format("{0} threads", threadCount))) {
222+
if (warmup) {
223223
ThreadedTest(target, passCountBase, target.ExecuteLock);
224224
ThreadedTest(target, passCountBase, target.ExecuteReadLock);
225225
ThreadedTest(target, passCountBase, target.ExecuteWriteLock);
@@ -228,6 +228,17 @@ private void LockTest(double speedFactor, int threadCount)
228228
ThreadedTest(target, passCountBase / 400, target.ExecuteSleepLock);
229229
}
230230
}
231+
else {
232+
using (TestLog.InfoRegion(string.Format("{0} threads", threadCount))) {
233+
ThreadedTest(target, passCountBase, target.ExecuteLock);
234+
ThreadedTest(target, passCountBase, target.ExecuteReadLock);
235+
ThreadedTest(target, passCountBase, target.ExecuteWriteLock);
236+
if (threadCount>1) {
237+
ThreadedTest(target, passCountBase / 200, target.ExecuteWaitLock);
238+
ThreadedTest(target, passCountBase / 400, target.ExecuteSleepLock);
239+
}
240+
}
241+
}
231242
}
232243

233244
private void InvokeAsyncTest(double speedFactor, int threadCount)
@@ -240,9 +251,14 @@ private void InvokeAsyncTest(double speedFactor, int threadCount)
240251
passCountBase /= 10;
241252

242253
TestHelper.CollectGarbage();
243-
using (warmup ? null : TestLog.InfoRegion(string.Format("{0} threads", threadCount))) {
254+
if (warmup) {
244255
ThreadedTest(target, passCountBase/100, target.ExecuteInvokeAsync);
245256
}
257+
else {
258+
using (TestLog.InfoRegion(string.Format("{0} threads", threadCount))) {
259+
ThreadedTest(target, passCountBase/100, target.ExecuteInvokeAsync);
260+
}
261+
}
246262
}
247263

248264
private static void ThreadedTest(Target target, int passCount, ParameterizedThreadStart method)

Orm/Xtensive.Orm/Comparison/ComparerProvider.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ protected override TAssociate CreateAssociate<TKey, TAssociate>(out Type foundFo
6666
// the comparer.
6767
var comparer = base.CreateAssociate<TKey, IAdvancedComparerBase>(out foundFor);
6868
if (foundFor == null) {
69-
CoreLog.Warning(Strings.LogCantFindAssociateFor,
69+
CoreLog.Warning(nameof(Strings.LogCantFindAssociateFor),
7070
TypeSuffixes.ToDelimitedString(" \\ "),
7171
typeof(TAssociate).GetShortName(),
7272
typeof(TKey).GetShortName());
@@ -77,15 +77,15 @@ protected override TAssociate CreateAssociate<TKey, TAssociate>(out Type foundFo
7777
}
7878
associate = BaseComparerWrapperType.Activate(new[] { typeof(TKey), foundFor }, ConstructorParams) as TAssociate;
7979
if (associate != null) {
80-
CoreLog.Warning(Strings.LogGenericAssociateIsUsedFor,
80+
CoreLog.Warning(nameof(Strings.LogGenericAssociateIsUsedFor),
8181
BaseComparerWrapperType.GetShortName(),
8282
typeof (TKey).GetShortName(),
8383
foundFor.GetShortName(),
8484
typeof (TKey).GetShortName());
8585
return associate;
8686
}
8787
else {
88-
CoreLog.Warning(Strings.LogGenericAssociateCreationHasFailedFor,
88+
CoreLog.Warning(nameof(Strings.LogGenericAssociateCreationHasFailedFor),
8989
BaseComparerWrapperType.GetShortName(),
9090
typeof (TKey).GetShortName(),
9191
foundFor.GetShortName(),

Orm/Xtensive.Orm/Core/AsyncFutureResult.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public override void Dispose()
5353
Get();
5454
}
5555
catch (Exception exception) {
56-
logger?.Warning(Strings.LogAsyncOperationError, exception: exception);
56+
logger?.Warning(nameof(Strings.LogAsyncOperationError), exception: exception);
5757
}
5858
}
5959

@@ -67,7 +67,7 @@ public override async ValueTask DisposeAsync()
6767
await GetAsync().ConfigureAwait(false);
6868
}
6969
catch (Exception exception) {
70-
logger?.Warning(Strings.LogAsyncOperationError, exception: exception);
70+
logger?.Warning(nameof(Strings.LogAsyncOperationError), exception: exception);
7171
}
7272
}
7373

0 commit comments

Comments
 (0)