MCPcopy Create free account
hub / github.com/1a1a11a/libCacheSim / create_spatial_sampler

Function create_spatial_sampler

libCacheSim/traceReader/sampling/spatial.c:41–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39void free_spatial_sampler(sampler_t *sampler) { free(sampler); }
40
41sampler_t *create_spatial_sampler(double sampling_ratio) {
42 if (sampling_ratio > 1 || sampling_ratio <= 0) {
43 ERROR("sampling ratio range error get %lf (should be 0-1)\n",
44 sampling_ratio);
45 } else if (sampling_ratio > 0.5) {
46 ERROR("currently we only support sampling ratio no more than 0.5\n");
47 } else if (sampling_ratio == 1) {
48 WARN("spatial sampler ratio 1 means no sampling\n");
49 return NULL;
50 }
51
52 sampler_t *s = my_malloc(sampler_t);
53 memset(s, 0, sizeof(sampler_t));
54 s->sampling_ratio = sampling_ratio;
55 s->sampling_ratio_inv = (int)(1.0 / sampling_ratio);
56 s->sampling_salt = 0;
57 s->sample = spatial_sample;
58 s->clone = clone_spatial_sampler;
59 s->free = free_spatial_sampler;
60 s->type = SPATIAL_SAMPLER;
61 // s->sampling_boundary = (uint64_t)(ratio * UINT64_MAX);
62
63 print_sampler(s);
64
65 VVERBOSE("create spatial sampler with ratio %lf\n", sampling_ratio);
66 return s;
67}
68
69
70void set_spatial_sampler_salt(sampler_t *sampler, uint64_t salt) {

Callers 4

runMethod · 0.85
create_readerFunction · 0.85
parse_cmdFunction · 0.85
parse_cmdFunction · 0.85

Calls 1

print_samplerFunction · 0.85

Tested by

no test coverage detected