Shawn M Moore > Text-Quantize-0.04 > Text::Quantize

Download:
Text-Quantize-0.04.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Source   Latest Release: Text-Quantize-0.05

NAME ^

Text::Quantize - render a list of numbers as a textual chart

VERSION ^

version 0.04

SYNOPSIS ^

    use Text::Quantize;
    
    print quantize([26, 24, 51, 77, 21]);
    
    __END__
    
     value  ------------- Distribution ------------- count
         8 |                                         0
        16 |@@@@@@@@@@@@@@@@@@@@@@@@                 3
        32 |@@@@@@@@                                 1
        64 |@@@@@@@@                                 1
       128 |                                         0

FUSSY SYNOPSIS ^

    use Text::Quantize ();

    print Text::Quantize::quantize([map { chomp; $_ } <DATA>], {
        left_label             => 'microseconds',
        middle_label           => 'Calls per time bucket',
        right_label            => 'syscalls',
        distribution_width     => 80,
        distribution_character => '=',
    });
    
    __END__
    
     microseconds  ---------------------------- Calls per time bucket ----------------------------- syscalls
              256 |                                                                                 0
              512 |====                                                                             5
             1024 |=====                                                                            7
             2048 |==================                                                               23
             4096 |============================                                                     36
             8192 |=======                                                                          9
            16384 |=                                                                                2
            32768 |                                                                                 1
           262144 |                                                                                 1
           524288 |                                                                                 1
          1048576 |                                                                                 1
          2097152 |=======                                                                          9
          4194304 |===                                                                              4
          8388608 |                                                                                 1
         16777216 |                                                                                 0

FUNCTIONS ^

quantize([integers], {options})

quantize takes an array reference of integers and an optional hash reference of options, and produces a textual histogram of the integers bucketed into powers-of-2 sets.

Options include:

left_label (default: value)

Controls the text of the left-most label which represents the bucket's contents.

middle_label (default: Distribution)

Controls the text of the middle label which can be used to title the histogram.

right_label (default: count)

Controls the text of the right-most label which represents how many items are in that bucket.

distribution_width (default: 40)

Controls how many characters wide the textual histogram is. This does not include the legends.

distribution_character (default: @)

Controls the character used to represent the data in the histogram.

add_endpoints (default: 1)

Controls whether the top and bottom lines (which are going to have values of 0) are added. They're included by default because it hints that the data set is complete.

bucketize([integers], {options})

bucketize takes an array reference of integers and an optional hash reference of options, and produces a hash reference of those integers bucketed into powers-of-2 sets.

Options include:

add_endpoints (default: 1)

Controls whether extra buckets, smaller than the minimum value and larger than the maximum value, (which are going to have values of 0) are added. They're included by default because it hints that the data set is complete.

SEE ALSO ^

DTrace, which is where I first saw this kind of quantize() histogram.

dip, which ported quantize() to Perl first, and from which I took a few insights.

AUTHOR ^

Shawn M Moore <code@sartak.org>

COPYRIGHT AND LICENSE ^

This software is copyright (c) 2012 by Infinity Interactive.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

syntax highlighting: