Exemplo n.º 1
0
def get_api_performance(db_session, endpoints):
    """
    :param db_session: session for the database
    :param endpoints: a list of endpoints, encoded by their name
    :return: for every endpoint in endpoints, a list with the performance
    """
    db_endpoints = [get_endpoint_by_name(db_session, end) for end in endpoints]
    data = get_endpoint_data_grouped(db_session, lambda x: simplify(x, 10))
    return [
        {'name': end.name, 'values': get_value(data, end.id, default=[])} for end in db_endpoints
    ]
Exemplo n.º 2
0
def get_outlier_graph(session, endpoint_id):
    """
    :param session: session for the database
    :param endpoint_id: id of the endpoint
    :return: a list with data about each CPU performance
    """
    all_cpus = get_outliers_cpus(session, endpoint_id)
    cpu_data = [ast.literal_eval(cpu) for cpu in all_cpus]

    return [
        {'name': 'CPU core %d' % idx, 'values': simplify(data, 50), 'color': get_color(idx)}
        for idx, data in enumerate(zip(*cpu_data))
    ]
Exemplo n.º 3
0
def get_endpoint_versions(db_session, endpoint_id, versions):
    """
    :param db_session: session for the database
    :param endpoint_id: id for the endpoint
    :param versions: a list of version to be filtered on
    :return: a list of dicts with the performance of each version
    """
    times = get_version_data_grouped(db_session, lambda x: simplify(x, 100), Request.endpoint_id == endpoint_id)
    first_requests = get_first_requests(db_session, endpoint_id)
    return [{
        'version': v,
        'date': get_value(first_requests, v),
        'values': get_value(times, v),
        'color': get_color(v)
    } for v in versions]
Exemplo n.º 4
0
def get_endpoint_users(db_session, endpoint_id, users):
    """
    :param db_session: session for the database
    :param endpoint_id: id for the endpoint
    :param users: a list of users to be filtered on
    :return: a list of dicts with the performance of each user
    """
    times = get_user_data_grouped(db_session, lambda x: simplify(x, 100), Request.endpoint_id == endpoint_id)
    first_requests = get_first_requests(db_session, endpoint_id)
    return [{
        'user': u,
        'date': get_value(first_requests, u),
        'values': get_value(times, u),
        'color': get_color(u)
    } for u in users]
def endpoint_graph():
    """
    Creates a graph with the execution times per endpoint
    :return:
    """
    with session_scope() as db_session:
        data = get_endpoint_data_grouped(db_session, lambda x: simplify(x, 10))
        values = [
            boxplot(get_value(data, end.id, default=[]), name=end.name)
            for end in get_endpoints(db_session)
        ]

    layout = get_layout(height=350 + 40 * len(values),
                        xaxis={'title': 'Execution time (ms)'},
                        margin=get_margin())
    return get_figure(layout, values)
Exemplo n.º 6
0
def users_graph(id, form):
    """
    Return an HTML box plot with a specific number of
    :param id: get the data for this endpoint only
    :param form: instance of SliderForm
    :return:
    """
    with session_scope() as db_session:
        users = get_users(db_session, id, form.get_slider_value())
        times = get_user_data_grouped(db_session, lambda x: simplify(x, 10),
                                      Request.endpoint_id == id)
        data = [boxplot(name=u, values=get_value(times, u)) for u in users]

    layout = get_layout(height=350 + 40 * len(data),
                        xaxis={'title': 'Execution time (ms)'},
                        yaxis={
                            'type': 'category',
                            'title': 'User'
                        })
    return get_figure(layout, data)
def versions_graph(db_session, endpoint_id, form):
    times = get_version_data_grouped(db_session, lambda x: simplify(x, 10),
                                     Request.endpoint_id == endpoint_id)
    first_requests = get_first_requests(db_session, endpoint_id,
                                        form.get_slider_value())
    data = [
        boxplot(name=format_version(
            request.version_requested,
            get_value(first_requests, request.version_requested)),
                values=get_value(times, request.version_requested),
                marker={'color': get_color(request.version_requested)})
        for request in first_requests
    ]

    layout = get_layout(height=350 + 40 * len(first_requests),
                        xaxis={'title': 'Execution time (ms)'},
                        yaxis={
                            'type': 'category',
                            'title': 'Version',
                            'autorange': 'reversed'
                        },
                        margin=get_margin())
    return get_figure(layout=layout, data=data)