This file is indexed.

/usr/share/doc/python-tables-doc/bench/deep-tree-h5py.py is in python-tables-doc 3.3.0-5.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
from __future__ import print_function
import os
import subprocess
from time import time
import random
import numpy
import h5py

random.seed(2)


def show_stats(explain, tref):
    "Show the used memory (only works for Linux 2.6.x)."
    # Build the command to obtain memory info
    cmd = "cat /proc/%s/status" % os.getpid()
    sout = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE).stdout
    for line in sout:
        if line.startswith("VmSize:"):
            vmsize = int(line.split()[1])
        elif line.startswith("VmRSS:"):
            vmrss = int(line.split()[1])
        elif line.startswith("VmData:"):
            vmdata = int(line.split()[1])
        elif line.startswith("VmStk:"):
            vmstk = int(line.split()[1])
        elif line.startswith("VmExe:"):
            vmexe = int(line.split()[1])
        elif line.startswith("VmLib:"):
            vmlib = int(line.split()[1])
    sout.close()
    print("Memory usage: ******* %s *******" % explain)
    print("VmSize: %7s kB\tVmRSS: %7s kB" % (vmsize, vmrss))
    print("VmData: %7s kB\tVmStk: %7s kB" % (vmdata, vmstk))
    print("VmExe:  %7s kB\tVmLib: %7s kB" % (vmexe, vmlib))
    tnow = time()
    print("WallClock time:", round(tnow - tref, 3))
    return tnow


def populate(f, nlevels):
    g = f
    arr = numpy.zeros((10,), "f4")
    for i in range(nlevels):
        g["DS1"] = arr
        g["DS2"] = arr
        g.create_group('group2_')
        g = g.create_group('group')


def getnode(f, nlevels, niter, range_):
    for i in range(niter):
        nlevel = random.randrange(
            (nlevels - range_) / 2, (nlevels + range_) / 2)
        groupname = ""
        for i in range(nlevel):
            groupname += "/group"
        groupname += "/DS1"
        f[groupname]


if __name__ == '__main__':
    nlevels = 1024
    niter = 1000
    range_ = 256
    profile = True
    doprofile = True
    verbose = False

    if doprofile:
        import pstats
        import cProfile as prof

    if profile:
        tref = time()
    if profile:
        show_stats("Abans de crear...", tref)
    f = h5py.File("/tmp/deep-tree.h5", 'w')
    if doprofile:
        prof.run('populate(f, nlevels)', 'populate.prof')
        stats = pstats.Stats('populate.prof')
        stats.strip_dirs()
        stats.sort_stats('time', 'calls')
        if verbose:
            stats.print_stats()
        else:
            stats.print_stats(20)
    else:
        populate(f, nlevels)
    f.close()
    if profile:
        show_stats("Despres de crear", tref)

#     if profile: tref = time()
#     if profile: show_stats("Abans d'obrir...", tref)
#     f = h5py.File("/tmp/deep-tree.h5", 'r')
#     if profile: show_stats("Abans d'accedir...", tref)
#     if doprofile:
#         prof.run('getnode(f, nlevels, niter, range_)', 'deep-tree.prof')
#         stats = pstats.Stats('deep-tree.prof')
#         stats.strip_dirs()
#         stats.sort_stats('time', 'calls')
#         if verbose:
#             stats.print_stats()
#         else:
#             stats.print_stats(20)
#     else:
#         getnode(f, nlevels, niter, range_)
#     if profile: show_stats("Despres d'accedir", tref)
#     f.close()
#     if profile: show_stats("Despres de tancar", tref)

#     f = h5py.File("/tmp/deep-tree.h5", 'r')
#     g = f
#     for i in range(nlevels):
#         dset = g["DS1"]
#         dset = g["DS2"]
#         group2 = g['group2_']
#         g = g['group']
#     f.close()