How slow? The following shows that it takes an average of 0.7/1000th of a second to dedup a 4k line:

#! perl -slw use 5.010; use strict; use Time::HiRes qw[ time ];; sub uniq{ my %uniq; undef @uniq{ @_ }; keys %uniq } my @lines; for ( 1 .. 1e3 ) { my $line = int( rand 1e6 ); $line .= chr(9) . int( rand 1e6 ) while length( $line ) < 4096; push @lines, $line; } my $start = time; $_ = join chr(9), uniq( split chr(9), $_ ) for @lines; my $stop = time; printf "On random 4k lines, uniquing averaged %.6f seconds/line\n", ($stop - $start) / 1e3; __END__ c:\test>junk On random 4k lines, uniquing averaged 0.000695 seconds/line c:\test>junk On random 4k lines, uniquing averaged 0.000696 seconds/line c:\test>junk On random 4k lines, uniquing averaged 0.000712 seconds/line c:\test>junk On random 4k lines, uniquing averaged 0.000700 seconds/line

Which means processing your 3e6 lines should take around 35 minutes (plus a bit for the file processing).

So how fast do you want it to run? Or more likely, what are you doing in your full code that is slowing things down?


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

In reply to Re: searching for unique numbers into a string by BrowserUk
in thread searching for unique numbers into a string by marcelpreda

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.