Skip to content
This repository has been archived by the owner on Jun 8, 2019. It is now read-only.

Commit

Permalink
* Added ${gc} which can be used to get the GC statistics (very limited)
Browse files Browse the repository at this point in the history
	* Added ${processinfo} which can be used to extract the performance
	information about the current process (possibly others in the future as
	well)
	* Added ${gc} which can be used to get the GC statistics (very limited)
	* Added Initialize() and Close() to the LayoutRender class
	* Added optimized CurrentTimeGetter which is way faster than DateTime.Now
	* New NLog.Benchmark that uses code generation and compilation to
	create more "clean" environment.
	* Some small optimizations
  • Loading branch information
jkowalski committed Jul 22, 2006
1 parent f7736f7 commit 3544e88
Show file tree
Hide file tree
Showing 43 changed files with 1,801 additions and 735 deletions.
12 changes: 12 additions & 0 deletions ChangeLog
@@ -1,3 +1,15 @@
2006-07-22 Jaroslaw Kowalski <jaak@jkowalski.net>
* New NLog.Benchmark that uses code generation and compilation to
create more "clean" environment.
* Added ${gc} which can be used to get the GC statistics (very limited)
* Added ${processinfo} which can be used to extract the performance
information about the current process (possibly others in the future as
well)
* Added ${gc} which can be used to get the GC statistics (very limited)
* Added Initialize() and Close() to the LayoutRender class
* Added optimized CurrentTimeGetter which is way faster than DateTime.Now
* Some small optimizations

2006-07-18 Jaroslaw Kowalski <jaak@jkowalski.net>
* Added ImpersonatingWrapper which temporarily changes the credentials
for the duration of the write.
Expand Down
17 changes: 13 additions & 4 deletions NLog.build
Expand Up @@ -338,11 +338,9 @@
</target>

<target name="NLog.Benchmark" depends="NLog">
<exec program="perl" commandline="tests/NLog.Benchmark/unroll_loop.pl tests/NLog.Benchmark/Benchmark.cs tests/NLog.Benchmark/Benchmark.Unrolled.cs ${benchmark.loop.unroll}" />
<csc target="exe" output="${nlog.dir}/NLog.Benchmark.exe" define="${nlog.define};NLOG" debug="${nlog.debug}" optimize="${nlog.optimize}" warninglevel="${csc.warninglevel}">
<sources basedir="tests/NLog.Benchmark">
<include name="**/*.cs" />
<exclude name="Benchmark.cs" />
<include name="*.cs" />
</sources>
<references>
<include name="${nlog.dir}/NLog.dll" />
Expand All @@ -351,7 +349,12 @@
<include name="System.Xml.dll" />
</references>
</csc>
<copy file="tests/NLog.Benchmark/NLog.config" tofile="${nlog.dir}/NLog.Benchmark.exe.config" />
<copy file="tests/NLog.Benchmark/NLog.config" tofile="${nlog.dir}/NLog.config" />
<property name="log4netbinary" value="${log4net.bin.dir}/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}/${if(nlog.debug,'debug','release')}/log4net.dll" />
<if test="${file::exists(log4netbinary)}">
<copy file="${log4netbinary}" tofile="${nlog.dir}/log4net.dll" />
<copy file="tests/NLog.Benchmark/log4net.config" tofile="${nlog.dir}/log4net.config" />
</if>
<exec program="${nlog.dir}/NLog.Benchmark.exe" workingdir="${nlog.dir}" commandline="Benchmark.xml ${benchmark.mode}" useruntimeengine="true" />
</target>

Expand Down Expand Up @@ -788,10 +791,16 @@
<target name="sln">
<call target="clean" />


<property name="oldframework" value="${nant.settings.currentframework}" />

<property name="nant.settings.currentframework" value="net-1.1" failonerror="false" />

<solution configuration="Release" solutionfile="NLog.vs2003.sln" />
<solution configuration="Debug" solutionfile="NLog.vs2003.sln" />
<solution configuration="Release" solutionfile="tests/NLogTests.vs2003.sln" />
<solution configuration="Debug" solutionfile="tests/NLogTests.vs2003.sln" />
<property name="nant.settings.currentframework" value="${oldframework}" failonerror="false" />

<call target="clean" />

Expand Down
143 changes: 119 additions & 24 deletions src/NLog.ComInterop/NLog.ComInterop.vs2003.csproj
@@ -1,25 +1,120 @@
<VisualStudioProject>
<CSHARP ProjectType="Local" ProductVersion="7.10.3077" SchemaVersion="2.0" ProjectGuid="{B3F8E5FB-C9D4-4C12-841F-8009EB60DB3D}">
<Build>
<Settings ApplicationIcon="" AssemblyKeyContainerName="" AssemblyName="NLog.ComInterop" AssemblyOriginatorKeyFile="" DefaultClientScript="JScript" DefaultHTMLPageLayout="Grid" DefaultTargetSchema="IE50" DelaySign="false" OutputType="Library" PreBuildEvent="" PostBuildEvent="" RootNamespace="NLog.ComInterop" RunPostBuildEvent="OnBuildSuccess" StartupObject="">
<Config Name="Debug" AllowUnsafeBlocks="false" BaseAddress="285212672" CheckForOverflowUnderflow="false" ConfigurationOverrideFile="" DefineConstants="DOTNET;DOTNET_1_1" DocumentationFile="NLog.ComInterop.xml" DebugSymbols="true" FileAlignment="4096" IncrementalBuild="false" NoStdLib="false" NoWarn="" Optimize="false" OutputPath="bin\Debug\" RegisterForComInterop="true" RemoveIntegerChecks="false" TreatWarningsAsErrors="false" WarningLevel="4" />
<Config Name="Release" AllowUnsafeBlocks="false" BaseAddress="285212672" CheckForOverflowUnderflow="false" ConfigurationOverrideFile="" DefineConstants="DOTNET;DOTNET_1_1" DocumentationFile="NLog.ComInterop.xml" DebugSymbols="false" FileAlignment="4096" IncrementalBuild="false" NoStdLib="false" NoWarn="" Optimize="false" OutputPath="bin\Release\" RegisterForComInterop="true" RemoveIntegerChecks="false" TreatWarningsAsErrors="false" WarningLevel="1" />
</Settings>
<References>
<Reference Name="System" AssemblyName="System" HintPath="C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.dll" />
<Reference Name="System.XML" AssemblyName="System.Xml" HintPath="C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.XML.dll" />
<Reference Name="NLog" Project="{020354EE-5073-4BB5-9AA2-A7EADA8CAD09}" Package="{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}" />
</References>
</Build>
<Files>
<Include>
<File RelPath="AssemblyInfo.cs" SubType="Code" BuildAction="Compile" />
<File RelPath="AssemblySign.cs" SubType="Code" BuildAction="Compile" />
<File RelPath="ILogger.cs" SubType="Code" BuildAction="Compile" />
<File RelPath="ILogManager.cs" SubType="Code" BuildAction="Compile" />
<File RelPath="Logger.cs" SubType="Code" BuildAction="Compile" />
<File RelPath="LogManager.cs" SubType="Code" BuildAction="Compile" />
</Include>
</Files>
</CSHARP>
</VisualStudioProject>
<CSHARP
ProjectType = "Local"
ProductVersion = "7.10.3077"
SchemaVersion = "2.0"
ProjectGuid = "{B3F8E5FB-C9D4-4C12-841F-8009EB60DB3D}"
>
<Build>
<Settings
ApplicationIcon = ""
AssemblyKeyContainerName = ""
AssemblyName = "NLog.ComInterop"
AssemblyOriginatorKeyFile = ""
DefaultClientScript = "JScript"
DefaultHTMLPageLayout = "Grid"
DefaultTargetSchema = "IE50"
DelaySign = "false"
OutputType = "Library"
PreBuildEvent = ""
PostBuildEvent = ""
RootNamespace = "NLog.ComInterop"
RunPostBuildEvent = "OnBuildSuccess"
StartupObject = ""
>
<Config
Name = "Debug"
AllowUnsafeBlocks = "false"
BaseAddress = "285212672"
CheckForOverflowUnderflow = "false"
ConfigurationOverrideFile = ""
DefineConstants = "DOTNET;DOTNET_1_1"
DocumentationFile = "NLog.ComInterop.xml"
DebugSymbols = "true"
FileAlignment = "4096"
IncrementalBuild = "false"
NoStdLib = "false"
NoWarn = ""
Optimize = "false"
OutputPath = "bin\Debug\"
RegisterForComInterop = "true"
RemoveIntegerChecks = "false"
TreatWarningsAsErrors = "false"
WarningLevel = "4"
/>
<Config
Name = "Release"
AllowUnsafeBlocks = "false"
BaseAddress = "285212672"
CheckForOverflowUnderflow = "false"
ConfigurationOverrideFile = ""
DefineConstants = "DOTNET;DOTNET_1_1"
DocumentationFile = "NLog.ComInterop.xml"
DebugSymbols = "false"
FileAlignment = "4096"
IncrementalBuild = "false"
NoStdLib = "false"
NoWarn = ""
Optimize = "false"
OutputPath = "bin\Release\"
RegisterForComInterop = "true"
RemoveIntegerChecks = "false"
TreatWarningsAsErrors = "false"
WarningLevel = "1"
/>
</Settings>
<References>
<Reference
Name = "System"
AssemblyName = "System"
HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.dll"
/>
<Reference
Name = "System.XML"
AssemblyName = "System.Xml"
HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.XML.dll"
/>
<Reference
Name = "NLog.vs2003"
Project = "{020354EE-5073-4BB5-9AA2-A7EADA8CAD09}"
Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
/>
</References>
</Build>
<Files>
<Include>
<File
RelPath = "AssemblyInfo.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "AssemblySign.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "ILogger.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "ILogManager.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "Logger.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "LogManager.cs"
SubType = "Code"
BuildAction = "Compile"
/>
</Include>
</Files>
</CSHARP>
</VisualStudioProject>

5 changes: 5 additions & 0 deletions src/NLog/ILayout.cs
Expand Up @@ -89,5 +89,10 @@ public interface ILayout
/// Initializes the layout.
/// </summary>
void Initialize();

/// <summary>
/// Closes the layout.
/// </summary>
void Close();
}
}
Expand Up @@ -31,52 +31,58 @@
// THE POSSIBILITY OF SUCH DAMAGE.
//

#if LOG4NET_WITH_FASTLOGGER
using System;
using System.Globalization;
using log4net.Core;
using System.Text;
using System.Reflection;
using System.Collections;

public sealed class FastLogger : LoggerWrapperImpl
using NLog.Config;
using NLog.Internal;
using System.Runtime.InteropServices;

namespace NLog
{
private readonly static Type declaringType = typeof(FastLogger);
public FastLogger(ILogger logger) : base(logger)
internal class CurrentTimeGetter
{
delegate DateTime GetDelegate();

}
private static GetDelegate _getDelegate;

public bool IsDebugEnabled
{
get { return Logger.IsEnabledFor(Level.Debug); }
}

public void Debug(string message)
{
Logger.Log(declaringType, Level.Debug, message, null);
}
public void DebugFormat(string format, params object[] args)
{
if (Logger.IsEnabledFor(Level.Debug))
static CurrentTimeGetter()
{
Logger.Log(declaringType, Level.Debug, String.Format(CultureInfo.InvariantCulture, format, args), null);
// _getDelegate = new GetDelegate(NonOptimizedGet);
_getDelegate = new GetDelegate(ThrottledGet);
}
}

public bool IsInfoEnabled
{
get { return Logger.IsEnabledFor(Level.Info); }
}

public void Info(string message)
{
Logger.Log(declaringType, Level.Info, message, null);
}
public void InfoFormat(string format, params object[] args)
{
if (Logger.IsEnabledFor(Level.Info))

public static DateTime Now
{
get { return _getDelegate(); }
}

private static int _lastTicks = -1;
private static DateTime _lastDateTime = DateTime.MinValue;

static DateTime NonOptimizedGet()
{
Logger.Log(declaringType, Level.Info, String.Format(CultureInfo.InvariantCulture, format, args), null);
return DateTime.Now;
}

static DateTime ThrottledGet()
{
int t = Environment.TickCount;

if (t != _lastTicks)
{
DateTime dt = DateTime.Now;

_lastTicks = t;
_lastDateTime = dt;
return dt;
}
else
{
return _lastDateTime;
}
}
}
}

#endif
4 changes: 2 additions & 2 deletions src/NLog/Internal/FileAppenders/BaseFileAppender.cs
Expand Up @@ -79,7 +79,7 @@ public ICreateFileParameters CreateFileParameters

protected void FileTouched()
{
_lastWriteTime = DateTime.Now;
_lastWriteTime = CurrentTimeGetter.Now;
}

protected void FileTouched(DateTime dt)
Expand All @@ -91,7 +91,7 @@ public BaseFileAppender(string fileName, ICreateFileParameters createParameters)
{
_fileName = fileName;
_createParameters = createParameters;
_openTime = DateTime.Now;
_openTime = CurrentTimeGetter.Now;
_lastWriteTime = DateTime.MinValue;
}

Expand Down
2 changes: 1 addition & 1 deletion src/NLog/Internal/InternalLogger.cs
Expand Up @@ -206,7 +206,7 @@ private static void Write(LogLevel level, IFormatProvider formatProvider, string
formattedMessage = String.Format(formatProvider, message, args);

StringBuilder builder = new StringBuilder(message.Length + 32);
builder.Append(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.ffff", CultureInfo.InvariantCulture));
builder.Append(CurrentTimeGetter.Now.ToString("yyyy-MM-dd HH:mm:ss.ffff", CultureInfo.InvariantCulture));
builder.Append(" ");
builder.Append(level.ToString());
builder.Append(" ");
Expand Down
2 changes: 1 addition & 1 deletion src/NLog/Internal/LogEventInfoBuffer.cs
Expand Up @@ -47,7 +47,7 @@
namespace NLog.Internal
{
/// <summary>
/// A cyclick buffer of <see cref="LogEventInfo"/> object.
/// A cyclic buffer of <see cref="LogEventInfo"/> object.
/// </summary>
public class LogEventInfoBuffer
{
Expand Down

0 comments on commit 3544e88

Please sign in to comment.