static char* test_scaling_equivalence() { load_histograms(); mu_assert( "Averages should be equivalent", compare_values( hdr_mean(cor_histogram) * 512, hdr_mean(scaled_cor_histogram), 0.000001)); mu_assert( "Total count should be equivalent", compare_int64( cor_histogram->total_count, scaled_cor_histogram->total_count)); int64_t expected_99th = hdr_value_at_percentile(cor_histogram, 99.0) * 512; int64_t scaled_99th = hdr_value_at_percentile(scaled_cor_histogram, 99.0); mu_assert( "99%'iles should be equivalent", compare_int64( hdr_lowest_equivalent_value(cor_histogram, expected_99th), hdr_lowest_equivalent_value(scaled_cor_histogram, scaled_99th))); mu_assert( "Max should be equivalent", compare_int64(hdr_max(cor_histogram) * 512, hdr_max(scaled_cor_histogram))); return 0; }
ERL_NIF_TERM _hh_lowest_at(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) { int64_t value = 0; hh_ctx_t* ctx = NULL; ErlNifResourceType* ctx_type = get_hh_ctx_type(env); if (argc != 2 || ctx_type == NULL || !enif_get_resource(env, argv[0], ctx_type, (void **)&ctx) || ctx->data == NULL || !enif_get_int64(env, argv[1], &value)) { return enif_make_badarg(env); } if (ctx != NULL) { return enif_make_int64( env, hdr_lowest_equivalent_value(ctx->data, value) ); } return make_error(env, "bad_hdr_histogram_nif_impl"); }