当前位置: 首页>>代码示例>>Python>>正文


Python Server.log_cpu方法代码示例

本文整理汇总了Python中server.Server.log_cpu方法的典型用法代码示例。如果您正苦于以下问题:Python Server.log_cpu方法的具体用法?Python Server.log_cpu怎么用?Python Server.log_cpu使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在server.Server的用法示例。


在下文中一共展示了Server.log_cpu方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run

# 需要导入模块: from server import Server [as 别名]
# 或者: from server.Server import log_cpu [as 别名]
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()
开发者ID:easyCZ,项目名称:memcached-vs-redis,代码行数:83,代码来源:main.py

示例2: Server

# 需要导入模块: from server import Server [as 别名]
# 或者: from server.Server import log_cpu [as 别名]
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()
开发者ID:easyCZ,项目名称:memcached-vs-redis,代码行数:20,代码来源:play.py


注:本文中的server.Server.log_cpu方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。