예제 #1
0
def test_unique_resource_values(query_profiles):
    """Test 'unique_resource_values_of' on resource.

    Expected no exception, all assertions passed.
    """
    # Acquire the memory query profile
    mem_profile = profile_filter(query_profiles,
                                 'memory-2017-08-25-16-03-47.perf')
    assert mem_profile is not None

    # Test the searching in first level of hierarchy
    unique_values = list(query.unique_resource_values_of(
        mem_profile, 'amount'))
    unique_values.sort()
    assert len(unique_values) == _MEMORY_AMOUNT_COUNT
    assert unique_values == _MEMORY_AMOUNT_LIST

    # Test the searching in dictionary -> list hierarchy
    unique_values = list(
        query.unique_resource_values_of(mem_profile, 'trace::function'))
    unique_values.sort()
    assert len(unique_values) == _MEMORY_TRACE_FUNCTION_COUNT
    assert unique_values == _MEMORY_TRACE_FUNCTION_LIST

    # Test the searching in dictionaries hierarchy
    unique_values = list(
        query.unique_resource_values_of(mem_profile, 'uid:line'))
    unique_values.sort()
    assert len(unique_values) == _MEMORY_UID_LINE_COUNT
    assert unique_values == _MEMORY_UID_LINE_LIST

    # Test key that is not in the resources
    unique_values = list(
        query.unique_resource_values_of(mem_profile, 'test:testing::test'))
    assert not unique_values
예제 #2
0
파일: factory.py 프로젝트: xlisci02/perun
def generate_plot_data_slices(profile):
    """ Generates data slices for plotting resources and models. The resources are split by unique
        uids, models are sliced into parts by uid and interval.

    :param dict profile: loaded perun profile
    :returns generator: generator: resources and models slices of unique uid as pair
        (data_slice(pandas.DataFrame), uid_models(list))
    """
    # Get resources for scatter plot points and models for curves
    resource_table = convert.resources_to_pandas_dataframe(profile)
    models = list(map(itemgetter(1), query.all_models_of(profile)))
    # Get unique uids from profile, each uid (and optionally interval) will have separate graph
    uids = map(convert.flatten,
               query.unique_resource_values_of(profile, 'uid'))

    # Process each uid data
    for uid_slice, uid_models in slice_resources_by_uid(
            resource_table, models, uids):
        # Slice the uid models according to different intervals (each interval is plotted
        # separately as it improves readability)
        if uid_models:
            for interval_models in slice_models_by_interval(uid_models):
                yield uid_slice, interval_models
        else:
            # There are no models to plot
            yield uid_slice, []
예제 #3
0
def test_unique_model_values(query_profiles):
    """Test 'unique_model_values_of' on model.

    Expected no exception, all assertions passed.
    """
    # Acquire the models query profile
    models_profile = profile_filter(query_profiles, 'complexity-models.perf')
    assert models_profile is not None

    # Test the searching in first level of hierarchy
    unique_values = list(query.unique_model_values_of(models_profile, 'model'))
    unique_values.sort()
    assert len(unique_values) == _MODELS_MODEL_COUNT
    assert unique_values == _MODELS_MODEL_LIST

    # Test the searching in dictionary -> list hierarchy
    unique_values = list(
        query.unique_model_values_of(models_profile, 'coeffs::name'))
    unique_values.sort()
    assert len(unique_values) == _MODELS_COEFFS_NAME_COUNT
    assert unique_values == _MODELS_COEFFS_NAME_LIST

    # Test key that is not in the models
    unique_values = list(
        query.unique_resource_values_of(models_profile, 'test'))
    assert not unique_values