// File: /workspace/github_cpp_makefile_star2_O2/dustin[P]kvtest/tests.cc
// Function: EnduranceTest::run(kvtest::KVStore*)
bool EnduranceTest::run(KVStore *tut) {
    long i = 0, prev_calls = 0;
    CountingCallback cb;
    time_t start = time(NULL);
    time_t step = time(NULL);
    const int alarm_freq = 10;
    Keys k(30000);
    Values v(20, 40000, 60000);

    setup_alarm(alarm_freq);

    std::cout << "# start time:  " << start << std::endl;
    std::cout << "# cmds\tbacklog\ttime\tabstime\trate" << std::endl;

    for(i = 0 ; ; i++) {
        std::string key(k.nextKey());
        const char *value = v.nextValue();

        tut->set(key, value, cb);
        if (alarmed) {
            time_t now = time(NULL);
            int delta = (int)(now - step);
            long new_calls = i - prev_calls;
            step = now;
            std::cout << i << "\t" << (i - cb.num_calls() + 1)
                      << "\t" << delta << "\t" << now << "\t"
                      << ((double)new_calls / (double)delta) << std::endl
                      << std::flush;
            prev_calls = i;
            setup_alarm(alarm_freq);
        }
    }

    // Last one to wait for a commit.
    RememberingCallback<bool> cbLast;
    tut->noop(cbLast);
    cbLast.waitForValue();
    time_t end = time(NULL);

    assertEquals((int)i, cb.num_calls());

    int delta = (int)(end - start);
    std::cout << "Ran " << i << " operations in "
              << delta << "s ("
              << (i/delta) << " ops/s)"
              << std::endl;
    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rsi, 0x18(%rsp)
leaq 0x80(%rsp), %rdi
callq 0x4f12
xorl %edi, %edi
callq 0x3220
movq %rax, %r14
xorl %edi, %edi
callq 0x3220
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
movl $0x7530, %esi           # imm = 0x7530
callq 0x5768
leaq 0x20(%rsp), %rdi
pushq $0x14
popq %rsi
movl $0x9c40, %edx           # imm = 0x9C40
movl $0xea60, %ecx           # imm = 0xEA60
callq 0x5a30
pushq $0xa
popq %rdi
callq 0x4812
movq 0x8708(%rip), %rdi      # 0xcfc8
leaq 0x38a6(%rip), %rsi      # 0x816d
callq 0x3240
movq %rax, %rdi
movq %r14, %rsi
callq 0x3230
movq %rax, %rdi
callq 0x30e0
movq 0x86e2(%rip), %rdi      # 0xcfc8
leaq 0x3890(%rip), %rsi      # 0x817d
callq 0x3240
movq %rax, %rdi
callq 0x30e0
movq %rbx, 0x10(%rsp)
movq $0x0, 0x8(%rsp)
leaq 0x60(%rsp), %r14
leaq 0x40(%rsp), %r15
leaq 0x7(%rsp), %rbx
leaq 0x20(%rsp), %r12
xorl %r13d, %r13d
movq %r14, %rdi
callq 0x5884
movq %r15, %rdi
movq %rax, %rsi
movq %rbx, %rdx
callq 0x3cf4
movq %r12, %rdi
callq 0x5bb6
movq 0x18(%rsp), %rdi
movq (%rdi), %r8
movq %r15, %rsi
movq %rax, %rdx
leaq 0x80(%rsp), %rcx
callq *0x28(%r8)
cmpb $0x0, 0x88e5(%rip)      # 0xd243
je 0x4a56
movq %rbx, %r12
movq %r14, %rbx
xorl %edi, %edi
callq 0x3220
movq %rax, %r14
movq 0x864d(%rip), %rdi      # 0xcfc8
movq %r13, %rsi
callq 0x3230
movq %rax, %rdi
leaq 0x3811(%rip), %rsi      # 0x819e
callq 0x3240
movq %rax, %r15
leaq 0x80(%rsp), %rdi
callq 0x503a
cltq
leaq 0x1(%r13), %rbp
movq %rbp, %rsi
subq %rax, %rsi
movq %r15, %rdi
callq 0x3230
movq %rax, %rdi
leaq 0x37de(%rip), %rsi      # 0x819e
callq 0x3240
movl %r14d, %r15d
subl 0x10(%rsp), %r15d
movq %rax, %rdi
movl %r15d, %esi
callq 0x33b0
movq %rax, %rdi
leaq 0x37bc(%rip), %rsi      # 0x819e
callq 0x3240
movq %rax, %rdi
movq %r14, %rsi
callq 0x3230
movq %rax, %rdi
leaq 0x37a2(%rip), %rsi      # 0x819e
callq 0x3240
movq %r13, %rcx
subq 0x8(%rsp), %rcx
cvtsi2sd %rcx, %xmm0
cvtsi2sd %r15d, %xmm1
divsd %xmm1, %xmm0
movq %rax, %rdi
callq 0x3370
movq %rax, %rdi
callq 0x30e0
movq %rax, %rdi
callq 0x3160
pushq $0xa
popq %rdi
callq 0x4812
movq %r14, 0x10(%rsp)
movq %r13, 0x8(%rsp)
movq %rbp, %r13
movq %rbx, %r14
movq %r12, %rbx
leaq 0x40(%rsp), %r15
leaq 0x20(%rsp), %r12
jmp 0x4a59
incq %r13
movq %r15, %rdi
callq 0x30d0
jmp 0x491f
jmp 0x4a7b
jmp 0x4a7b
jmp 0x4a6c
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x30d0
jmp 0x4a7e
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x5b86
jmp 0x4a8d
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x5854
jmp 0x4a9c
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x506a
movq %rbx, %rdi
callq 0x33c0