Esempio n. 1
0
def mkload(opts, fh):
    opts.load = int(opts.load * 1000 * 1000)
    k = helpers.strings(SEED, opts.ksize)
    s = opts.load
    m = helpers.progress()
    helpers.debug(
        "generating load test file ... [ksize: %s, pktsz: %s, keylen: %s, load: %s]\n"
        % (helpers.fmt(len(k)), helpers.fmt(opts.pktsz), len(
            k[0]), helpers.fmt(s)))
    while (s > 0):
        p = []
        c = opts.pktsz
        while (True):
            i = opts.load - s
            n = k[i % len(k)]
            l = "event %s|%s %d.0 %s;" % (len(n), n, i, repr(random.random()))
            z = len(l)
            s -= 1
            c -= z
            if (c >= 0):
                m.measure(z)
                p.append(l)
            else:
                if (opts.pktsz < z):
                    m.measure(z)
                    p.append(l)
                break
            m.dump_state("mkload")
        fh.write("".join(p) + "\n")
    m.done()
Esempio n. 2
0
def mkload(opts, fh):
    opts.load = int(opts.load * 1000 * 1000)
    k         = helpers.strings(SEED, opts.uniq)
    s         = opts.load
    m         = helpers.progress()
    helpers.debug("generating load test file ... [uniq: %s, pktsz: %s, keylen: %s, load: %s]\n" % (helpers.fmt(len(k)),
                                                                                                   helpers.fmt(opts.pktsz),
                                                                                                   len(k[0]),
                                                                                                   helpers.fmt(s)))
    pack = lambda p: "".join(p) + "\n"
    while (s > 0):
        p = []
        c = opts.pktsz
        while (True):
            i  = opts.load - s
            n  = k[i % len(k)]
            l  = "event %s|%s %d.0 %s;" % (len(n), n, i, repr(random.random()))
            s -= 1
            c -= len(l)
            if (c >= 0):
                p.append(l)
            else:
                if (opts.pktsz < len(l)):
                    p.append(l)
                break
        if (opts.measure == M_BYTES):
            m.measure(len(pack(p)))
        else:
            m.measure(len(p))
        m.dump_state("mkload")
        fh.write("%d %s" % (len(p), pack(p)))
    m.done()
Esempio n. 3
0
def mkload(opts, fh):
    opts.load = int(opts.load * 1000 * 1000)
    k         = helpers.strings(SEED, opts.ksize)
    s         = opts.load
    m         = helpers.progress()
    helpers.debug("generating load test file ... [ksize: %s, pktsz: %s, keylen: %s, load: %s]\n" % (helpers.fmt(len(k)),
                                                                                                    helpers.fmt(opts.pktsz),
                                                                                                    len(k[0]),
                                                                                                    helpers.fmt(s)))
    while (s > 0):
        p = []
        c = opts.pktsz
        while (True):
            i  = opts.load - s
            n  = k[i % len(k)]
            l  = "event %s|%s %d.0 %s;" % (len(n), n, i, repr(random.random()))
            z  = len(l)
            s -= 1
            c -= z
            if (c >= 0):
                m.measure(z)
                p.append(l)
            else:
                if (opts.pktsz < z):
                    m.measure(z)
                    p.append(l)
                break
            m.dump_state("mkload")
        fh.write("".join(p) + "\n")
    m.done()
Esempio n. 4
0
def mkload(opts, fh):
    opts.load = int(opts.load * 1000 * 1000)
    k         = helpers.strings(SEED, opts.uniq)
    s         = opts.load
    m         = helpers.progress()
    helpers.debug("generating load test file ... [uniq: %s, pktsz: %s, keylen: %s, load: %s]\n" % (helpers.fmt(len(k)),
                                                                                                   helpers.fmt(opts.pktsz),
                                                                                                   len(k[0]),
                                                                                                   helpers.fmt(s)))
    pack = lambda p: "".join(p) + "\n"
    while (s > 0):
        p = []
        c = opts.pktsz
        while (True):
            i  = opts.load - s
            n  = k[i % len(k)]
            l  = "%s %s|%s %s %d.0;" % (opts.type, len(n), n, repr(random.random()), i)
            s -= 1
            c -= len(l)
            if (c >= 0):
                p.append(l)
            else:
                if (opts.pktsz < len(l)):
                    p.append(l)
                break
        if (opts.measure == M_BYTES):
            m.measure(len(pack(p)))
        else:
            m.measure(len(p))
        m.dump_state("mkload")
        fh.write("%d %s" % (len(p), pack(p)))
    m.done()