performance measurements

Each table row shows performance measurements for this Perl program with a particular command-line input value N.

 N  CPU secs Elapsed secs Memory KB Code B ≈ CPU Load
250,0002.860.9539,304507  74% 54% 85% 88%
2,500,00025.787.72141,012507  76% 95% 79% 85%
25,000,000255.0274.611,140,456507  96% 89% 83% 76%

Read the ↓ make, command line, and program output logs to see how this program was run.

Read k-nucleotide benchmark to see what this program should do.

 notes

This is perl 5, version 20, subversion 2 (v5.20.2) built for i686-linux-thread-multi

Compile-time options: HAS_TIMES MULTIPLICITY PERLIO_LAYERS
                        PERL_DONT_CREATE_GVSV
                        PERL_HASH_FUNC_ONE_AT_A_TIME_HARD
                        PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP
                        PERL_NEW_COPY_ON_WRITE PERL_PRESERVE_IVUV
                        USE_ITHREADS USE_LARGE_FILES USE_LOCALE
                        USE_LOCALE_COLLATE USE_LOCALE_CTYPE
                        USE_LOCALE_NUMERIC USE_PERLIO USE_PERL_ATOF
                        USE_REENTRANT_API

 k-nucleotide Perl #3 program source code

# The Computer Language Benchmarks Game
# http://benchmarksgame.alioth.debian.org/
#
#  contributed by Mykola Zubach

use strict;
use threads;

my($sequence, $seq_len, $thr, @threads, %h);

sub read_sequence($) {
  my $id = shift;
  my $out;

  while(<STDIN>) {
    last if /^>$id /;
  }

  while(<STDIN>) {
    last if /^>/;
    chomp;
    $out .= uc($_);
  }

  return $out;
}

sub count_freq($) {
  my $len = shift;
  my $end = $seq_len - $len;

  %h = ();
  for(my $i = 0; $i <= $end; $i++) {
    $h{substr($sequence, $i, $len)} ++;
  }
}

sub count_len($) {
  my $len = shift;
  my $sum = $seq_len - $len + 1;
  my $out = '';

  count_freq($len);

  foreach my $s  (sort { $h{$b} <=> $h{$a} || $a cmp $b } keys %h) {
    $out .= sprintf "$s %.3f\n", $h{$s} * 100 / $sum;
  }
  $out .= "\n";

  return $out;
}

sub count_sequence($) {
  my $s = shift;

# count ALL sequences of specified length!
  count_freq(length($s));

  return sprintf("%d\t$s\n", $h{$s});
}

## MAIN()

$sequence = read_sequence('THREE');
$seq_len = length($sequence);

foreach my $len (1,2) {
  push @threads, threads->create(\&count_len, $len);
}

foreach my $s (qw(GGT GGTA GGTATT GGTATTTTAATT GGTATTTTAATTTATAGT)) {
  push @threads, threads->create(\&count_sequence, $s);
}

foreach $thr (@threads) {
  print $thr->join();
}

 make, command-line, and program output logs

Sun, 15 Mar 2015 09:33:06 GMT

COMMAND LINE:
/usr/local/src/perl-5.20.2/bin/perl knucleotide.perl-3.perl 0 < knucleotide-input25000000.txt

PROGRAM OUTPUT:
A 30.295
T 30.151
C 19.800
G 19.754

AA 9.177
TA 9.132
AT 9.131
TT 9.091
CA 6.002
AC 6.001
AG 5.987
GA 5.984
CT 5.971
TC 5.971
GT 5.957
TG 5.956
CC 3.917
GC 3.911
CG 3.909
GG 3.902

1471758	GGT
446535	GGTA
47336	GGTATT
893	GGTATTTTAATT
893	GGTATTTTAATTTATAGT

Revised BSD license

  Home   Conclusions   License   Play