Thread Über viele(!) Boolesche Werte iterieren: Array oder Bit::Vector oder was? (14 answers)
Opened by flowdy at 2012-08-03 22:56

flowdy
 2012-08-04 18:20
#160625 #160625
User since
2012-08-03
45 articles
BenutzerIn

user image
Stimmt ... dachte ich, aber ...

Code: (dl )
1
2
3
4
5
6
7
8
9
       Rate bitvx bitvm bitvr array strng index slice theor
bitvx 1.45/s -- -15% -20% -22% -37% -43% -64% -71%
bitvm 1.70/s 18% -- -5% -8% -26% -33% -58% -66%
bitvr 1.80/s 25% 6% -- -3% -21% -29% -55% -64%
array 1.85/s 28% 9% 3% -- -19% -27% -54% -63%
strng 2.30/s 59% 35% 27% 24% -- -10% -43% -55%
index 2.55/s 76% 49% 41% 38% 11% -- -37% -50%
slice 4.03/s 178% 136% 124% 118% 76% 58% -- -20%
theor 5.06/s 250% 197% 181% 173% 121% 99% 26% --


Der
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
    # Sparen wir uns die Strukturdaten des Arrays und von 999.999 Skalaren
    # Vorschlag von topeg++, angeglichen. $bit_data-Initialisierung oben.
    strng => sub {
                 my (@cache, $last, $v);
                 for ( my $i = $start; $i <= $end; $i++ ) {
                     $v = substr($str_data,$_,1);
                     if ($v ne $last || $v eq '0') {
                         push @cache, $v eq '1' ? 1 : -1
                     }
                     else { $cache[-1] += $v }
                     $last = $v;
                 }
             },
package MyClass; sub new {\b\b\b\b\b\b\b\b\buse Moose;

View full thread Über viele(!) Boolesche Werte iterieren: Array oder Bit::Vector oder was?