Exemplo n.º 1
0
static char* test_get_min_value()
{
    load_histograms();

    mu_assert("hdr_min(raw_histogram) != 1000", hdr_min(raw_histogram) == 1000L);
    mu_assert("hdr_min(cor_histogram) != 1000", hdr_min(cor_histogram) == 1000L);

    return 0;
}
Exemplo n.º 2
0
 void get_snapshot(Snapshot* snapshot) const {
   ScopedMutex l(&mutex_);
   hdr_histogram* h = histogram_;
   for (size_t i = 0; i < thread_state_->max_threads(); ++i) {
     histograms_[i].add(h);
   }
   snapshot->min = hdr_min(h);
   snapshot->max = hdr_max(h);
   snapshot->mean = static_cast<int64_t>(hdr_mean(h));
   snapshot->stddev = static_cast<int64_t>(hdr_stddev(h));
   snapshot->median = hdr_value_at_percentile(h, 50.0);
   snapshot->percentile_75th = hdr_value_at_percentile(h, 75.0);
   snapshot->percentile_95th = hdr_value_at_percentile(h, 95.0);
   snapshot->percentile_98th = hdr_value_at_percentile(h, 98.0);
   snapshot->percentile_99th = hdr_value_at_percentile(h, 99.0);
   snapshot->percentile_999th = hdr_value_at_percentile(h, 99.9);
 }
Exemplo n.º 3
0
ERL_NIF_TERM _hh_min(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
    hh_ctx_t* ctx = NULL;

    ErlNifResourceType* ctx_type = get_hh_ctx_type(env);
    if (argc != 1 ||
        ctx_type == NULL ||
        !enif_get_resource(env, argv[0], ctx_type, (void **)&ctx))
    {
        return enif_make_badarg(env);
    }
   
    if (ctx != NULL)
    {
        return enif_make_long(env, hdr_min(ctx->data));
    }

    return make_error(env, "bad_hdr_histogram_nif_impl");
}
static bool compare_histogram(struct hdr_histogram* a, struct hdr_histogram* b)
{
    if (a->counts_len != b->counts_len)
    {
        printf(
            "a.counts_len = %"PRIu32", b.counts_len = %"PRIu32"\n",
            a->counts_len, b->counts_len);
        return false;
    }

    int64_t a_max = hdr_max(a);
    int64_t b_max = hdr_max(b);

    if (a_max != b_max)
    {
        printf("a.max = %"PRIu64", b.max = %"PRIu64"\n", a_max, b_max);
//        return false;
    }

    int64_t a_min = hdr_min(a);
    int64_t b_min = hdr_min(b);

    if (a_min != b_min)
    {
        printf("a.min = %"PRIu64", b.min = %"PRIu64"\n", a_min, b_min);
//        return false;
    }

    size_t a_size = hdr_get_memory_size(a);
    size_t b_size = hdr_get_memory_size(b);

    if (a_size != b_size)
    {
        printf("a.size: %zu, b.size: %zu\n", a_size, b_size);
        return false;
    }

    size_t counts_size = a->counts_len * sizeof(int64_t);

    if (memcmp(a->counts, b->counts, counts_size) == 0)
    {
        return true;
    }

    printf("%s\n", "Counts incorrect");

    struct hdr_iter iter_a;
    struct hdr_iter iter_b;

    hdr_iter_init(&iter_a, a);
    hdr_iter_init(&iter_b, b);

    while (hdr_iter_next(&iter_a) && hdr_iter_next(&iter_b))
    {
        if (iter_a.count != iter_b.count ||
            iter_a.value != iter_b.value)
        {
            printf(
                "A - value: %"PRIu64", count: %"PRIu64", B - value: %"PRIu64", count: %"PRIu64"\n",
                iter_a.value, iter_a.count,
                iter_b.value, iter_b.count);
        }
    }

    return false;
}