Archive

Archive for February 18th, 2005

How remove leading zeros

February 18th, 2005 No comments

The most efficient way to remove leading zeros from some number is add to that number 0:

      1 #! /usr/bin/perl -w
      2
      3 use strict;
      4 use Benchmark;
      5
      6 my $test = '000000000000001';
      8 timethese shift,
      9 {
     10  Add        => sub { my $num = $test; $num += 0 },
     11  Regex    => sub { my $num = $test; $num =~ s/^0+// },
     12  Sprintf    => sub { my $num = $test; $num = sprintf '%d', $num },
     13 };
	

Benchmark: timing 10000000 iterations of Add, Regex, Sprintf…
Add: 26 wallclock secs (17.68 usr + 0.06 sys = 17.74 CPU) @ 563697.86/s (n=10000000)
Regex: 48 wallclock secs (38.32 usr + 0.09 sys = 38.41 CPU) @ 260348.87/s (n=10000000)
Sprintf: 43 wallclock secs (34.78 usr + 0.10 sys = 34.88 CPU) @ 286697.25/s (n=10000000)

Categories: Digital Life Tags:

unpack vs substr

February 18th, 2005 No comments

Recently I’ve decided to repalce using substr by unpack when I need to split data which are presented in a row with specified order. But after that I’ve made a test to see what way is the most efficient.
The test displays that unpack is slower than substr about 30%! But on the other hand unpack makes a code more compact and clear. So, if speed is critical for you the better to use substr but if you want to make your code more readable you choise is unpack.

Read more…

Categories: Digital Life Tags:

Raritets of the USSR photo chronicles

February 18th, 2005 No comments

Raritets of the USSR photo chronicles – Great Domestic War 1941-1945 is a set of inconceivable photos! Highly recomended!

Categories: Digital Life Tags:

New Limassol theaters schedule

February 18th, 2005 No comments
Forkers

Only one new movie has started in the Limassol theaters at that weekend. It’s a comedy “Meet the Fockers” with Robert De Niro and Ben Stiller in key roles. Actually, this is a sequel of “Meet the Parents” where Forker (nice name) met with his girlfriend’s parents. So, I can suppose, the sequel story is about visit the parents to Forker’s home. I’ve watched “Meet the Parents” and I was disappointed (but I’ve watched many times
“Dumb & Dumber” and “Ace Ventura: : When Nature Calls” gladly). I don’t like Ben Stiller but I don’t understand what is Rober De Niro doing in those rubbish movies?!
Well, you can still watch “Blade: Trinity”, “National Treasure”, “The Phantom of the Opera” etc. Please, visit to cinema page and get detailed information about Linassol theaters schedule. Enjoy!

Categories: Uncategorized Tags:
Get Adobe Flash playerPlugin by wpburn.com wordpress themes