MCPcopy Create free account
hub / github.com/apache/trafficserver / build_zipf

Function build_zipf

src/iocore/cache/CacheTest.cc:515–532  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

513static double *zipf_table = nullptr;
514
515static void
516build_zipf()
517{
518 if (zipf_table) {
519 return;
520 }
521 zipf_table = static_cast<double *>(ats_malloc(ZIPF_SIZE * sizeof(double)));
522 for (int i = 0; i < ZIPF_SIZE; i++) {
523 zipf_table[i] = 1.0 / pow(i + 2, zipf_alpha);
524 }
525 for (int i = 1; i < ZIPF_SIZE; i++) {
526 zipf_table[i] = zipf_table[i - 1] + zipf_table[i];
527 }
528 double x = zipf_table[ZIPF_SIZE - 1];
529 for (int i = 0; i < ZIPF_SIZE; i++) {
530 zipf_table[i] = zipf_table[i] / x;
531 }
532}
533
534static int
535get_zipf(double v)

Callers 1

test_RamCacheFunction · 0.85

Calls 1

ats_mallocFunction · 0.85

Tested by

no test coverage detected