This is the mail archive of the
ecos-bugs@sourceware.org
mailing list for the eCos project.
[Bug 1001605] New: much faster and simpler(!) replacement for_simple_mktime() (in wallclock.inl)
- From: bugzilla-daemon at bugs dot ecos dot sourceware dot org
- To: ecos-bugs at ecos dot sourceware dot org
- Date: Fri, 1 Jun 2012 09:56:31 +0100
- Subject: [Bug 1001605] New: much faster and simpler(!) replacement for_simple_mktime() (in wallclock.inl)
- Auto-submitted: auto-generated
Please do not reply to this email. Use the web interface provided at:
http://bugs.ecos.sourceware.org/show_bug.cgi?id=1001605
Summary: much faster and simpler(!) replacement for
_simple_mktime() (in wallclock.inl)
Product: eCos
Version: CVS
Platform: All
OS/Version: All
Status: UNCONFIRMED
Severity: enhancement
Priority: low
Component: Wallclock
AssignedTo: unassigned@bugs.ecos.sourceware.org
ReportedBy: bernard.fouche@kuantic.com
CC: ecos-bugs@ecos.sourceware.org
Class: Advice Request
If _simple_mktime() is called for Dec 31st 2012, it will do:
42 (2012-1970) additions of a value requiring 3 modulo's
+ 12 additions (of the month)
+ 1 substraction
+ 3 multiplications and 3 additions
That is a total of (42*3)+12+1+(3+3)=145 operations.
The proposed change makes _simple_mktime() to use:
- 1 substraction, 1 multiplication, 1 addition and 1 substraction to calculate
a 'base' second value.
- 1 comparison that can lead to 1 substraction
- 1 addition, 1 substraction, 1 division
- 2 substractions, 1 division
- 1 addition, 1 substraction, 1 division
- 1 addition
- 1 substraction
- 1 multiplication
- 1 addition
- 1 multiplication
- 1 addition
- 1 multiplication
- 1 addition
That is a total of:
(1+1+1+1)+(1+1)+(1+1+1)+(2+1)+(1+1+1)+1+1+1+1+1+1+1+1=23 operations.
This count is nearly always the same whatever the time/date processed, which is
not the case for the original code, which takes 3 modulo's more per invocation
each year, since this function is called by all RTC HW drivers.
I don't think eCos runs on MCU/CPU without HW division, but in such a case this
would mean that 2/3rd of the modulo's in the current code are also done in
software (for 100 and 400 values).
I attach an example of the proposed replacement code that compiles under Linux
and uses brute force to check all possible values: it takes about 6 minutes to
run in a recent computer.
If someone can review and accept this small code change, I can make a patch vs
ecos/packages/io/wallclock/current/include/wallclock/wallclock.inl
Bernard
--
Configure bugmail: http://bugs.ecos.sourceware.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.