예제 #1
0
def main(argv):
    """Main."""
    del argv  # Unused.

    # Initialise flows and config_lib
    server_startup.Init()

    if not flags.FLAGS.target:
        store_names = ", ".join(sorted(blob_store.REGISTRY.keys()))
        print("Missing --target. Use one or multiple of: {}.".format(
            store_names))
        exit(1)

    stores = [
        _MakeBlobStore(blobstore_name) for blobstore_name in flags.FLAGS.target
    ]

    with io.open("/dev/urandom", "rb") as random_fd:
        for blobstore_name, bs in zip(flags.FLAGS.target, stores):
            print()
            print(blobstore_name)
            print("size\ttotal\tnum\tqps\t  b/sec\tp50\tp90\tp95\tp99")
            for size in flags.FLAGS.sizes:
                size_b = rdfvalue.ByteSize(size)
                durations = _RunBenchmark(
                    bs, size_b, flags.FLAGS.per_size_duration_seconds,
                    random_fd)
                _PrintStats(size, size_b, durations)
예제 #2
0
    def testParsing(self):
        cases = [
            ("100gb", 100 * 1000**3),
            ("10kib", 10 * 1024),
            ("2.5kb", 2500),
            ("3.25MiB", 3.25 * 1024**2),
            ("12B", 12),
        ]

        for string, expected in cases:
            self.assertEqual(expected, rdfvalue.ByteSize(string))
예제 #3
0
def _PrintStats(size, size_b, durations):
    durations_ms = np.array(durations) * 1000
    total_s = sum(durations)
    qps = len(durations) / total_s
    print(
        "{size}\t{total:.1f}s\t{num}\t{qps:.2f}\t{bps: >7}\t{p50:.1f}\t{p90:.1f}"
        "\t{p95:.1f}\t{p99:.1f}".format(
            size=size,
            total=total_s,
            num=len(durations),
            qps=qps,
            bps=str(rdfvalue.ByteSize(int(size_b * qps))).replace("iB", ""),
            p50=np.percentile(durations_ms, 50),
            p90=np.percentile(durations_ms, 90),
            p95=np.percentile(durations_ms, 95),
            p99=np.percentile(durations_ms, 99),
        ))
예제 #4
0
 def Run(self, args):
     _ = args
     self.SendReply(rdfvalue.ByteSize(psutil.virtual_memory()[0]))
예제 #5
0
 def GenerateSample(self, number=5):
     return rdfvalue.ByteSize("%sKib" % number)