Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

While your version took 12 seconds for 16MB on my system:

C:\test>dir 1123355.bin 14/04/2015 16:50 16,777,216 1123355.bin C:\test>1159245 1123355.bin Took 12.897612 secs

(That was the third run so the cache was primed.)

This version took:

C:\test>1159245 1123355.bin Took 3.832763 secs : 3762666 ☺ : 46120 ☻ : 43642 ♥ : 44106 ♦ : 43878 ...

The code;

#! perl -slw use strict; use Time::HiRes qw[ time ]; my $start = time; open I, '<:raw', $ARGV[ 0 ]; my @seen; while( read( I, my $buf, 16384 ) ) { ++$seen[$_] for unpack 'C*', $buf; } printf "Took %f secs\n", time() - $start; printf "%c : %u\n", $_, $seen[$_] for 0 .. 255;

In reply to Re: Count byte/character occurrence (1/4) by BrowserUk
in thread Count byte/character occurrence (quickly) by james28909

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (6)
As of 2024-04-20 00:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found