From: Brian Drummond <brian@shapes.demon.co.uk>
Subject: Re: highest bit, statically determined
Date: Tue, 2 Oct 2012 11:03:22 +0000 (UTC)
Date: 2012-10-02T11:03:22+00:00 [thread overview]
Message-ID: <k4ehlq$51p$1@dont-email.me> (raw)
In-Reply-To: 506a0b6f$0$9525$9b4e6d93@newsspool1.arcor-online.net
On Mon, 01 Oct 2012 23:30:24 +0200, Georg Bauhaus wrote:
> On 01.10.12 10:52, Anatoly Chernyshev wrote:
>> (0|1=>0,2|3=>1,4..7=>2, 8..15=>3, 16..31=>4,32..63=>5, 64..127=>6,
>> 128..255=>7);
>
> 68580000 2.653934000 68580000 2.021029000 68580000 27.702262000
> 68580000 1.173348000 -- first_1_bit_table
>
> I guess the approaches can be used together for larger N-tets.
Just for completeness,
function first_bit_case(N:Octet) return natural is
begin
case N is
when 0 => return 0;
when 1 => return 1;
when 2..3 => return 2;
when 4..7 => return 3;
when 8..15 => return 4;
when 16..31 => return 5;
when 32..63 => return 6;
when 64..127 => return 7;
when others => return 8;
end case;
end first_bit_case;
Here (on an Atom netbook) it measures about the same as the equivalent if
chain; faster than the recursive versions but slower than the table.
--Z := Z + first_1_bit_ifchain(Data(i)); -- real 0m3.208s
--Z := Z + first_bit_table(Data(i)); -- real 0m1.971s
--Z := Z + first_1_bit(Data(i)); -- real 0m4.672s
--Z := Z + First_1_Bit_A(Data(i)); -- real 0m3.937s
Z := Z + first_bit_case(Data(i)); -- real 0m3.272s
The Ada-2012 case expression was no faster.
- Brian
next prev parent reply other threads:[~2012-10-02 11:03 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-29 17:34 highest bit, statically determined Georg Bauhaus
2012-09-29 18:11 ` Pascal Obry
2012-09-29 18:59 ` Georg Bauhaus
2012-09-29 19:18 ` Georg Bauhaus
2012-09-29 18:57 ` Bill Findlay
2012-09-29 19:16 ` Bill Findlay
2012-09-29 21:36 ` Georg Bauhaus
2012-09-29 22:06 ` Georg Bauhaus
2012-09-29 23:38 ` Bill Findlay
2012-09-30 15:01 ` Vadim Godunko
2012-11-04 20:45 ` Yannick Duchêne (Hibou57)
2012-11-04 22:00 ` Bill Findlay
2012-09-30 15:39 ` Anatoly Chernyshev
2012-09-30 18:36 ` Shark8
2012-10-01 8:07 ` Georg Bauhaus
2012-10-01 8:11 ` Georg Bauhaus
2012-10-01 8:52 ` Anatoly Chernyshev
2012-10-01 21:30 ` Georg Bauhaus
2012-10-01 22:55 ` Shark8
2012-10-01 23:25 ` Georg Bauhaus
2012-10-02 11:03 ` Brian Drummond [this message]
2012-10-03 9:30 ` kalvink65
2012-10-03 18:54 ` Georg Bauhaus
2012-10-04 7:46 ` Georg Bauhaus
2012-10-04 8:25 ` Stephen Leake
2012-10-04 10:01 ` kalvin.news
2012-10-05 7:50 ` Anatoly Chernyshev
2012-10-05 8:38 ` Anatoly Chernyshev
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox