CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced:
"Optimized Away"... or not?

 



cnd
New User

Sep 8, 2009, 11:27 PM

Post #1 of 2 (2762 views)
"Optimized Away"... or not? Can't Post

Does anyone know how to actually get code to "optimise away". As exciting as this looks ( http://perldoc.perl.org/5.8.8/constant.html ) it doesn't actually work (and no - it "doesn't work" outside the debugger either)...


Code
   

[root@q01 srvsample]# date;perl -d:SmallProf /tmp/speediness1.pl;date
Wed Sep 9 06:14:40 UTC 2009
Took: 166.858855962753s
Wed Sep 9 06:17:27 UTC 2009
[root@q01 srvsample]# cat smallprof.out
================ SmallProf version 2.02 ================
Profile of /tmp/speediness1.pl Page 1
=================================================================
count wall tm cpu time line
0 0.00000 0.00000 1:#!/usr/bin/perl -w
0 0.00000 0.00000 2:
0 0.00000 0.00000 3:use strict;
0 0.00000 0.00000 4:use constant DEBUG => 0;
0 0.00000 0.00000 5:use Time::HiRes qw(time);
0 0.00000 0.00000 6:
2 0.00000 0.00000 7:my $s='';
0 0.00000 0.00000 8:
1 0.00000 0.00000 9:my($go)=time;
1 0.00000 0.00000 10:while($i++<1000000) {
0 0.00000 0.00000 11:
1000000 0.01641 12.09000 12: $a++;
0 0.00000 0.00000 13:
1000000 0.01581 11.08000 14: if(0) { log_message(2, "event on $id = "
0 0.00000 0.00000 15:
1000000 0.02954 13.46000 16: $x++ if($s eq '');
1000000 0.02674 12.98000 17: $y++ if(length($s)==0);
1000000 0.01630 10.85000 18: $id++ if DEBUG;
1000000 0.01712 11.62000 19: $ev++ if 0;
1000000 0.03508 13.83000 20: $b++;
0 0.00000 0.00000 21:
0 0.00000 0.00000 22:}
0 0.00000 0.00000 23:
1 0.00000 0.00000 24:my $stop=time;
0 0.00000 0.00000 25:
1 0.00001 0.00000 26:print "Took: ";
1 0.00003 0.00000 27:print ($stop-$go);
1 0.00004 0.00000 28:print "s\n";
0 0.00000 0.00000 29:
0 0.00000 0.00000 30:
0 0.00000 0.00000 31:sub log_message {
0 0.00000 0.00000 32:}
[root@q01 srvsample]#



cnd
New User

Sep 9, 2009, 5:22 AM

Post #2 of 2 (2754 views)
Re: [cnd] "Optimized Away"... or not? [In reply to] Can't Post

Spent a few more hours on this - without much luck.

The best I could find, which solved my need, was;

http://search.cpan.org/~elizabeth/ifdef-0.07/lib/ifdef.pm

which of course doesn't fix the "optimized away" issue if that was specifically what you needed to do...

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives