Ejemplo n.º 1
0
def main(argv):
    o = options.Options(optspec)
    opt, flags, extra = o.parse_bytes(argv[1:])

    if extra:
        o.fatal('no arguments expected')

    git.check_repo_or_die()
    sys.stdout.flush()
    out = byte_stream(sys.stdout)

    report(-1, out)
    _helpers.random_sha()
    report(0, out)

    with git.PackIdxList(git.repo(b'objects/pack'),
                         ignore_midx=opt.ignore_midx) as m:

        if opt.existing:

            def foreverit(mi):
                while 1:
                    for e in mi:
                        yield e

            objit = iter(foreverit(m))

        for c in range(opt.cycles):
            for n in range(opt.number):
                if opt.existing:
                    bin = next(objit)
                    assert (m.exists(bin))
                else:
                    bin = _helpers.random_sha()

                    # technically, a randomly generated object id might exist.
                    # but the likelihood of that is the likelihood of finding
                    # a collision in sha-1 by accident, which is so unlikely that
                    # we don't care.
                    assert (not m.exists(bin))
            report((c + 1) * opt.number, out)

    if bloom._total_searches:
        out.write(
            b'bloom: %d objects searched in %d steps: avg %.3f steps/object\n'
            % (bloom._total_searches, bloom._total_steps,
               bloom._total_steps * 1.0 / bloom._total_searches))
    if midx._total_searches:
        out.write(
            b'midx: %d objects searched in %d steps: avg %.3f steps/object\n' %
            (midx._total_searches, midx._total_steps,
             midx._total_steps * 1.0 / midx._total_searches))
    if git._total_searches:
        out.write(
            b'idx: %d objects searched in %d steps: avg %.3f steps/object\n' %
            (git._total_searches, git._total_steps,
             git._total_steps * 1.0 / git._total_searches))
    out.write(b'Total time: %.3fs\n' % (time.time() - start))
Ejemplo n.º 2
0
ignore-midx  ignore .midx files, use only .idx files
existing   test with existing objects instead of fake ones
"""
o = options.Options(optspec)
(opt, flags, extra) = o.parse(sys.argv[1:])

if extra:
    o.fatal('no arguments expected')

git.ignore_midx = opt.ignore_midx

git.check_repo_or_die()
m = git.PackIdxList(git.repo('objects/pack'))

report(-1)
_helpers.random_sha()
report(0)

if opt.existing:
    def foreverit(mi):
        while 1:
            for e in mi:
                yield e
    objit = iter(foreverit(m))

for c in range(opt.cycles):
    for n in range(opt.number):
        if opt.existing:
            bin = next(objit)
            assert(m.exists(bin))
        else:
Ejemplo n.º 3
0
ignore-midx  ignore .midx files, use only .idx files
existing   test with existing objects instead of fake ones
"""
o = options.Options(optspec)
(opt, flags, extra) = o.parse(sys.argv[1:])

if extra:
    o.fatal('no arguments expected')

git.ignore_midx = opt.ignore_midx

git.check_repo_or_die()
m = git.PackIdxList(git.repo('objects/pack'))

report(-1)
_helpers.random_sha()
report(0)

if opt.existing:

    def foreverit(mi):
        while 1:
            for e in mi:
                yield e

    objit = iter(foreverit(m))

for c in xrange(opt.cycles):
    for n in xrange(opt.number):
        if opt.existing:
            bin = objit.next()