| 532 | } |
| 533 | |
| 534 | static int |
| 535 | get_zipf(double v) |
| 536 | { |
| 537 | int l = 0, r = ZIPF_SIZE - 1, m; |
| 538 | do { |
| 539 | m = (r + l) / 2; |
| 540 | if (v < zipf_table[m]) { |
| 541 | r = m - 1; |
| 542 | } else { |
| 543 | l = m + 1; |
| 544 | } |
| 545 | } while (l < r); |
| 546 | if (zipf_bucket_size == 1) { |
| 547 | return m; |
| 548 | } |
| 549 | double x = zipf_table[m], y = zipf_table[m + 1]; |
| 550 | m += static_cast<int>((v - x) / (y - x)); |
| 551 | return m; |
| 552 | } |
| 553 | |
| 554 | static bool |
| 555 | test_RamCache(RegressionTest *t, RamCache *cache, const char *name, int64_t cache_size) |