Python Interpreters Benchmarks
x64 ArchLinux : AMD® Ryzen 7 4700U®

 performance measurements

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

 N  CPU secs Elapsed secs Memory KB Code B ≈ CPU Load
10,0000.130.07?777  33% 14% 14% 14% 86% 17% 17% 0%

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

Read  benchmark to see what this program should do.

 notes

  source code

# The Computer Language Benchmarks Game
# http://benchmarksgame.alioth.debian.org/
#
# submitted by Ian Osgood
# modified by Sokolov Yura
# modified by bearophile
# modified by xfm for parallelization
# modified by Justin Peel 

from sys import stdin
from collections import defaultdict
from multiprocessing import Pool

def gen_freq(frame) :
    global sequence
    frequences = defaultdict(int)
    if frame != 1:
        for ii in range(len(sequence)-frame+1) :
            frequences[sequence[ii:ii+frame]] += 1
    else:
        for nucleo in sequence:
            frequences[nucleo] += 1
    return frequences


def sort_seq(length):
    frequences = gen_freq(length)
    n= sum(frequences.values())

    l = sorted(list(frequences.items()), reverse=True, key=lambda seq_freq: (seq_freq[1],seq_freq[0]))

    return '\n'.join("%s %.3f" % (st, 100.0*fr/n) for st,fr in l)


def find_seq(s):
    t = gen_freq(len(s))
    return (s,t.get(s,0))

def prepare(f=stdin) :
    for line in f:
        if line[0] in ">;":
            if line[1:3] == "TH":
                break

    seq = []
    app = seq.append
    for line in f:
        if line[0] in ">;":
            break
        app( line )
    return "".join(seq).upper().replace('\n','')

def init(arg):
    global sequence
    sequence = arg

def main():
    global sequence
    sequence = prepare()
    p=Pool()

    
    res2 = p.map_async(find_seq,reversed("GGT GGTA GGTATT GGTATTTTAATT GGTATTTTAATTTATAGT".split()))
    res1 = p.map_async(sort_seq,(1,2))
    
    for s in res1.get() : print (s+'\n')
    res2 = reversed([r for r in res2.get()])
    print ("\n".join("{1:d}\t{0}".format(*s) for s in res2))

if __name__=='__main__' :
    main()

 make, command-line, and program output logs

 Sun, 23 Apr 2023 09:20:24 GMT

MAKE:
make[1]: Vstupuje se do adresáře „/home/dundee/work/pybenchmarks/bencher/tmp/knucleotide/tmp“
nuitka3 --remove-output knucleotide.nuitka-8.nuitka
Nuitka-Options:INFO: Used command line options: --remove-output knucleotide.nuitka-8.nuitka
Nuitka-Options:WARNING: You did not specify to follow or include anything but main program. Check options and make sure that is intended.
Nuitka:INFO: Starting Python compilation with Nuitka '1.5' on Python '3.10' commercial grade 'not installed'.
Nuitka-Plugins:INFO: multiprocessing: Injecting pre-module load code for module 'multiprocessing':
Nuitka-Plugins:INFO: multiprocessing:     Monkey patching "multiprocessing" load environment.
Nuitka-Plugins:INFO: multiprocessing: Injecting post-module load code for module 'multiprocessing':
Nuitka-Plugins:INFO: multiprocessing:     Monkey patching "multiprocessing" for compiled methods.
Nuitka:INFO: Completed Python level compilation and optimization.
Nuitka:INFO: Generating source code for C backend compiler.
Nuitka:INFO: Running data composer tool for optimal constant value handling.
Nuitka:INFO: Running C compilation via Scons.
Nuitka-Scons:INFO: Backend C compiler: gcc (gcc).
Nuitka-Scons:INFO: Backend linking program with 10 files (no progress information available).
Nuitka-Scons:WARNING: You are not using ccache.
Nuitka:INFO: Removing build directory 'knucleotide.nuitka-8.nuitka.build'.
Nuitka:INFO: Successfully created 'knucleotide.nuitka-8.nuitka.bin'.
cp knucleotide.nuitka-8.nuitka.bin knucleotide.nuitka-8.nuitka_run
make[1]: Opouští se adresář „/home/dundee/work/pybenchmarks/bencher/tmp/knucleotide/tmp“
19.08s to complete and log all make actions

COMMAND LINE:
 ./knucleotide.nuitka-8.nuitka_run 0 < knucleotide-input10000.txt

PROGRAM OUTPUT:
A 30.284
T 29.796
C 20.312
G 19.608

AA 9.212
AT 8.950
TT 8.948
TA 8.936
CA 6.166
CT 6.100
AC 6.086
TC 6.042
AG 6.036
GA 5.968
TG 5.868
GT 5.798
CC 4.140
GC 4.044
CG 3.906
GG 3.798

562	GGT
152	GGTA
15	GGTATT
0	GGTATTTTAATT
0	GGTATTTTAATTTATAGT

Revised BSD license

  Home   Conclusions   License   Play