You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-dev@logging.apache.org by "Ron Grabowski (JIRA)" <ji...@apache.org> on 2008/05/01 04:00:55 UTC

[jira] Created: (LOG4NET-151) Cache DateTime.Now values when creating LoggingEvent when Environment.TickCount has not changed

Cache DateTime.Now values when creating LoggingEvent when Environment.TickCount has not changed
-----------------------------------------------------------------------------------------------

                 Key: LOG4NET-151
                 URL: https://issues.apache.org/jira/browse/LOG4NET-151
             Project: Log4net
          Issue Type: Improvement
            Reporter: Ron Grabowski
            Assignee: Ron Grabowski
            Priority: Minor
             Fix For: 1.2.11


When creating a lot of logging events in tight loop, DateTime.Now is called for each new LoggingEvent even if several LoggingEvents are created within the same millisecond. We can reuse the same DateTime object because DateTime objects only track time down to the millisecond:

// inspired by nlog
int ticks = Environment.TickCount;
if (ticks != cachedTicks)
{
 cachedTicks = ticks;
 cachedDateTime = DateTime.Now;
}
return cachedDateTime;

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (LOG4NET-151) Cache DateTime.Now values when creating LoggingEvent when Environment.TickCount has not changed

Posted by "Ron Grabowski (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LOG4NET-151?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ron Grabowski updated LOG4NET-151:
----------------------------------

    Affects Version/s: 1.2.10

> Cache DateTime.Now values when creating LoggingEvent when Environment.TickCount has not changed
> -----------------------------------------------------------------------------------------------
>
>                 Key: LOG4NET-151
>                 URL: https://issues.apache.org/jira/browse/LOG4NET-151
>             Project: Log4net
>          Issue Type: Improvement
>    Affects Versions: 1.2.10
>            Reporter: Ron Grabowski
>            Assignee: Ron Grabowski
>            Priority: Minor
>             Fix For: 1.2.11
>
>
> When creating a lot of logging events in tight loop, DateTime.Now is called for each new LoggingEvent even if several LoggingEvents are created within the same millisecond. We can reuse the same DateTime object because DateTime objects only track time down to the millisecond:
> // inspired by nlog
> int ticks = Environment.TickCount;
> if (ticks != cachedTicks)
> {
>  cachedTicks = ticks;
>  cachedDateTime = DateTime.Now;
> }
> return cachedDateTime;

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.