No matter the method tried, when I increase the number of threads, the reported time increases dramatically...
Assuming that your running on a single cpu machine, that is to be expected.
Using two threads will not double the capacity of your cpu. They shared the cpu. Both threads will get (slightly less than) half of the time a single thread would get. All other things being equal.
Threads are not a way of making your code run faster. The main purpose to is allow one part of your program to continue doing something useful whilst another part of your program is waiting for something to happen--usually IO of some form. Waiting for the user to type something, or a webserver to respond to a query etc.
There are other uses, but the limited api that Perl threads present of the underlying mechanisms restricts many of these.
Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
"Memory, processor, disk in that order on the hardware side. Algorithm, algoritm, algorithm on the code side." - tachyon
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.