Hi all,

I try to create a queue for multithreaded processing of a huge image file.

Here is what i figured out:

#!/usr/bin/env perl use strict; use warnings; use Data::Dump; use Time::HiRes qw(time); # use feature qw(say); my $start = time; my @queue; my @line; # ratio 1.25 - i guess 160 pixel # my $width = 20; # my $height = 8; # my $qsize = 4; # same ratio - i guess 20 MP my $width = 1280 * 4; my $height = 1024 * 4; my $qsize = 32; for my $x ( 0 .. $width - 1 ) { for my $y ( 0 .. $height - 1 ) { my $coords = [ $x, $y ]; push @line, $coords; if ( scalar @line == $width ) { push @queue, [@line]; @line = (); # audacious actions start here if ( scalar @queue == $qsize ) { # dd \@queue; @queue = (); } } } } printf "Took %.3f seconds\n", time - $start; __END__ karls-mac-mini:monks karl$ ./queue.pl Took 13.531 seconds

It looks like it works as designed.

But i can't suppress the vague feeling that this solution is ungeschickt.

How can i improve this code?

Update: Thank you very much to all that contributed to this interesting thread. I have little time this week, but when i have studied the numerous examples given, i'll reply more detailed respectively ask more questions :-)

Thank you very much for any hint and best regards,

Karl

«The Crux of the Biscuit is the Apostrophe»


In reply to Threads From Hell #3: Missing Some Basic Prerequisites [Solved] by karlgoethebier

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.