performance measurements

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

 N  CPU secs Elapsed secs Memory KB Code B ≈ CPU Load

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

Read binary-trees benchmark to see what this program should do.


 binary-trees Cython program source code

# The Computer Language Benchmarks Game
# contributed by Antoine Pitrou
# modified by Dominique Wahli and Daniel Nanz

import sys
import multiprocessing as mp

def make_tree(int i, int d):
    if d > 0:
        i2 = i + i
        d -= 1
        return (i, make_tree(i2 - 1, d), make_tree(i2, d))
    return (i, None, None)

cdef int check_tree(node):
    cdef int i
    (i, l, r) = node
    if l is None:
        return i
        return i + check_tree(l) - check_tree(r)

def make_check(itde, make=make_tree, check=check_tree):
    cdef int i, d
    i, d = itde
    return check(make(i, d))

def get_argchunks(int i, int d, int chunksize=5000):
    cdef int k
    assert chunksize % 2 == 0
    chunk = []
    for k in range(1, i + 1):
        chunk.extend([(k, d), (-k, d)])
        if len(chunk) == chunksize:
            yield chunk
            chunk = []
    if len(chunk) > 0:
        yield chunk

def main(int n, int min_depth=4):
    cdef int max_depth, stretch_depth, mmd, i, d, cs

    max_depth = max(min_depth + 2, n)
    stretch_depth = max_depth + 1
    if mp.cpu_count() > 1:
        pool = mp.Pool()
        chunkmap =
        chunkmap = map

    print('stretch tree of depth {0}\t check: {1}'.format(
          stretch_depth, make_check((0, stretch_depth))))

    long_lived_tree = make_tree(0, max_depth)

    mmd = max_depth + min_depth
    for d in range(min_depth, stretch_depth, 2):
        i = 2 ** (mmd - d)
        cs = 0
        for argchunk in get_argchunks(i,d):
            cs += sum(chunkmap(make_check, argchunk))
        print('{0}\t trees of depth {1}\t check: {2}'.format(i * 2, d, cs))

    print('long lived tree of depth {0}\t check: {1}'.format(
          max_depth, check_tree(long_lived_tree)))


 make, command-line, and program output logs

Mon, 25 Nov 2019 14:47:54 GMT

make[1]: Vstupuje se do adresáře „/home/dundee/workspace/benchmarksgame/bencher/tmp/binarytrees/tmp“
cp binarytrees.cython `echo binarytrees.cython | sed 's/cython-..//' | sed 's/.cython//'`.pyx
cythonize -3 -bi `echo binarytrees.cython | sed 's/cython-..//' | sed 's/.cython//'`.pyx
Compiling /home/dundee/workspace/benchmarksgame/bencher/tmp/binarytrees/tmp/binarytrees.pyx because it changed.
[1/1] Cythonizing /home/dundee/workspace/benchmarksgame/bencher/tmp/binarytrees/tmp/binarytrees.pyx
running build_ext
building 'binarytrees' extension
creating /home/dundee/workspace/benchmarksgame/bencher/tmp/binarytrees/tmp/tmpydortcsg/home
creating /home/dundee/workspace/benchmarksgame/bencher/tmp/binarytrees/tmp/tmpydortcsg/home/dundee
creating /home/dundee/workspace/benchmarksgame/bencher/tmp/binarytrees/tmp/tmpydortcsg/home/dundee/workspace
creating /home/dundee/workspace/benchmarksgame/bencher/tmp/binarytrees/tmp/tmpydortcsg/home/dundee/workspace/benchmarksgame
creating /home/dundee/workspace/benchmarksgame/bencher/tmp/binarytrees/tmp/tmpydortcsg/home/dundee/workspace/benchmarksgame/bencher
creating /home/dundee/workspace/benchmarksgame/bencher/tmp/binarytrees/tmp/tmpydortcsg/home/dundee/workspace/benchmarksgame/bencher/tmp
creating /home/dundee/workspace/benchmarksgame/bencher/tmp/binarytrees/tmp/tmpydortcsg/home/dundee/workspace/benchmarksgame/bencher/tmp/binarytrees
creating /home/dundee/workspace/benchmarksgame/bencher/tmp/binarytrees/tmp/tmpydortcsg/home/dundee/workspace/benchmarksgame/bencher/tmp/binarytrees/tmp
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -fPIC -I/usr/include/python3.8 -c /home/dundee/workspace/benchmarksgame/bencher/tmp/binarytrees/tmp/binarytrees.c -o /home/dundee/workspace/benchmarksgame/bencher/tmp/binarytrees/tmp/tmpydortcsg/home/dundee/workspace/benchmarksgame/bencher/tmp/binarytrees/tmp/binarytrees.o
gcc -pthread -shared -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now /home/dundee/workspace/benchmarksgame/bencher/tmp/binarytrees/tmp/tmpydortcsg/home/dundee/workspace/benchmarksgame/bencher/tmp/binarytrees/tmp/binarytrees.o -L/usr/lib -o /home/dundee/workspace/benchmarksgame/bencher/tmp/binarytrees/tmp/
make[1]: Opouští se adresář „/home/dundee/workspace/benchmarksgame/bencher/tmp/binarytrees/tmp“
3.53s to complete and log all make actions

/usr/bin/python3 -c "import binarytrees" 14

TIMED OUT after 300s


Revised BSD license

  Home   Conclusions   License   Play