UBB.Dev
Posted By: Greg Hard Theres gotta be a way to make THIS small... - 11/11/2000 4:06 AM
sub KillServer {
#used for the announcements
my $StartDate = shift;
my $EndDate = shift;

#convert dates to Julian dates
my $StartMonth = substr($StartDate, 0, 2);
my $StartDay = substr($StartDate, 2, 2);
my $StartYear = substr($StartDate, 4, 4);
my $EndMonth = substr($EndDate, 0, 2);
my $EndDay = substr($EndDate, 2, 2);
my $EndYear = substr($EndDate, 4, 4);

------------------
UBBDEV Moderator
OCCUPATION: Programmer, webmaster.

Hack Developer of the Ultimate Bulletin Board. I am not an employee of Infopop

Due to time limitation, I do not offer support Via. E-mail. Please post on the forums.

Sincerely,
MasterMind
Actually, I think that is as small as it will get. Maybe Mark can work something up, but if so it's something I haven't learned yet.

------------------
Powered by ZCom Bulletin Boards
You can replace this:
my $StartDate = shift;
my $EndDate = shift;

With this:
my ($StartDate, $EndDate) = @_;

I don't know about the rest.

------------------
Wartortle

I'm supposed to put somthin here? wink
Whoops! How'd I miss this thread?? How's this for smaller? [Linked Image]

Code
code:

Time the original vs the smaller version:

Benchmark: timing 10000 iterations of Original, Smaller...
Original: 2 wallclock secs ( 2.66 usr + 0.00 sys = 2.66 CPU) @ 3753.75/s (n=10000)
Smaller: 1 wallclock secs ( 0.88 usr + 0.00 sys = 0.88 CPU) @ 11350.74/s (n=10000)

Remember, the CPU time is the important stat, not the wallclock seconds

[Linked Image]

--mark

This message has been edited by Mark Badolato on November 19, 2000 at 01:34 AM
Aw hell, it can be dropped to about 0.55 CPU by changing to:

Code
code:

See, always something to tweak! [Linked Image]

New benchmark:

Benchmark: timing 10000 iterations of Original, Smaller...
Original: 3 wallclock secs ( 2.61 usr + 0.00 sys = 2.61 CPU) @ 3827.02/s (n=10000)
Smaller: 1 wallclock secs ( 0.54 usr + 0.00 sys = 0.54 CPU) @ 18552.88/s (n=10000)

--mark

This message has been edited by Mark Badolato on November 19, 2000 at 01:14 PM
Where do you even edit this?

------------------
The Fusion of Goku & Trunks...GoTorankusuKu
Posted By: zanardi Re: Theres gotta be a way to make THIS small... - 11/20/2000 10:01 PM
damn, they weren't kidding when they said you learn something new everyday [Linked Image]
Heh yup. Hell I still learn new perl stuff all the time too. The trick though is to keep on searching, and researching, and learning. Read everything you can, experiment, watch what the knowledgable people do etc.

It takes practice! The above code change I did compared to the original is like 89% less code, and runs 400% faster then the original. I didn't learn how to that kind of stuff in a day. It took lots of dedication to the craft, and lots of watching what the real Perl gurus. But who knows, some of the gurus could come along and shrink that even further...

I recommend that anyone who wants to get serious, get a newsreader, connect to Usenet and follow along at comp.lang.perl.misc (warning, do a LOT of lurking there before even thinking about posting. The group has no tolerence for newbies asking FAQ's or not doing basic research on their own). I can't tell you how much I've learned from reading that group daily.

--mark
Quote
quote:
So Mark. Where can I get some of your scripts eh? [Linked Image]

------------------
Powered by ZCom Bulletin Boards
Ya can't. I don't have any that are publicly released, save for a stupid clock script that i put on hotscripts and cgi-resources once just to see what kind of traffic the sites generate [Linked Image]

Someday when I actually have some of that free time thing I've heard so much about, I'd like to finish the UGB 2.0, which we was started back in april and hasn't been touched since July [Linked Image]

But, all of my other stuff has been private contract work, or my job.

--mark
damn jobs

------------------
Da Wannabe Cannuck

:: Who is Andy?
yeah i know huh? having to work to pay bills [Linked Image] [Linked Image]

--mark
© UBB.Developers