Exemple #1
0
def run(type, server_conf, memtier_conf, output_dir, base_port=11120, instances=1, duration=30, zipf=False, pin=False, iterations=3):
    server = Server(type, server_conf, base_port, instances)
    clients = Clients(type, memtier_conf, base_port, instances, zipf=zipf)

    server.start_cache()

    if pin:
        server.pin()

    # Warm up
    print('[Main] Warming up cache')
    client_results = clients.warmup()
    memtier_parser = MemtierResultsParser(client_results)
    memtier_parser.read()

    cpu_stats = []
    total_stats = []
    latency_stats = []
    for i in range(iterations):
        print('[Main] Iteration {} started'.format(i))
        server_cpu = server.log_cpu(duration + 1)
        cpu_parser = CPUParser()

        client_results = clients.run_memtier(False)

        memtier_parser = MemtierResultsParser(client_results)

        memtier_parser.read()

        averaged_totals = memtier_parser.get_averaged_totals()
        average_99th = memtier_parser.get_average_99th()
        server_cpu_averages = cpu_parser.get_average_stats(server_cpu)
        server_cpu_labels = cpu_parser.get_labels()

        total_stats.append(averaged_totals)
        latency_stats.append(average_99th)
        cpu_stats.append([server_cpu_averages[key] for key in server_cpu_labels])

        print('[Main] Iteration {} finished'.format(i))
        print('[Main] Totals:', averaged_totals)
        print('[Main] 99th:', average_99th)
        print('[Main] CPU:', server_cpu_averages)


    avg_latency = sum(latency_stats) / float(iterations)
    avg_cpu_stats = []
    for index in range(len(cpu_stats[0])):
        values = [cpu[index] for cpu in cpu_stats]
        avg_cpu_stats.append(sum(values) / float(iterations))

    avg_total_stats = []
    for index in range(len(total_stats[0])):
        values = [cpu[index] for cpu in total_stats]
        avg_total_stats.append(sum(values) / float(iterations))

    print('[Main] Totals:', avg_total_stats)
    print('[Main] 99th:', avg_latency)
    print('[Main] CPU:', avg_cpu_stats)

    # write results
    write(
        ', '.join(memtier_parser.get_totals_headers()),
        avg_total_stats,
        '%s/totals.csv' % output_dir
    )

    write(
        '99th latency',
        [avg_latency],
        '%s/latency.csv' % output_dir
    )

    server_cpu_labels = cpu_parser.get_labels()
    write(
        ', '.join(server_cpu_labels),
        avg_cpu_stats,
        '%s/cpu.csv' % output_dir
    )

    # Clean up
    server.kill_cache()
Exemple #2
0
from clients import Clients
from parsers.cpu import CPUParser
from parsers.memtier import MemtierResultsParser
from server import Server

s = Server('memcached', '-d -p 11120 -m 1024', 11120, 4)
s.start_cache()

c = Clients('memcached', '-s nsl200 -p 11123 --test-time=30 -c 1 -t 1 -P memcache_binary', 11120, 4)

cpu = s.log_cpu()
cpu_parser = CPUParser()
results = c.run_memtier()

parser = MemtierResultsParser(results)
parser.read()
averages = parser.get_averaged_totals()
average_99th = parser.get_average_99th()