| 631 | } |
| 632 | |
| 633 | void SnappyCompress(ThreadState* thread) { |
| 634 | RandomGenerator gen; |
| 635 | Slice input = gen.Generate(Options().block_size); |
| 636 | int64_t bytes = 0; |
| 637 | int64_t produced = 0; |
| 638 | bool ok = true; |
| 639 | std::string compressed; |
| 640 | while (ok && bytes < 1024 * 1048576) { // Compress 1G |
| 641 | ok = port::Snappy_Compress(input.data(), input.size(), &compressed); |
| 642 | produced += compressed.size(); |
| 643 | bytes += input.size(); |
| 644 | thread->stats.FinishedSingleOp(); |
| 645 | } |
| 646 | |
| 647 | if (!ok) { |
| 648 | thread->stats.AddMessage("(snappy failure)"); |
| 649 | } else { |
| 650 | char buf[100]; |
| 651 | snprintf(buf, sizeof(buf), "(output: %.1f%%)", |
| 652 | (produced * 100.0) / bytes); |
| 653 | thread->stats.AddMessage(buf); |
| 654 | thread->stats.AddBytes(bytes); |
| 655 | } |
| 656 | } |
| 657 | |
| 658 | void SnappyUncompress(ThreadState* thread) { |
| 659 | RandomGenerator gen; |
nothing calls this directly
no test coverage detected