Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: Making program readable

by ravi45722 (Pilgrim)
on Oct 06, 2015 at 10:47 UTC ( [id://1143909]=note: print w/replies, xml ) Need Help??


in reply to Re: Making program readable
in thread Making program readable

I replaced the my if-else loops with these.

my @del_user_error_count; foreach my $i (0..4) { if ($cdr_post_array[11] eq $del_user_errors[$i]) { $del_user_error_count[$i]++; last; } }

Its decreased 42 lines but its increasing the execution time. I see this through benchmark.

For if-else loop it gives

 the code took:52 wallclock secs

After replacing the code with foreach

 the code took:67 wallclock secs

Replies are listed 'Best First'.
Re^3: Making program readable
by karlgoethebier (Abbot) on Oct 09, 2015 at 20:43 UTC
    "...I see this through benchmark..."

    You might try Iterator::Simple:

    #!/usr/bin/env perl use strict; use warnings; # use feature qw (say); use Iterator::Simple qw(iter); my $iterator = iter( [ 1 .. 4 ] ); while ( defined( my $i = $iterator->() ) ) { # warp action goes here }

    See also Bleeding edge as well as Re^2: Useful number of childs revisited.

    Regards, Karl

    «The Crux of the Biscuit is the Apostrophe»

Re^3: Making program readable
by Anonymous Monk on Oct 07, 2015 at 01:43 UTC

    Its decreased 42 lines but its increasing the execution time. I see this through benchmark.

    Ignore it, its not important :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1143909]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2024-03-28 13:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found